Skip to content

Commit 6bf166b

Browse files
committed
Shard tests using cargo-nextest
1 parent 490ff3e commit 6bf166b

File tree

1 file changed

+51
-13
lines changed

1 file changed

+51
-13
lines changed

.github/workflows/ci.yaml

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ jobs:
132132
- name: Run `cargo-deny`
133133
uses: EmbarkStudios/[email protected]
134134

135-
135+
136136
check-schema:
137137
name: Check schema
138138
runs-on: ubuntu-latest
@@ -168,15 +168,15 @@ jobs:
168168
run: |
169169
if ! [[ -z $(git status -s) ]]; then
170170
echo "::error title=Workspace is not clean::Please run 'sh ./misc/update.sh' and commit the changes"
171-
171+
172172
(
173173
echo '## Diff after running `sh ./misc/update.sh`:'
174174
echo
175175
echo '```diff'
176176
git diff
177177
echo '```'
178178
) >> $GITHUB_STEP_SUMMARY
179-
179+
180180
exit 1
181181
fi
182182
@@ -216,14 +216,52 @@ jobs:
216216
cargo clippy --workspace --tests --bins --lib -- -D warnings
217217
218218
219+
compile-test-artifacts:
220+
name: Compile test artifacts
221+
runs-on: ubuntu-latest
222+
223+
permissions:
224+
contents: read
225+
226+
steps:
227+
- name: Checkout
228+
uses: actions/checkout@v3
229+
230+
- name: Install toolchain
231+
run: |
232+
rustup toolchain install stable
233+
rustup default stable
234+
235+
- name: Install nextest
236+
uses: taiki-e/install-action@nextest
237+
238+
- name: Setup sccache
239+
uses: mozilla-actions/[email protected]
240+
241+
- name: Build and archive tests
242+
run: cargo nextest archive --archive-file nextest-archive.tar.zst
243+
env:
244+
SQLX_OFFLINE: '1'
245+
246+
- name: Upload archive to workflow
247+
uses: actions/upload-artifact@v4
248+
with:
249+
name: nextest-archive
250+
path: nextest-archive.tar.zst
251+
252+
219253
test:
220254
name: Run test suite with Rust stable
221-
needs: [rustfmt, opa-lint]
255+
needs: [rustfmt, opa-lint, compile-test-artifacts]
222256
runs-on: ubuntu-latest
223257

224258
permissions:
225259
contents: read
226260

261+
strategy:
262+
matrix:
263+
partition: [1, 2]
264+
227265
services:
228266
postgres:
229267
image: docker.io/library/postgres:15.3
@@ -243,10 +281,9 @@ jobs:
243281
- name: Checkout the code
244282
uses: actions/[email protected]
245283

246-
- name: Install toolchain
247-
run: |
248-
rustup toolchain install stable
249-
rustup default stable
284+
- run: mkdir -p ~/.cargo/bin
285+
- name: Install nextest
286+
uses: taiki-e/install-action@nextest
250287

251288
- name: Install Node
252289
uses: actions/[email protected]
@@ -270,16 +307,17 @@ jobs:
270307
working-directory: ./policies
271308
run: make
272309

273-
- name: Setup sccache
274-
uses: mozilla-actions/[email protected]
310+
- name: Download archive
311+
uses: actions/download-artifact@v4
312+
with:
313+
name: nextest-archive
275314

276315
- name: Test
277-
id: test
278316
env:
279317
DATABASE_URL: postgresql://postgres:postgres@localhost/postgres
280-
SQLX_OFFLINE: '1'
281318
run: |
282-
cargo test --workspace
319+
~/.cargo/bin/cargo-nextest nextest run --archive-file nextest-archive.tar.zst \
320+
--partition count:${{ matrix.partition }}/2
283321
284322
syn2mas:
285323
name: Check syn2mas

0 commit comments

Comments
 (0)