Skip to content

Commit f3945b9

Browse files
authored
Add build job with turbo cache to CI (#1615)
<!-- How to write a good PR title: - Follow [the Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). - Give as much context as necessary and as little as possible - Prefix it with [WIP] while it’s a work in progress --> ## Self Checklist - [x] I wrote a PR title in **English** and added an appropriate **label** to the PR. - [x] I wrote the commit message in **English** and to follow [**the Conventional Commits specification**](https://www.conventionalcommits.org/en/v1.0.0/). - [x] I [added the **changeset**](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md) about the changes that needed to be released. (or didn't have to) - [x] I wrote or updated **documentation** related to the changes. (or didn't have to) - [x] I wrote or updated **tests** related to the changes. (or didn't have to) - [x] I tested the changes in various browsers. (or didn't have to) - Windows: Chrome, Edge, (Optional) Firefox - macOS: Chrome, Edge, Safari, (Optional) Firefox ## Related Issue <!-- Please link to issue if one exists --> Fixes #1005 ## Summary <!-- Please brief explanation of the changes made --> - 빌드 잡을 CI에 추가합니다. - 빌드 잡에 캐시를 추가합니다. ## Details <!-- Please elaborate description of the changes --> 기존에 `--filter=bezier-icons` 를 통해 아이콘 패키지만 빌드하던 것에서 필터를 제거하고, 모든 패키지를 빌드하도록 변경합니다. 의존성 업데이트 등 변경이 있었을 경우 라이브러리가 정상적으로 빌드되는 지 검증하기 위해서입니다. #1424 에서 빌드 시간이 많이 단축되었지만, 필터가 제거되었으므로 총 빌드 시간도 유의미하게 증가하게 될 거라 생각했습니다. 이를 방지하고자 빌드 잡에 캐시를 추가했습니다. ### 빌드 잡에 캐시 추가 - 기존엔 jest의 캐시가 없었습니다. 캐시 관련 설정을 추가합니다. - 마이너: 캐시 설정을 추가하며 jest 설정을 레포지토리 전반적으로 통일합니다. jest 관련 패키지를 루트로 옮기고, `@swc/jest` 를 모든 패키지에 적용하여 테스트 수행시간을 줄이고자 했습니다. 기본값과 동일하거나 불필요한 jest 설정 옵션은 제거했습니다. - `test:ci` 스크립트를 제거하고 기존 `test: jest --onlyChanged` 스크립트를 `test:ci` 와 동일한 스크립트로 변경합니다. 기존에 only changed 플래그가 추가되었던 이유가 pre-commit 훅을 빠르게 수행하기 위해서였는데, pre-commit 훅이 제거되었기때문에 불필요해졌다고 판단했습니다. ### Breaking change? (Yes/No) <!-- If Yes, please describe the impact and migration path for users --> No
1 parent 5042b04 commit f3945b9

File tree

19 files changed

+123
-181
lines changed

19 files changed

+123
-181
lines changed

.circleci/config.yml

Lines changed: 56 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
version: 2.1
22

33
orbs:
4-
codecov: codecov/codecov@1.2.0
4+
node: circleci/node@5.1.0
5+
codecov: codecov/codecov@3.3.0
56

67
references:
78
workspace_root: &workspace_root
@@ -10,74 +11,98 @@ references:
1011
attach_workspace: &attach_workspace
1112
attach_workspace:
1213
at: *workspace_root
14+
15+
build_cache_paths: &build_cache_paths
16+
paths:
17+
- node_modules/.cache/turbo
1318

14-
defaults: &defaults
15-
resource_class: xlarge
16-
working_directory: *workspace_root
19+
lint_cache_paths: &lint_cache_paths
20+
paths:
21+
- packages/bezier-react/.stylelintcache
22+
- packages/bezier-react/.eslintcache
23+
- packages/bezier-icons/.eslintcache
24+
- packages/bezier-figma-plugin/.eslintcache
25+
- packages/bezier-codemod/.eslintcache
1726

18-
docker:
19-
- image: node:18.17.1
27+
test_cache_paths: &test_cache_paths
28+
paths:
29+
- packages/bezier-react/.jestcache
30+
- packages/bezier-icons/.jestcache
31+
- packages/bezier-figma-plugin/.jestcache
32+
- packages/bezier-codemod/.jestcache
2033

21-
filter_only_tagged: &filter_only_tagged
22-
filters:
23-
tags:
24-
only: /^v.*/
25-
branches:
26-
ignore: /.*/
34+
executors:
35+
node_executor:
36+
docker:
37+
- image: node:18.17.1
38+
resource_class: xlarge
39+
working_directory: *workspace_root
2740

2841
jobs:
2942
install:
30-
<<: *defaults
43+
executor: node_executor
3144
steps:
3245
- checkout
33-
- restore_cache:
34-
keys:
35-
- bezier-react-dependencies-{{ checksum "yarn.lock" }}
36-
- run: yarn install
37-
- save_cache:
38-
paths:
39-
- .yarn/cache
40-
- .yarn/unplugged
41-
key: bezier-react-dependencies-{{ checksum "yarn.lock" }}
46+
- node/install-packages:
47+
pkg-manager: yarn
4248
- persist_to_workspace:
4349
root: *workspace_root
4450
paths:
4551
- .
4652

4753
build:
48-
<<: *defaults
54+
executor: node_executor
4955
steps:
5056
- *attach_workspace
51-
- run: yarn build --filter=bezier-icons
57+
- restore_cache:
58+
keys:
59+
- build-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-
60+
- build-{{ .Environment.CACHE_VERSION }}-
61+
- run: yarn build
62+
- save_cache:
63+
key: build-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ epoch }}
64+
<<: *build_cache_paths
5265
- persist_to_workspace:
5366
root: *workspace_root
5467
paths:
5568
- .
5669

