Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build job with turbo cache to CI #1615

Merged
merged 36 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ed0969f
test(jest): config cache directory
sungik-choi Sep 11, 2023
e256636
ci: move ci workflow fron circle ci to github actions
sungik-choi Sep 11, 2023
986416d
ci: apply cache and refine each step
sungik-choi Sep 11, 2023
ba0572a
build: remove test:ci script and add jest cache to outputs of test pi…
sungik-choi Sep 11, 2023
8dab4e6
chore(deps): move jest-relate packages from each packages to root pac…
sungik-choi Sep 11, 2023
7a9c9cf
chore: remove onlyChanged flag of test script
sungik-choi Sep 11, 2023
1815991
test: unify test setup with SWC and add cache directory
sungik-choi Sep 11, 2023
337ea6f
ci(validate): improved execution of lint, typecheck, and test scripts…
sungik-choi Sep 11, 2023
481b472
chore: add .jestcache to clean script
sungik-choi Sep 11, 2023
ea59e54
ci: seperate cache key based on workflow
sungik-choi Sep 11, 2023
5a903e7
refactor(ci): use default fetch depth option of actions/checkout
sungik-choi Sep 14, 2023
989a12b
refactor(ci): change the hard-coded node version to .nvmrc directory
sungik-choi Sep 14, 2023
11e1dae
Merge branch 'main' into ci/build
sungik-choi Oct 10, 2023
90f2750
chore(deps): clean up dependecies
sungik-choi Oct 10, 2023
5a13673
ci(github): enhance chromatic workflow
sungik-choi Oct 10, 2023
50a12a3
ci(github): format
sungik-choi Oct 10, 2023
d273587
ci(github): add alpha branch to chromatic trigger branch
sungik-choi Oct 10, 2023
7c36660
build(turbo): define workspace-tasks
sungik-choi Oct 10, 2023
542e3bd
ci(github): use turbo pipeline instead of custom validate script
sungik-choi Oct 10, 2023
eb10825
ci(github): fix chromatic workflow
sungik-choi Oct 10, 2023
e98c23e
Merge branch 'main' into ci/build
sungik-choi Oct 17, 2023
1590bb6
ci(circle): revert config.yml
sungik-choi Oct 17, 2023
9b79f79
build(packages): unify typecheck script
sungik-choi Oct 17, 2023
e0b140e
ci: remove ci github action and revert circle ci config file
sungik-choi Oct 17, 2023
9866576
ci: add new line
sungik-choi Oct 17, 2023
392fcc9
ci(circle): remove unnecessary token param
sungik-choi Oct 17, 2023
2b2e9a3
ci(circle): remove disallowed key
sungik-choi Oct 17, 2023
eaecc7f
build(turbo): remove unnecessary workflow pipeline
sungik-choi Oct 17, 2023
1629c28
ci(circle): changed to a single pipeline to reduce workspace attach p…
sungik-choi Oct 17, 2023
e9c1a49
Revert "ci(circle): changed to a single pipeline to reduce workspace …
sungik-choi Oct 17, 2023
7a786af
ci(circle): enhance workspace and cache config
sungik-choi Oct 17, 2023
7649906
ci(circle): fix workspace path
sungik-choi Oct 17, 2023
43a6453
ci(circle): wip: add concurrency option to prevent SIGKILL
sungik-choi Oct 17, 2023
d5ada1b
ci(circle): change concurrency number from 2 to 1
sungik-choi Oct 17, 2023
535a26f
ci(circle): use xlarge resource and remove concurrency option
sungik-choi Oct 17, 2023
76d7b6d
ci(chromatic): remove unnecessary diffs
sungik-choi Oct 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 56 additions & 31 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
version: 2.1

orbs:
codecov: codecov/codecov@1.2.0
node: circleci/node@5.1.0
codecov: codecov/codecov@3.3.0

references:
workspace_root: &workspace_root
Expand All @@ -10,74 +11,98 @@ references:
attach_workspace: &attach_workspace
attach_workspace:
at: *workspace_root

build_cache_paths: &build_cache_paths
paths:
- node_modules/.cache/turbo

defaults: &defaults
resource_class: xlarge
working_directory: *workspace_root
lint_cache_paths: &lint_cache_paths
paths:
- packages/bezier-react/.stylelintcache
- packages/bezier-react/.eslintcache
- packages/bezier-icons/.eslintcache
- packages/bezier-figma-plugin/.eslintcache
- packages/bezier-codemod/.eslintcache

