Skip to content

Commit 93223ad

Browse files
authored
ci: simplify CI matrix and more comprehensive tests (#640)
1 parent 479f02c commit 93223ad

File tree

1 file changed

+96
-116
lines changed

1 file changed

+96
-116
lines changed

.github/workflows/ci.yml

+96-116
Original file line numberDiff line numberDiff line change
@@ -16,113 +16,112 @@ jobs:
1616
name: Build the package
1717
steps:
1818
- uses: actions/checkout@v4
19-
- uses: pnpm/action-setup@v3
19+
with:
20+
submodules: true
21+
- uses: pnpm/action-setup@v4
2022
- uses: actions/setup-node@v4
2123
with:
2224
node-version: 22
2325
cache: 'pnpm'
2426
- run: pnpm install
2527
env:
2628
CYPRESS_INSTALL_BINARY: 0
29+
CHROMEDRIVER_SKIP_DOWNLOAD: true
2730
- run: pnpm build
2831
- run: pnpm test:unit
2932

30-
# Use cache to share the output across different jobs
31-
# No need to cache node_modules because they are all bundled
32-
- uses: actions/cache/save@v4
33-
id: cache
34-
with:
35-
path: outfile.cjs
36-
key: ${{ github.sha }}-${{ hashFiles('pnpm-lock.yaml') }}
33+
- run: pnpm snapshot
3734

38-
test:
35+
# Use artifact to share the output across different jobs
36+
# No need to save node_modules because they are all bundled
37+
- uses: actions/upload-artifact@v4
38+
with:
39+
name: build-output
40+
path: |
41+
outfile.cjs
42+
playground
43+
retention-days: 3
44+
45+
verify-scripts:
46+
needs: build
47+
strategy:
48+
matrix:
49+
node-version: [18, 20, 22]
50+
os: [ubuntu-latest, windows-latest, macos-latest]
51+
verification-script:
52+
- pnpm --filter "\!*typescript*" build
53+
- pnpm --filter "*typescript*" build
54+
- pnpm --filter "*vitest*" test:unit
55+
- pnpm --filter "*eslint*" lint --no-fix --max-warnings=0
56+
- pnpm --filter "*prettier*" format --write --check
57+
# FIXME: it's failing now
58+
# - pnpm --filter "*with-tests*" test:unit
59+
runs-on: ${{ matrix.os }}
60+
continue-on-error: ${{ matrix.os == 'windows-latest' }}
61+
env:
62+
CYPRESS_INSTALL_BINARY: 0
63+
CHROMEDRIVER_SKIP_DOWNLOAD: true
64+
steps:
65+
- uses: actions/checkout@v4
66+
with:
67+
submodules: true
68+
- uses: pnpm/action-setup@v4
69+
- uses: actions/setup-node@v4
70+
with:
71+
node-version: ${{ matrix.node-version }}
72+
cache: 'pnpm'
73+
74+
# use artifacts to share the playground across different jobs
75+
- uses: actions/download-artifact@v4
76+
with:
77+
name: build-output
78+
79+
- name: Install dependencies to avoid tsconfig warnings
80+
run: pnpm install
81+
- name: Install dependencies in playground
82+
working-directory: ./playground
83+
run: pnpm install --no-frozen-lockfile
84+
85+
- name: Run build script in playground
86+
working-directory: ./playground
87+
run: ${{ matrix.verification-script }}
88+
89+
verify-e2e:
3990
needs: build
4091
strategy:
4192
matrix:
42-
flag-for-ts: ['', '--typescript']
43-
flag-for-jsx: ['', '--jsx']
44-
flag-for-router: ['', '--router']
45-
flag-for-pinia: ['', '--pinia']
46-
flag-for-vitest: ['', '--vitest']
47-
48-
# It's quite costly to install Cypress & Playwright even with cache.
49-
# Maybe we can split them into another job so that all the projects
50-
# can share the same binary installation.
51-
flag-for-e2e: ['', '--cypress', '--playwright']
52-
53-
# Skip ESLint/Prettier tests as we've reached the limit of job numbers
54-
# TODO: Find a way to test them without adding new jobs
55-
93+
e2e-framework: ['cypress', 'playwright']
5694
node-version: [22]
57-
os: [ubuntu-latest]
58-
59-
# Run a few tests on other systems and Node.js versions
60-
include:
61-
- node-version: 22
62-
os: windows-latest
63-
flag-for-ts: '--typescript'
64-
flag-for-jsx: '--jsx'
65-
flag-for-router: '--router'
66-
flag-for-pinia: '--pinia'
67-
flag-for-vitest: '--vitest'
68-
flag-for-e2e: '--cypress'
69-
flag-for-eslint: '--eslint'
70-
71-
- node-version: 22
72-
os: macos-latest
73-
flag-for-ts: '--typescript'
74-
flag-for-jsx: '--jsx'
75-
flag-for-router: '--router'
76-
flag-for-pinia: '--pinia'
77-
flag-for-vitest: '--vitest'
78-
flag-for-e2e: '--cypress'
79-
flag-for-eslint: '--eslint'
80-
81-
- node-version: 18
82-
os: ubuntu-latest
83-
flag-for-ts: '--typescript'
84-
flag-for-jsx: '--jsx'
85-
flag-for-router: '--router'
86-
flag-for-pinia: '--pinia'
87-
flag-for-vitest: '--vitest'
88-
flag-for-e2e: '--cypress'
89-
flag-for-eslint: '--eslint'
90-
91-
- node-version: 20
92-
os: ubuntu-latest
93-
flag-for-ts: '--typescript'
94-
flag-for-jsx: '--jsx'
95-
flag-for-router: '--router'
96-
flag-for-pinia: '--pinia'
97-
flag-for-vitest: '--vitest'
98-
flag-for-e2e: '--cypress'
99-
flag-for-eslint: '--eslint'
95+
os: [ubuntu-latest, windows-latest, macos-latest]
10096
runs-on: ${{ matrix.os }}
10197
continue-on-error: ${{ matrix.os == 'windows-latest' }}
10298
env:
103-
FEATURE_FLAGS: ${{ matrix.flag-for-ts }} ${{ matrix.flag-for-jsx }} ${{ matrix.flag-for-router }} ${{ matrix.flag-for-pinia }} ${{ matrix.flag-for-vitest }} ${{ matrix.flag-for-e2e }} ${{matrix.flag-for-eslint}}
10499
# Sometimes the Linux runner can't verify Cypress in 30s
105100
CYPRESS_VERIFY_TIMEOUT: 60000
106101
steps:
107102
- uses: actions/checkout@v4
108-
- uses: pnpm/action-setup@v3
103+
with:
104+
submodules: true
105+
- uses: pnpm/action-setup@v4
109106
- uses: actions/setup-node@v4
110107
with:
111108
node-version: ${{ matrix.node-version }}
112109
cache: 'pnpm'
113-
- uses: actions/cache/restore@v4
114-
id: cache-restore
110+
111+
# use artifacts to share the playground across different jobs
112+
- uses: actions/download-artifact@v4
115113
with:
116-
path: outfile.cjs
117-
key: ${{ github.sha }}-${{ hashFiles('pnpm-lock.yaml') }}
118-
- name: Build the package on cache miss
119-
if: steps.cache-restore.outputs.cache-hit != 'true'
120-
run: pnpm install && pnpm build
114+
name: build-output
115+
116+
- name: Install dependencies to avoid tsconfig warnings
117+
run: pnpm install
118+
- name: Install dependencies in playground
119+
working-directory: ./playground
120+
run: pnpm install --no-frozen-lockfile
121121

122122
# https://github.com/vitejs/vite/blob/main/.github/workflows/ci.yml#L62
123123
# Install playwright's binary under custom directory to cache
124124
- name: Set Playwright & Cypress path
125-
if: runner.os != 'Windows'
126125
run: |
127126
echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV
128127
echo "CYPRESS_CACHE_FOLDER=$HOME/.cache/cypress-bin" >> $GITHUB_ENV
@@ -132,7 +131,7 @@ jobs:
132131
echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV
133132
echo "CYPRESS_CACHE_FOLDER=$HOME\.cache\cypress-bin" >> $env:GITHUB_ENV
134133
135-
- if: ${{ contains(matrix.flag-for-e2e, '--cypress') }}
134+
- if: ${{ contains(matrix.e2e-framework, 'cypress') }}
136135
name: Cache Cypress binaries
137136
id: cache-cypress
138137
uses: actions/cache@v4
@@ -141,7 +140,7 @@ jobs:
141140
key: ${{ runner.os }}-cypress-bin
142141
path: ${{ env.CYPRESS_CACHE_FOLDER }}
143142

144-
- if: ${{ contains(matrix.flag-for-e2e, '--playwright') }}
143+
- if: ${{ contains(matrix.e2e-framework, 'playwright') }}
145144
name: Cache Playwright's binary
146145
uses: actions/cache@v4
147146
with:
@@ -150,47 +149,28 @@ jobs:
150149
key: ${{ runner.os }}-playwright-bin-v1
151150
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
152151

153-
- if: ${{ (contains(env.FEATURE_FLAGS, '--')) }}
154-
name: Create the sample project with feature flags
155-
working-directory: ../
156-
run: node ./create-vue/outfile.cjs sample-project ${{ env.FEATURE_FLAGS }}
157-
158-
- if: ${{ !(contains(env.FEATURE_FLAGS, '--')) }}
159-
name: Create the sample project with default options
160-
working-directory: ../
161-
run: node ./create-vue/outfile.cjs sample-project --default
162-
163-
- name: Install dependencies in the sample project
164-
working-directory: ../sample-project
165-
run: pnpm install
166-
167-
- if: ${{ contains(matrix.flag-for-vitest, '--') }}
168-
name: Run unit test script
169-
working-directory: ../sample-project
170-
run: pnpm test:unit
171-
172-
- name: Run build script
173-
working-directory: ../sample-project
174-
run: pnpm build
175-
176152
- name: Download Cypress
177-
if: ${{ contains(matrix.flag-for-e2e, '--cypress') }}
178-
working-directory: ../sample-project
153+
if: ${{ contains(matrix.e2e-framework, 'cypress') }}
154+
working-directory: ./playground/cypress
179155
run: |
180156
pnpm exec cypress cache list
181157
pnpm exec cypress install
182158
183-
- if: ${{ contains(matrix.flag-for-e2e, '--playwright') }}
159+
- if: ${{ contains(matrix.e2e-framework, 'playwright') }}
184160
name: Install Playwright dependencies
185-
working-directory: ../sample-project
186-
run: npx playwright install --with-deps
187-
188-
- if: ${{ contains(matrix.flag-for-e2e, '--') }}
189-
name: Run e2e test script
190-
working-directory: ../sample-project
191-
run: pnpm test:e2e
192-
193-
- if: ${{ contains(matrix.flag-for-eslint, '--') }}
194-
name: Run lint script
195-
working-directory: ../sample-project
196-
run: pnpm lint --no-fix --max-warnings=0
161+
working-directory: ./playground/playwright
162+
run: pnpm exec playwright install --with-deps
163+
164+
- name: Run build script
165+
working-directory: ./playground
166+
run: pnpm --filter "*${{ matrix.e2e-framework }}*" build
167+
168+
- name: Run e2e test script
169+
working-directory: ./playground
170+
run: pnpm --filter "*${{ matrix.e2e-framework }}*" --workspace-concurrency 1 test:e2e
171+
172+
- name: Cypress component testing for projects without Vitest
173+
if: ${{ contains(matrix.e2e-framework, 'cypress') }}
174+
run: pnpm --filter '*cypress*' --filter '!*vitest*' --workspace-concurrency 1 test:unit
175+
176+
# FIXME: `--with-tests` folders. It's failing now.

0 commit comments

Comments
 (0)