5770
lint:
58-
<<: *defaults
71+
executor: node_executor
5972
steps:
6073
- *attach_workspace
74+
- restore_cache:
75+
keys:
76+
- lint-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-
77+
- lint-{{ .Environment.CACHE_VERSION }}-
6178
- run: yarn lint
79+
- save_cache:
80+
key: lint-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ epoch }}
81+
<<: *lint_cache_paths
6282

6383
typecheck:
64-
<<: *defaults
84+
executor: node_executor
6585
steps:
6686
- *attach_workspace
6787
- run: yarn typecheck
6888

6989
test:
70-
<<: *defaults
90+
executor: node_executor
7191
steps:
7292
- *attach_workspace
73-
- run: yarn test:ci
93+
- restore_cache:
94+
keys:
95+
- test-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-
96+
- test-{{ .Environment.CACHE_VERSION }}-
97+
- run: yarn test
7498
- codecov/upload:
7599
file: './packages/bezier-react/coverage/lcov.info'
76-
token: $CODECOV_TOKEN
100+
- save_cache:
101+
key: test-{{ .Environment.CACHE_VERSION }}-{{ .Branch }}-{{ epoch }}
102+
<<: *test_cache_paths
77103

78104
workflows:
79-
version: 2
80-
lint_and_test:
105+
ci:
81106
jobs:
82107
- install
83108
- build:

.github/workflows/chromatic-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
name: Chromatic Report
1313
runs-on: ubuntu-latest
1414
steps:
15-
- name: Checkout Repo
15+
- name: Checkout
1616
uses: actions/checkout@v4
1717

1818
- name: Download artifact

