Skip to content

Commit 654033a

Browse files
committed
ci: build before test and reuse cache in jobs
1 parent 9421343 commit 654033a

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

.github/workflows/test.yml

+37
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,37 @@ env:
1616
CI: true
1717

1818
jobs:
19+
build:
20+
name: 'Build for tests on Node.js ${{ matrix.node }} OS: ${{matrix.os}}'
21+
runs-on: ${{ matrix.os }}
22+
strategy:
23+
matrix:
24+
os: [ubuntu-latest]
25+
node: [18, 20, 22]
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Install pnpm
31+
uses: pnpm/action-setup@v4
32+
33+
- name: Setup Node.js ${{ matrix.node }}
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: ${{ matrix.node }}
37+
cache: 'pnpm'
38+
39+
- name: Install dependencies
40+
run: pnpm install
41+
42+
- name: Build code
43+
run: pnpm build
44+
45+
- name: Cache dist
46+
uses: actions/cache@v4
47+
with:
48+
path: packages/*/dist
49+
key: build-intlify-bundle-tools-os-${{ matrix.os }}-${{ github.sha }}
1950
test:
2051
name: 'Test on Node.js ${{ matrix.node }} OS: ${{matrix.os}} (${{ matrix.framework }})'
2152
runs-on: ${{ matrix.os }}
@@ -57,6 +88,12 @@ jobs:
5788
# does not need to explicitly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved
5889
run: pnpm playwright install chromium
5990

91+
- name: Restore dist cache
92+
uses: actions/cache@v4
93+
with:
94+
path: packages/*/dist
95+
key: build-intlify-bundle-tools-os-${{ matrix.os }}-${{ github.sha }}
96+
6097
- name: Testing
6198
run: pnpm test
6299
env:

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"build:example": "run-s \"build:example:vite {@}\" \"build:example:webpack\" --",
112112
"build:example:vite": "cd examples/vite && vite build --config ./vite.config.ts --outDir ./dist",
113113
"build:example:webpack": "pnpm build && webpack --config ./examples/webpack/webpack.config.js",
114-
"build:example:rspack": "pnpm build && rspack --config ./examples/rspack/rsbuild.config.js",
114+
"build:example:rspack": "pnpm build && rspack --config ./examples/rspack/rsbuild.config.ts",
115115
"play:vite": "vite examples/vite -c examples/vite/vite.config.ts",
116116
"play:webpack": "pnpm run build:unplugin && webpack serve --config ./examples/webpack/webpack.config.mjs",
117117
"play:rspack": "rspack dev --config ./examples/rspack/rspack.config.mjs",
@@ -131,7 +131,7 @@
131131
"lint": "run-p \"lint:* {@}\" --",
132132
"lint:eslint": "eslint --flag unstable_ts_config .",
133133
"lint:prettier": "prettier . --check",
134-
"test": "pnpm build && pnpm test:unit && pnpm test:e2e",
134+
"test": "pnpm test:unit && pnpm test:e2e",
135135
"test:e2e": "pnpm check-install && vitest -c ./vitest.e2e.config.ts run",
136136
"test:e2e:rollup": "pnpm --filter @intlify/rollup-plugin-vue-i18n test:e2e",
137137
"test:e2e:vite": "pnpm --filter @intlify/vite-plugin-vue-i18n test:e2e",

0 commit comments

Comments
 (0)