Skip to content

Commit c3d8829

Browse files
feat: Highly unlikely to work attempt to speed up integration tests
1 parent a0f8972 commit c3d8829

File tree

1 file changed

+109
-35
lines changed

1 file changed

+109
-35
lines changed

.github/workflows/ci.yml

+109-35
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,47 @@ jobs:
4343
- run: pnpm run lint
4444
- run: cd packages/kit && pnpm prepublishOnly && { [ "`git status --porcelain=v1`" == "" ] || (echo "Generated types have changed — please run prepublishOnly locally and commit the changes after you have reviewed them"; git diff; exit 1); }
4545
- run: pnpm run check
46+
list-kit-test-packages:
47+
runs-on: ubuntu-latest
48+
outputs:
49+
package_shards: ${{ steps.set-package-groups.outputs.package_shards }}
50+
steps:
51+
- uses: actions/checkout@v4
52+
- uses: pnpm/action-setup@v2
53+
- name: List and group test packages
54+
id: set-package-groups
55+
run: |
56+
package_shards=$(
57+
pnpm -r --filter="./packages/kit/test/**" exec sh -c '
58+
if [ "$(pnpm pkg get scripts.test 2>/dev/null)" != "{}" ]; then
59+
pnpm pkg get name | sed -e "s/^\"//; s/\"$//"
60+
fi
61+
' | sort | uniq | jq -Rsc '
62+
split("\n") | map(select(. != "")) | . as $list |
63+
[range(0; length; 4) |
64+
{
65+
name: ("Shard " + (. / 4 | tostring)),
66+
filters: ($list[.:(.+4)] | map("--filter=" + .) | join(" ")),
67+
packages: $list[.:(.+4)]
68+
}
69+
]
70+
'
71+
)
72+
echo "package_shards=$package_shards" >> $GITHUB_OUTPUT
73+
echo "Generated package shards:"
74+
echo "$package_shards" | jq .
4675
test-kit:
76+
needs: list-kit-test-packages
77+
name: test-kit (node ${{ matrix.node-version }}, ${{ matrix.e2e-browser }}, ${{ matrix.package_shards.name }})
4778
runs-on: ${{ matrix.os }}
4879
timeout-minutes: 30
4980
strategy:
5081
fail-fast: false
5182
matrix:
83+
package_shards: ${{ fromJson(needs.list-kit-test-packages.outputs.package_shards) }}
84+
node-version: [18, 20, 22]
5285
include:
53-
- node-version: 18
54-
os: ubuntu-latest
55-
e2e-browser: 'chromium'
56-
- node-version: 20
57-
os: ubuntu-latest
58-
e2e-browser: 'chromium'
59-
- node-version: 22
60-
os: ubuntu-latest
86+
- os: ubuntu-latest
6187
e2e-browser: 'chromium'
6288
env:
6389
KIT_E2E_BROWSER: ${{matrix.e2e-browser}}
@@ -69,10 +95,14 @@ jobs:
6995
with:
7096
node-version: ${{ matrix.node-version }}
7197
cache: pnpm
72-
- run: pnpm install --frozen-lockfile
73-
- run: pnpm playwright install ${{ matrix.e2e-browser }}
74-
- run: pnpm run sync-all
75-
- run: pnpm test:kit
98+
- name: Install dependencies
99+
run: pnpm install --frozen-lockfile
100+
- name: Install Playwright
101+
run: pnpm playwright install ${{ matrix.e2e-browser }}
102+
- name: Run tests
103+
run: |
104+
pnpm run sync-all
105+
pnpm ${{ matrix.package_shards.filters }} test
76106
- name: Print flaky test report
77107
run: node scripts/print-flaky-test-report.js
78108
- name: Archive test results
@@ -84,39 +114,69 @@ jobs:
84114
uses: actions/upload-artifact@v4
85115
with:
86116
retention-days: 3
87-
name: test-failure-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.e2e-browser }}
117+
name: test-failure-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.e2e-browser }}-${{ matrix.package_shards.name }}
88118
path: test-results.tar.gz
119+
test-kit-results:
120+
if: always()
121+
needs: test-kit
122+
runs-on: ubuntu-latest
123+
steps:
124+
- name: Check test results
125+
run: |
126+
if [ "${{ needs.test-kit.result }}" = "success" ]; then
127+
echo "All tests passed successfully!"
128+
exit 0
129+
else
130+
echo "Some tests failed. Please check the individual job results."
131+
exit 1
132+
fi
133+
list-kit-test-cross-browser-packages:
134+
runs-on: ubuntu-latest
135+
outputs:
136+
packages: ${{ steps.set-packages.outputs.packages }}
137+
steps:
138+
- uses: actions/checkout@v4
139+
- uses: pnpm/action-setup@v2
140+
- name: List test packages
141+
id: set-packages
142+
run: |
143+
packages=$(
144+
pnpm -r --filter="./packages/kit/test/**" exec sh -c '
145+
if [ "$(pnpm pkg get scripts.test:cross-platform:build 2>/dev/null)" != "{}" ]; then
146+
echo "build:$(pnpm pkg get name | sed -e "s/^\"//; s/\"$//")"
147+
fi
148+
if [ "$(pnpm pkg get scripts.test:cross-platform:dev 2>/dev/null)" != "{}" ]; then
149+
echo "dev:$(pnpm pkg get name | sed -e "s/^\"//; s/\"$//")"
150+
fi
151+
' | sort | uniq | jq -Rsc '
152+
. | split("\n") | map(select(. != "")) | map(split(":") | {mode: .[0], package: .[1]})
153+
'
154+
)
155+
echo "packages=$packages" >> $GITHUB_OUTPUT
156+
echo "Generated packages:"
157+
echo "$packages" | jq .
89158
test-kit-cross-browser:
159+
needs: list-kit-test-cross-browser-packages
90160
runs-on: ${{ matrix.os }}
91161
timeout-minutes: 30
92162
strategy:
93163
fail-fast: false
94164
matrix:
165+
node-version: [20]
166+
package-details: ${{fromJson(needs.list-kit-test-cross-browser-packages.outputs.packages)}}
95167
include:
96-
- node-version: 18
97-
os: windows-2019 # slowness reported on newer versions https://github.com/actions/runner-images/issues/5166
168+
- os: windows-2019 # slowness reported on newer versions https://github.com/actions/runner-images/issues/5166
98169
e2e-browser: 'chromium'
99-
mode: 'dev'
100-
- node-version: 18
101-
os: ubuntu-latest
170+
- os: ubuntu-latest
102171
e2e-browser: 'firefox'
103-
mode: 'dev'
104-
- node-version: 18
105-
os: macOS-latest
172+
- os: macOS-latest
106173
e2e-browser: 'webkit'
107-
mode: 'dev'
108-
- node-version: 18
109-
os: windows-2019 # slowness reported on newer versions https://github.com/actions/runner-images/issues/5166
174+
- os: windows-2019 # slowness reported on newer versions https://github.com/actions/runner-images/issues/5166
110175
e2e-browser: 'chromium'
111-
mode: 'build'
112-
- node-version: 18
113-
os: ubuntu-latest
176+
- os: ubuntu-latest
114177
e2e-browser: 'firefox'
115-
mode: 'build'
116-
- node-version: 18
117-
os: macOS-latest
178+
- os: macOS-latest
118179
e2e-browser: 'webkit'
119-
mode: 'build'
120180
env:
121181
KIT_E2E_BROWSER: ${{matrix.e2e-browser}}
122182
steps:
@@ -130,20 +190,34 @@ jobs:
130190
- run: pnpm install --frozen-lockfile
131191
- run: pnpm playwright install ${{ matrix.e2e-browser }}
132192
- run: pnpm run sync-all
133-
- run: pnpm test:cross-platform:${{ matrix.mode }}
193+
- run: pnpm --filter="${{ matrix.package-details.package }}" test:cross-platform:${{ matrix.package-details.mode }}
134194
- name: Print flaky test report
135195
run: node scripts/print-flaky-test-report.js
136196
- name: Archive test results
137197
if: failure()
138198
shell: bash
139-
run: find packages -type d -name test-results -not -empty | tar -czf test-results-cross-platform-${{ matrix.mode }}.tar.gz --files-from=-
199+
run: find packages -type d -name test-results -not -empty | tar -czf test-results-cross-platform-${{ matrix.package-details.mode }}.tar.gz --files-from=-
140200
- name: Upload test results
141201
if: failure()
142202
uses: actions/upload-artifact@v4
143203
with:
144204
retention-days: 3
145-
name: test-failure-cross-platform-${{ matrix.mode }}-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.e2e-browser }}
146-
path: test-results-cross-platform-${{ matrix.mode }}.tar.gz
205+
name: test-failure-cross-platform-${{ matrix.package-details.mode }}-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.e2e-browser }}
206+
path: test-results-cross-platform-${{ matrix.package-details.mode }}.tar.gz
207+
test-kit-cross-browser-results:
208+
if: always()
209+
needs: test-kit-cross-browser
210+
runs-on: ubuntu-latest
211+
steps:
212+
- name: Check test results
213+
run: |
214+
if [ "${{ needs.test-kit-cross-browser.result }}" = "success" ]; then
215+
echo "All tests passed successfully!"
216+
exit 0
217+
else
218+
echo "Some tests failed. Please check the individual job results."
219+
exit 1
220+
fi
147221
test-others:
148222
runs-on: ubuntu-latest
149223
steps:

0 commit comments

Comments
 (0)