.github/workflows/chromatic.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
push:
55
branches:
66
- main
7+
- alpha
78
pull_request:
8-
types: [opened, reopened, synchronize]
99
paths:
1010
- packages/bezier-react/**
1111

@@ -15,33 +15,32 @@ jobs:
1515
name: Chromatic
1616
runs-on: ubuntu-latest
1717
steps:
18-
- name: Get Yarn cache path
19-
id: yarn-cache
20-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
21-
22-
- name: Checkout Repo
18+
- name: Checkout
2319
uses: actions/checkout@v4
2420
with:
2521
fetch-depth: 0
2622

2723
- name: Setup Node.js
2824
uses: actions/setup-node@v3
2925
with:
30-
node-version: 18.17.1
26+
node-version-file: .nvmrc
27+
cache: yarn
3128

32-
- name: Load Yarn cache
29+
- name: Restore cache
3330
uses: actions/cache@v3
3431
with:
35-
path: ${{ steps.yarn-cache.outputs.dir }}
36-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
32+
path: |
33+
**/.turbo
34+
node_modules/.cache/turbo
35+
key: ${{ runner.os }}-chromatic-${{ github.sha }}
3736
restore-keys: |
38-
${{ runner.os }}-yarn-
37+
${{ runner.os }}-chromatic-
3938
40-
- name: Install Dependencies
39+
- name: Install dependencies
4140
run: yarn
4241

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

4645
- name: Publish to Chromatic
4746
uses: chromaui/action@v1

.github/workflows/generate-icon-files.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ jobs:
1212
name: Generate icon files from icons.json file
1313
runs-on: ubuntu-latest
1414
steps:
15-
- name: Checkout Repo
15+
- name: Checkout
1616
uses: actions/checkout@v4
1717

1818
- name: Setup Node.js
1919
uses: actions/setup-node@v3
2020
with:
21-
node-version: 18.17.1
21+
node-version-file: .nvmrc
2222

2323
- name: Git Config
2424
run: |

.github/workflows/release.yml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,17 @@ jobs:
1010
name: Release
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Get Yarn cache path
14-
id: yarn-cache
15-
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
16-
17-
- name: Checkout Repo
13+
- name: Checkout
1814
uses: actions/checkout@v4
19-
with:
20-
fetch-depth: 0
2115

2216
- name: Setup Node.js
2317
uses: actions/setup-node@v3
2418
with:
25-
node-version: 18.17.1
26-
27-
- name: Load Yarn cache
28-
uses: actions/cache@v3
29-
with:
30-
path: ${{ steps.yarn-cache.outputs.dir }}
31-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
32-
restore-keys: |
33-
${{ runner.os }}-yarn-
19+
node-version-file: .nvmrc
20+
cache: yarn
3421

35-
- name: Install Dependencies
22+
- name: Install dependencies
3623
run: yarn
37-
env:
38-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
3924

4025
- name: Create release Pull Request or publish to NPM
4126
id: changesets

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,6 @@ stats.html
215215

216216
# Rollup cache
217217
.rollup.cache
218+
219+
# Jest cache
220+
.jestcache

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"lint": "turbo run lint",
1313
"typecheck": "turbo run typecheck",
1414
"test": "turbo run test",
15-
"test:ci": "turbo run test:ci",
1615
"clean": "turbo run clean && rm -rf node_modules .turbo",
1716
"version-packages": "changeset version && yarn --mode=\"update-lockfile\"",
1817
"release": "turbo run build --filter='@channel.io/*' && changeset publish",
@@ -27,13 +26,17 @@
2726
"@channel.io/stylelint-config": "^1.2.0",
2827
"@commitlint/cli": "^17.7.1",
2928
"@commitlint/config-conventional": "^17.7.0",
29+
"@swc/core": "^1.3.83",
30+
"@swc/jest": "^0.2.29",
31+
"@types/jest": "^29.5.4",
3032
"cz-conventional-changelog": "^3.3.0",
3133
"eslint": "^7.32.0",
3234
"eslint-config-bezier": "workspace:*",
3335
"husky": "^8.0.3",
36+
"jest": "^29.6.4",
37+
"jest-environment-jsdom": "^29.6.4",
3438
"npm-run-all": "^4.1.5",
3539
"stylelint": "^13.13.1",
36-
"ts-node": "^10.9.1",
3740
"turbo": "^1.10.13",
3841
"typescript": "^4.9.5"
3942
},
Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
/** @type {import('ts-jest').JestConfigWithTsJest} */
1+
/** @type {import('jest').Config} */
22
module.exports = {
3-
preset: 'ts-jest/presets/default-esm',
3+
cacheDirectory: '.jestcache',
4+
testEnvironment: 'node',
5+
transform: {
6+
'^.+\\.[t|j]sx?$': ['@swc/jest'],
7+
},
48
moduleNameMapper: {
59
'^(\\.{1,2}/.*)\\.js$': '$1',
610
},
7-
transform: {
8-
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
9-
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
10-
'^.+\\.tsx?$': [
11-
'ts-jest',
12-
{
13-
useESM: true,
14-
},
15-
],
16-
},
17-
testEnvironment: 'node',
18-
testRegex: '\\.test\\.ts$',
11+
testMatch: ['**/*.test.(ts|tsx)'],
1912
}