docker:
- image: node:18.17.1
test_cache_paths: &test_cache_paths
paths:
- packages/bezier-react/.jestcache
- packages/bezier-icons/.jestcache
- packages/bezier-figma-plugin/.jestcache
- packages/bezier-codemod/.jestcache

filter_only_tagged: &filter_only_tagged
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
Comment on lines -21 to -26
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused

executors:
node_executor:
docker:
- image: node:18.17.1
resource_class: xlarge
working_directory: *workspace_root

jobs:
install:
<<: *defaults
executor: node_executor
steps:
- checkout
- restore_cache:
keys:
- bezier-react-dependencies-{{ checksum "yarn.lock" }}
- run: yarn install
- save_cache:
paths:
- .yarn/cache
- .yarn/unplugged
key: bezier-react-dependencies-{{ checksum "yarn.lock" }}
- node/install-packages:
pkg-manager: yarn
- persist_to_workspace:
root: *workspace_root
paths:
- .

build:
<<: *defaults
executor: node_executor
steps:
- *attach_workspace
- run: yarn build --filter=bezier-icons
- restore_cache:
keys:
- build-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-
- build-{{ .Environment.CACHE_VERSION }}-
- run: yarn build
- save_cache:
key: build-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ epoch }}
<<: *build_cache_paths
- persist_to_workspace:
root: *workspace_root
paths:
- .

lint:
<<: *defaults
executor: node_executor
steps:
- *attach_workspace
- restore_cache:
keys:
- lint-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-
- lint-{{ .Environment.CACHE_VERSION }}-
- run: yarn lint
- save_cache:
key: lint-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ epoch }}
<<: *lint_cache_paths

typecheck:
<<: *defaults
executor: node_executor
steps:
- *attach_workspace
- run: yarn typecheck

test:
<<: *defaults
executor: node_executor
steps:
- *attach_workspace
- run: yarn test:ci
- restore_cache:
keys:
- test-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-
- test-{{ .Environment.CACHE_VERSION }}-
- run: yarn test
- codecov/upload:
file: './packages/bezier-react/coverage/lcov.info'
token: $CODECOV_TOKEN
- save_cache:
key: test-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ epoch }}
<<: *test_cache_paths

workflows:
version: 2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deprecated

lint_and_test:
ci:
jobs:
- install
- build:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/chromatic-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
name: Chromatic Report
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v3

