Skip to content

Commit 899974e

Browse files
authored
ci: reduce rebuilding of test crates (#32211)
1 parent 951455e commit 899974e

File tree

2 files changed

+68
-18
lines changed

2 files changed

+68
-18
lines changed

.github/workflows/ci.generate.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,11 @@ const buildJobs = buildItems.map((rawBuildItem) => {
969969
cachePrefix: "test-main",
970970
});
971971
const testCrateNameExpr = testMatrix.test_crate;
972+
// unit_node runs the fastest, so spend the time building
973+
// the caches on that run
974+
const shouldSaveCache = buildItem.save_cache.and(
975+
testCrateNameExpr.equals("unit_node"),
976+
);
972977
additionalJobs.push(job(
973978
jobIdForJob("test"),
974979
{
@@ -1029,14 +1034,28 @@ const buildJobs = buildItems.map((rawBuildItem) => {
10291034
if: isRelease.and(testCrateNameExpr.equals("specs")),
10301035
run: "cargo build --release -p test_ffi",
10311036
},
1037+
{
1038+
name: "Build caches (debug)",
1039+
if: isDebug.and(shouldSaveCache),
1040+
run: `cargo test --no-run ${
1041+
testCrates.map((c) => `-p ${c.package}`).join(" ")
1042+
}`,
1043+
env: { CARGO_PROFILE_DEV_DEBUG: 0 },
1044+
},
10321045
{
10331046
name: "Test (debug)",
1034-
// run full tests only on Linux
10351047
if: isDebug,
10361048
run:
10371049
`cargo test -p ${testMatrix.test_package} --test ${testMatrix.test_crate}`,
10381050
env: { CARGO_PROFILE_DEV_DEBUG: 0 },
10391051
},
1052+
{
1053+
name: "Build caches (release)",
1054+
if: isRelease.and(shouldSaveCache),
1055+
run: `cargo test --no-run ${
1056+
testCrates.map((c) => `-p ${c.package}`).join(" ")
1057+
} --release`,
1058+
},
10401059
{
10411060
name: "Test (release)",
10421061
if: isRelease.and(
@@ -1069,9 +1088,7 @@ const buildJobs = buildItems.map((rawBuildItem) => {
10691088
path: `target/test_results_${testMatrix.test_crate}.json`,
10701089
},
10711090
}),
1072-
saveCacheStep.if(buildItem.save_cache
1073-
// only bother saving for the integration test job because it builds the most
1074-
.and(testCrateNameExpr.equals("integration"))),
1091+
saveCacheStep.if(shouldSaveCache),
10751092
),
10761093
},
10771094
));

.github/workflows/ci.yml

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,11 @@ jobs:
470470
- name: Build ffi (debug)
471471
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''specs'''
472472
run: cargo build -p test_ffi
473+
- name: Build caches (debug)
474+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'''
475+
env:
476+
CARGO_PROFILE_DEV_DEBUG: 0
477+
run: cargo test --no-run -p integration_tests -p node_compat_tests -p specs_tests -p unit_tests -p unit_node_tests
473478
- name: Test (debug)
474479
if: '!startsWith(github.ref, ''refs/tags/'')'
475480
env:
@@ -486,7 +491,7 @@ jobs:
486491
path: 'target/test_results_${{ matrix.test_crate }}.json'
487492
- name: Cache cargo home
488493
uses: cirruslabs/cache/save@v4
489-
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''integration'' && github.ref == ''refs/heads/main'''
494+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'' && github.ref == ''refs/heads/main'''
490495
with:
491496
path: |-
492497
~/.cargo/.crates.toml
@@ -498,7 +503,7 @@ jobs:
498503
key: '96-cargo-home-macos-x86_64-test-main-${{ github.sha }}'
499504
- name: Cache build output
500505
uses: cirruslabs/cache/save@v4
501-
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''integration'' && github.ref == ''refs/heads/main'''
506+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'' && github.ref == ''refs/heads/main'''
502507
with:
503508
path: |-
504509
./target
@@ -1144,6 +1149,11 @@ jobs:
11441149
- name: Build ffi (debug)
11451150
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''specs'''
11461151
run: cargo build -p test_ffi
1152+
- name: Build caches (debug)
1153+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'''
1154+
env:
1155+
CARGO_PROFILE_DEV_DEBUG: 0
1156+
run: cargo test --no-run -p integration_tests -p node_compat_tests -p specs_tests -p unit_tests -p unit_node_tests
11471157
- name: Test (debug)
11481158
if: '!startsWith(github.ref, ''refs/tags/'')'
11491159
env:
@@ -1160,7 +1170,7 @@ jobs:
11601170
path: 'target/test_results_${{ matrix.test_crate }}.json'
11611171
- name: Cache cargo home
11621172
uses: cirruslabs/cache/save@v4
1163-
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''integration'' && github.ref == ''refs/heads/main'''
1173+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'' && github.ref == ''refs/heads/main'''
11641174
with:
11651175
path: |-
11661176
~/.cargo/.crates.toml
@@ -1172,7 +1182,7 @@ jobs:
11721182
key: '96-cargo-home-macos-aarch64-test-main-${{ github.sha }}'
11731183
- name: Cache build output
11741184
uses: cirruslabs/cache/save@v4
1175-
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''integration'' && github.ref == ''refs/heads/main'''
1185+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'' && github.ref == ''refs/heads/main'''
11761186
with:
11771187
path: |-
11781188
./target
@@ -1915,6 +1925,11 @@ jobs:
19151925
- name: Build ffi (debug)
19161926
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''specs'''
19171927
run: cargo build -p test_ffi
1928+
- name: Build caches (debug)
1929+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'''
1930+
env:
1931+
CARGO_PROFILE_DEV_DEBUG: 0
1932+
run: cargo test --no-run -p integration_tests -p node_compat_tests -p specs_tests -p unit_tests -p unit_node_tests
19181933
- name: Test (debug)
19191934
if: '!startsWith(github.ref, ''refs/tags/'')'
19201935
env:
@@ -1931,7 +1946,7 @@ jobs:
19311946
path: 'target/test_results_${{ matrix.test_crate }}.json'
19321947
- name: Cache cargo home
19331948
uses: cirruslabs/cache/save@v4
1934-
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''integration'' && github.ref == ''refs/heads/main'''
1949+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'' && github.ref == ''refs/heads/main'''
19351950
with:
19361951
path: |-
19371952
~/.cargo/.crates.toml
@@ -1943,7 +1958,7 @@ jobs:
19431958
key: '96-cargo-home-windows-x86_64-test-main-${{ github.sha }}'
19441959
- name: Cache build output
19451960
uses: cirruslabs/cache/save@v4
1946-
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''integration'' && github.ref == ''refs/heads/main'''
1961+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'' && github.ref == ''refs/heads/main'''
19471962
with:
19481963
path: |-
19491964
./target
@@ -2663,6 +2678,11 @@ jobs:
26632678
- name: Build ffi (debug)
26642679
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''specs'''
26652680
run: cargo build -p test_ffi
2681+
- name: Build caches (debug)
2682+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'''
2683+
env:
2684+
CARGO_PROFILE_DEV_DEBUG: 0
2685+
run: cargo test --no-run -p integration_tests -p node_compat_tests -p specs_tests -p unit_tests -p unit_node_tests
26662686
- name: Test (debug)
26672687
if: '!startsWith(github.ref, ''refs/tags/'')'
26682688
env:
@@ -2679,7 +2699,7 @@ jobs:
26792699
path: 'target/test_results_${{ matrix.test_crate }}.json'
26802700
- name: Cache cargo home
26812701
uses: cirruslabs/cache/save@v4
2682-
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''integration'' && github.ref == ''refs/heads/main'''
2702+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'' && github.ref == ''refs/heads/main'''
26832703
with:
26842704
path: |-
26852705
~/.cargo/.crates.toml
@@ -2691,7 +2711,7 @@ jobs:
26912711
key: '96-cargo-home-windows-aarch64-test-main-${{ github.sha }}'
26922712
- name: Cache build output
26932713
uses: cirruslabs/cache/save@v4
2694-
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''integration'' && github.ref == ''refs/heads/main'''
2714+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'' && github.ref == ''refs/heads/main'''
26952715
with:
26962716
path: |-
26972717
./target
@@ -3590,6 +3610,9 @@ jobs:
35903610
- name: Build ffi (release)
35913611
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''specs'''
35923612
run: cargo build --release -p test_ffi
3613+
- name: Build caches (release)
3614+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'''
3615+
run: cargo test --no-run -p integration_tests -p node_compat_tests -p specs_tests -p unit_tests -p unit_node_tests --release
35933616
- name: Test (release)
35943617
if: '!startsWith(github.ref, ''refs/tags/'')'
35953618
run: 'cargo test -p ${{ matrix.test_package }} --test ${{ matrix.test_crate }} --release'
@@ -3604,7 +3627,7 @@ jobs:
36043627
path: 'target/test_results_${{ matrix.test_crate }}.json'
36053628
- name: Cache cargo home
36063629
uses: cirruslabs/cache/save@v4
3607-
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''integration'' && github.ref == ''refs/heads/main'''
3630+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'' && github.ref == ''refs/heads/main'''
36083631
with:
36093632
path: |-
36103633
~/.cargo/.crates.toml
@@ -3616,7 +3639,7 @@ jobs:
36163639
key: '96-cargo-home-linux-x86_64-test-main-${{ github.sha }}'
36173640
- name: Cache build output
36183641
uses: cirruslabs/cache/save@v4
3619-
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''integration'' && github.ref == ''refs/heads/main'''
3642+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'' && github.ref == ''refs/heads/main'''
36203643
with:
36213644
path: |-
36223645
./target
@@ -4130,6 +4153,11 @@ jobs:
41304153
- name: Build ffi (debug)
41314154
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''specs'''
41324155
run: cargo build -p test_ffi
4156+
- name: Build caches (debug)
4157+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'''
4158+
env:
4159+
CARGO_PROFILE_DEV_DEBUG: 0
4160+
run: cargo test --no-run -p integration_tests -p node_compat_tests -p specs_tests -p unit_tests -p unit_node_tests
41334161
- name: Test (debug)
41344162
if: '!startsWith(github.ref, ''refs/tags/'')'
41354163
env:
@@ -4146,7 +4174,7 @@ jobs:
41464174
path: 'target/test_results_${{ matrix.test_crate }}.json'
41474175
- name: Cache cargo home
41484176
uses: cirruslabs/cache/save@v4
4149-
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''integration'' && github.ref == ''refs/heads/main'''
4177+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'' && github.ref == ''refs/heads/main'''
41504178
with:
41514179
path: |-
41524180
~/.cargo/.crates.toml
@@ -4158,7 +4186,7 @@ jobs:
41584186
key: '96-cargo-home-linux-x86_64-test-main-${{ github.sha }}'
41594187
- name: Cache build output
41604188
uses: cirruslabs/cache/save@v4
4161-
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''integration'' && github.ref == ''refs/heads/main'''
4189+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'' && github.ref == ''refs/heads/main'''
41624190
with:
41634191
path: |-
41644192
./target
@@ -4506,6 +4534,11 @@ jobs:
45064534
- name: Build ffi (debug)
45074535
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''specs'''
45084536
run: cargo build -p test_ffi
4537+
- name: Build caches (debug)
4538+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'''
4539+
env:
4540+
CARGO_PROFILE_DEV_DEBUG: 0
4541+
run: cargo test --no-run -p integration_tests -p node_compat_tests -p specs_tests -p unit_tests -p unit_node_tests
45094542
- name: Test (debug)
45104543
if: '!startsWith(github.ref, ''refs/tags/'')'
45114544
env:
@@ -4522,7 +4555,7 @@ jobs:
45224555
path: 'target/test_results_${{ matrix.test_crate }}.json'
45234556
- name: Cache cargo home
45244557
uses: cirruslabs/cache/save@v4
4525-
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''integration'' && github.ref == ''refs/heads/main'''
4558+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'' && github.ref == ''refs/heads/main'''
45264559
with:
45274560
path: |-
45284561
~/.cargo/.crates.toml
@@ -4534,7 +4567,7 @@ jobs:
45344567
key: '96-cargo-home-linux-aarch64-test-main-${{ github.sha }}'
45354568
- name: Cache build output
45364569
uses: cirruslabs/cache/save@v4
4537-
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''integration'' && github.ref == ''refs/heads/main'''
4570+
if: '!startsWith(github.ref, ''refs/tags/'') && matrix.test_crate == ''unit_node'' && github.ref == ''refs/heads/main'''
45384571
with:
45394572
path: |-
45404573
./target

0 commit comments

Comments
 (0)