packages/bezier-codemod/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"dev": "tsc --watch",
2020
"lint": "TIMING=1 eslint --cache .",
2121
"typecheck": "tsc --noEmit",
22-
"test": "jest --onlyChanged",
23-
"clean": "rm -rf dist node_modules .turbo .eslintcache"
22+
"test": "jest",
23+
"clean": "rm -rf dist node_modules .turbo .eslintcache .jestcache"
2424
},
2525
"files": [
2626
"dist"
@@ -33,12 +33,9 @@
3333
"ts-morph": "^19.0.0"
3434
},
3535
"devDependencies": {
36-
"@types/jest": "^29.5.4",
3736
"@types/node": "^20.6.0",
3837
"@types/react": "^18.2.21",
3938
"eslint-config-bezier": "workspace:*",
40-
"jest": "^29.6.4",
41-
"ts-jest": "^29.1.1",
4239
"tsconfig": "workspace:*"
4340
},
4441
"keywords": [

packages/bezier-figma-plugin/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
"lint": "run-p 'lint:*'",
1515
"lint:js": "TIMING=1 eslint --cache .",
1616
"lint:style": "stylelint --allow-empty-input --cache '**/*.styled.{js,ts}'",
17+
"typecheck": "tsc --noEmit",
1718
"clean": "run-s 'clean:*'",
1819
"clean:build": "rm -rf dist",
19-
"clean:cache": "rm -rf node_modules .turbo .eslintcache"
20+
"clean:cache": "rm -rf node_modules .turbo .eslintcache .jestcache"
2021
},
2122
"author": "Channel Corp.",
2223
"license": "Apache-2.0",

packages/bezier-icons/jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('jest').Config} */
2+
module.exports = {
3+
cacheDirectory: '.jestcache',
4+
testEnvironment: 'jsdom',
5+
transform: {
6+
'^.+\\.[t|j]sx?$': ['@swc/jest'],
7+
},
8+
}

packages/bezier-icons/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"build": "rollup -c",
2929
"dev": "rollup -c -w",
3030
"lint": "TIMING=1 eslint --cache .",
31-
"typecheck": "tsc --build --verbose",
32-
"test": "jest --onlyChanged",
31+
"typecheck": "tsc --noEmit",
32+
"test": "jest",
3333
"clean": "run-s 'clean:*'",
3434
"clean:build": "rm -rf dist",
3535
"clean:cache": "rm -rf node_modules .turbo .eslintcache stats.html"
@@ -56,7 +56,6 @@
5656
"@svgr/core": "^8.1.0",
5757
"@svgr/plugin-jsx": "^8.1.0",
5858
"eslint-config-bezier": "workspace:^",
59-
"jest": "^29.6.4",
6059
"rollup": "^3.29.1",
6160
"rollup-plugin-visualizer": "^5.9.2",
6261
"svgo": "^3.0.2",

packages/bezier-icons/tsconfig.eslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
".eslintrc.js",
77
"babel.config.js",
88
"rollup.config.mjs",
9+
"jest.config.js",
910
],
1011
}

packages/bezier-icons/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"compilerOptions": {
3-
"noEmit": true,
43
"target": "es2017",
54
"moduleResolution": "node",
65
"lib": ["es2017", "dom"],

0 commit comments

Comments
 (0)