- name: Download artifact
uses: actions/github-script@v6
Expand Down
27 changes: 13 additions & 14 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
push:
branches:
- main
- alpha
pull_request:
types: [opened, reopened, synchronize]
sungik-choi marked this conversation as resolved.
Show resolved Hide resolved
paths:
- packages/bezier-react/**

Expand All @@ -15,33 +15,32 @@ jobs:
name: Chromatic
runs-on: ubuntu-latest
steps:
- name: Get Yarn cache path
id: yarn-cache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Checkout Repo
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.17.1
node-version-file: .nvmrc
cache: yarn

- name: Load Yarn cache
- name: Restore cache
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: |
**/.turbo
node_modules/.cache/turbo
key: ${{ runner.os }}-chromatic-${{ github.sha }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-chromatic-

- name: Install Dependencies
- name: Install dependencies
run: yarn

- name: Build Packages
run: yarn build --filter=bezier-icons
- name: Build bezier-react's dependencies
run: yarn build --filter=@channel.io/bezier-react^...

- name: Publish to Chromatic
uses: chromaui/action@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/generate-icon-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
name: Generate icon files from icons.json file
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.17.1
node-version-file: .nvmrc

- name: Git Config
run: |
Expand Down
23 changes: 4 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,17 @@ jobs:
name: Release
runs-on: ubuntu-latest
steps:
- name: Get Yarn cache path
id: yarn-cache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Checkout Repo
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.17.1

- name: Load Yarn cache
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
node-version-file: .nvmrc
cache: yarn

- name: Install Dependencies
- name: Install dependencies
run: yarn
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create release Pull Request or publish to NPM
id: changesets
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,6 @@ stats.html

# Rollup cache
.rollup.cache

# Jest cache
.jestcache
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"lint": "turbo run lint",
"typecheck": "turbo run typecheck",
"test": "turbo run test",
"test:ci": "turbo run test:ci",
"clean": "turbo run clean && rm -rf node_modules .turbo",
"version-packages": "changeset version && yarn --mode=\"update-lockfile\"",
"release": "turbo run build --filter='@channel.io/*' && changeset publish",
Expand All @@ -27,13 +26,17 @@
"@channel.io/stylelint-config": "^1.2.0",
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@swc/core": "^1.3.83",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.4",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.32.0",
"eslint-config-bezier": "workspace:*",
"husky": "^8.0.3",
"jest": "^29.6.4",
"jest-environment-jsdom": "^29.6.4",
"npm-run-all": "^4.1.5",
"stylelint": "^13.13.1",
"ts-node": "^10.9.1",
"turbo": "^1.10.13",
"typescript": "^4.9.5"
},
Expand Down
21 changes: 7 additions & 14 deletions packages/bezier-codemod/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
/** @type {import('jest').Config} */
module.exports = {
preset: 'ts-jest/presets/default-esm',
cacheDirectory: '.jestcache',
testEnvironment: 'node',
transform: {
'^.+\\.[t|j]sx?$': ['@swc/jest'],
},
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
transform: {
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
useESM: true,
},
],
},
testEnvironment: 'node',
testRegex: '\\.test\\.ts$',
testMatch: ['**/*.test.(ts|tsx)'],
}
7 changes: 2 additions & 5 deletions packages/bezier-codemod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"dev": "tsc --watch",
"lint": "TIMING=1 eslint --cache .",
"typecheck": "tsc --noEmit",
"test": "jest --onlyChanged",
"clean": "rm -rf dist node_modules .turbo .eslintcache"
"test": "jest",
"clean": "rm -rf dist node_modules .turbo .eslintcache .jestcache"
},
"files": [
"dist"
Expand All @@ -33,12 +33,9 @@
"ts-morph": "^19.0.0"
},
"devDependencies": {
"@types/jest": "^29.5.4",
"@types/node": "^20.6.0",
"@types/react": "^18.2.21",
"eslint-config-bezier": "workspace:*",
"jest": "^29.6.4",
"ts-jest": "^29.1.1",
"tsconfig": "workspace:*"
},
"keywords": [
Expand Down
3 changes: 2 additions & 1 deletion packages/bezier-figma-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
"lint": "run-p 'lint:*'",
"lint:js": "TIMING=1 eslint --cache .",
"lint:style": "stylelint --allow-empty-input --cache '**/*.styled.{js,ts}'",
"typecheck": "tsc --noEmit",
"clean": "run-s 'clean:*'",
"clean:build": "rm -rf dist",
"clean:cache": "rm -rf node_modules .turbo .eslintcache"
"clean:cache": "rm -rf node_modules .turbo .eslintcache .jestcache"
},
"author": "Channel Corp.",
"license": "Apache-2.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/bezier-icons/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('jest').Config} */
module.exports = {
cacheDirectory: '.jestcache',
testEnvironment: 'jsdom',
transform: {
'^.+\\.[t|j]sx?$': ['@swc/jest'],
},
}
5 changes: 2 additions & 3 deletions packages/bezier-icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"build": "rollup -c",
"dev": "rollup -c -w",
"lint": "TIMING=1 eslint --cache .",
"typecheck": "tsc --build --verbose",
"test": "jest --onlyChanged",
"typecheck": "tsc --noEmit",
"test": "jest",
"clean": "run-s 'clean:*'",
"clean:build": "rm -rf dist",
"clean:cache": "rm -rf node_modules .turbo .eslintcache stats.html"
Expand All @@ -56,7 +56,6 @@
"@svgr/core": "^8.1.0",
"@svgr/plugin-jsx": "^8.1.0",
"eslint-config-bezier": "workspace:^",
"jest": "^29.6.4",
"rollup": "^3.29.1",
"rollup-plugin-visualizer": "^5.9.2",
"svgo": "^3.0.2",
Expand Down
1 change: 1 addition & 0 deletions packages/bezier-icons/tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
".eslintrc.js",
"babel.config.js",
"rollup.config.mjs",
"jest.config.js",
],
}
1 change: 0 additions & 1 deletion packages/bezier-icons/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"compilerOptions": {
"noEmit": true,
"target": "es2017",
"moduleResolution": "node",
"lib": ["es2017", "dom"],
Expand Down
Loading