Skip to content

Commit 6013acb

Browse files
committed
improve caching
1 parent 2e3e253 commit 6013acb

File tree

4 files changed

+85
-28
lines changed

4 files changed

+85
-28
lines changed

.github/scripts/ci_config.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,7 @@ def run_group_tests(args):
160160

161161
github_group_start(f"Testing {crate}")
162162

163-
# On Windows, skip --all-features to avoid x11 feature
164-
if args.os == "windows-latest":
165-
cmd = ["cargo", "test", "-p", crate]
166-
else:
167-
cmd = ["cargo", "test", "-p", crate, "--all-features"]
168-
163+
cmd = ["cargo", "test", "-p", crate, "--all-features"]
169164
result = subprocess.run(cmd)
170165

171166
github_group_end()
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build and Test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
required: true
8+
type: string
9+
exclude-crates:
10+
required: false
11+
type: string
12+
default: ""
13+
14+
jobs:
15+
build:
16+
name: "build (${{ inputs.os }})"
17+
runs-on: ${{ inputs.os }}
18+
steps:
19+
- uses: actions/checkout@v6
20+
- uses: dtolnay/rust-toolchain@stable
21+
- uses: Swatinem/rust-cache@v2
22+
with:
23+
shared-key: "rust-cache-${{ inputs.os }}"
24+
cache-on-failure: true
25+
- name: Build workspace
26+
run: cargo build --workspace --all-targets --all-features ${{ inputs.exclude-crates && format('--exclude {0}', inputs.exclude-crates) || '' }}
27+
28+
test:
29+
name: "test: ${{ matrix.group }} (${{ inputs.os }})"
30+
needs: build
31+
runs-on: ${{ inputs.os }}
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
group: [core, spv, wallet, rpc, tools]
36+
steps:
37+
- uses: actions/checkout@v6
38+
- uses: dtolnay/rust-toolchain@stable
39+
- uses: Swatinem/rust-cache@v2
40+
with:
41+
shared-key: "rust-cache-${{ inputs.os }}"
42+
save-if: false
43+
- uses: actions/setup-python@v5
44+
with:
45+
python-version: "3.12"
46+
cache: "pip"
47+
cache-dependency-path: .github/scripts/requirements.txt
48+
- run: pip install -r .github/scripts/requirements.txt
49+
- name: Run tests
50+
run: python .github/scripts/ci_config.py run-group ${{ matrix.group }} --os ${{ inputs.os }}

.github/workflows/rust.yml

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ jobs:
4040
- uses: actions/checkout@v6
4141
- uses: dtolnay/rust-toolchain@stable
4242
- uses: Swatinem/rust-cache@v2
43+
with:
44+
shared-key: "rust-cache-docs"
4345
- name: Build documentation
4446
env:
4547
RUSTDOCFLAGS: -D warnings
@@ -59,29 +61,31 @@ jobs:
5961
- name: Check all crates are assigned to test groups
6062
run: python .github/scripts/ci_config.py verify-groups
6163

62-
test:
63-
name: "test: ${{ matrix.group }} (${{ matrix.os }})"
64+
# Per-OS build and test (reusable workflow handles build -> test dependency)
65+
ubuntu:
6466
needs: verify-execution
65-
runs-on: ${{ matrix.os }}
66-
strategy:
67-
fail-fast: false
68-
matrix:
69-
os: [ubuntu-latest, ubuntu-22.04-arm, macos-latest, windows-latest]
70-
group: [core, spv, wallet, rpc, tools]
71-
steps:
72-
- uses: actions/checkout@v6
73-
- uses: dtolnay/rust-toolchain@stable
74-
- uses: Swatinem/rust-cache@v2
75-
with:
76-
shared-key: "rust-cache-${{ matrix.os }}-${{ matrix.group }}"
77-
- uses: actions/setup-python@v5
78-
with:
79-
python-version: "3.12"
80-
cache: "pip"
81-
cache-dependency-path: .github/scripts/requirements.txt
82-
- run: pip install -r .github/scripts/requirements.txt
83-
- name: Run tests
84-
run: python .github/scripts/ci_config.py run-group ${{ matrix.group }} --os ${{ matrix.os }}
67+
uses: ./.github/workflows/build-and-test.yml
68+
with:
69+
os: ubuntu-latest
70+
71+
ubuntu-arm:
72+
needs: verify-execution
73+
uses: ./.github/workflows/build-and-test.yml
74+
with:
75+
os: ubuntu-22.04-arm
76+
77+
macos:
78+
needs: verify-execution
79+
uses: ./.github/workflows/build-and-test.yml
80+
with:
81+
os: macos-latest
82+
83+
windows:
84+
needs: verify-execution
85+
uses: ./.github/workflows/build-and-test.yml
86+
with:
87+
os: windows-latest
88+
exclude-crates: dash-fuzz
8589

8690
no-std:
8791
name: No-std Checks
@@ -90,6 +94,8 @@ jobs:
9094
- uses: actions/checkout@v6
9195
- uses: dtolnay/rust-toolchain@stable
9296
- uses: Swatinem/rust-cache@v2
97+
with:
98+
shared-key: "rust-cache-no-std"
9399
- uses: actions/setup-python@v5
94100
with:
95101
python-version: "3.12"

.github/workflows/sanitizer.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434
with:
3535
components: rust-src
3636
- uses: Swatinem/rust-cache@v2
37+
with:
38+
shared-key: "rust-cache-asan"
39+
cache-on-failure: true
3740

3841
- name: Run tests with ASAN
3942
env:
@@ -59,6 +62,9 @@ jobs:
5962
with:
6063
components: rust-src
6164
- uses: Swatinem/rust-cache@v2
65+
with:
66+
shared-key: "rust-cache-tsan"
67+
cache-on-failure: true
6268

6369
- name: Run tests with TSAN
6470
env:

0 commit comments

Comments
 (0)