Skip to content

Commit 3131362

Browse files
authored
feat: add github shared caching (#2308)
# What does this PR do? Add shared caching # Motivation Have shared caching # Additional Notes The caching is done from main, so on the branch we won't see a real difference, that's expected # How to test the change? Dashboard Co-authored-by: jules.wiriath <jules.wiriath@datadoghq.com>
1 parent d506837 commit 3131362

12 files changed

Lines changed: 75 additions & 4 deletions

.github/workflows/check-crypto-providers.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ jobs:
2121
- name: Install ${{ steps.rust-version.outputs.version }} toolchain
2222
run: rustup set profile minimal && rustup install ${{ steps.rust-version.outputs.version }} && rustup default ${{ steps.rust-version.outputs.version }}
2323
- name: Cache [rust]
24+
id: rust-cache
2425
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1
2526
with:
2627
cache-targets: true # cache build artifacts
2728
cache-bin: true # cache the ~/.cargo/bin directory
29+
shared-key: default
30+
save-if: ${{ github.ref == 'refs/heads/main' }}
31+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
2832
- name: Run crypto provider check
2933
run: ./scripts/check_crypto_providers.sh

.github/workflows/coverage.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ jobs:
4545
with:
4646
tool: cargo-llvm-cov@0.6.13,nextest@0.9.96
4747
- name: Cache [rust]
48+
id: rust-cache
4849
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1
4950
with:
5051
cache-targets: true # cache build artifacts
5152
cache-bin: true # cache the ~/.cargo/bin directory
53+
shared-key: coverage
54+
save-if: ${{ github.ref == 'refs/heads/main' }}
55+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
5256
- name: Generate code coverage (including doc tests)
5357
env:
5458
# Override rust-toolchain.toml so cargo-llvm-cov runs on the dated

.github/workflows/fuzz.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,14 @@ jobs:
6262
with:
6363
tool: cargo-bolero
6464
- name: Cache [rust]
65+
id: rust-cache
6566
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1
6667
with:
6768
cache-targets: true # cache build artifacts
6869
cache-bin: true # cache the ~/.cargo/bin directory
70+
shared-key: fuzz
71+
save-if: ${{ github.ref == 'refs/heads/main' }}
72+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
6973
- env:
7074
# Override rust-toolchain.toml so cargo-bolero runs on the dated nightly.
7175
RUSTUP_TOOLCHAIN: ${{ steps.nightly-version.outputs.version }}

.github/workflows/lint.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,14 @@ jobs:
112112
rustup install ${{ needs.setup.outputs.nightly-version }}
113113
rustup component add rustfmt --toolchain ${{ needs.setup.outputs.nightly-version }}
114114
- name: Cache [rust]
115+
id: rust-cache
115116
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1
116117
with:
117118
cache-targets: true # cache build artifacts
118119
cache-bin: true # cache the ~/.cargo/bin directory
120+
shared-key: lint
121+
save-if: ${{ github.ref == 'refs/heads/main' }}
122+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
119123
- name: Run rustfmt
120124
env:
121125
FMT_PACKAGES: ${{ needs.setup.outputs.fmt-packages }}
@@ -159,10 +163,14 @@ jobs:
159163
rustup component add clippy --toolchain "$VERSION"
160164
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
161165
- name: Cache [rust]
166+
id: rust-cache
162167
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1
163168
with:
164169
cache-targets: true # cache build artifacts
165170
cache-bin: true # cache the ~/.cargo/bin directory
171+
shared-key: clippy-${{ matrix.rust_version }}
172+
save-if: ${{ github.ref == 'refs/heads/main' }}
173+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
166174
- name: Run clippy on ${{ matrix.platform }} ${{ matrix.rust_version }}
167175
shell: bash
168176
env:

.github/workflows/miri.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,14 @@ jobs:
8181
with:
8282
tool: nextest@0.9.96
8383
- name: Cache [rust]
84+
id: rust-cache
8485
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1
8586
with:
8687
cache-targets: true # cache build artifacts
8788
cache-bin: true # cache the ~/.cargo/bin directory
89+
shared-key: miri
90+
save-if: ${{ github.ref == 'refs/heads/main' }}
91+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
8892
- env:
8993
# Override rust-toolchain.toml so miri runs on the dated nightly
9094
# (miri is nightly-only) instead of the workspace MSRV.

.github/workflows/pr-metadata-docs-and-deps.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,14 @@ jobs:
104104
pull-requests: write
105105
steps:
106106
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
107-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
107+
- name: Cache [rust]
108+
id: rust-cache
109+
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
108110
with:
109111
cache-targets: true
112+
shared-key: default
113+
save-if: ${{ github.ref == 'refs/heads/main' }}
114+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
110115
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c #stable
111116
- name: Check missing docs
112117
id: missing-docs
@@ -275,10 +280,15 @@ jobs:
275280
pull-requests: write
276281
steps:
277282
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
278-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
283+
- name: Cache [rust]
284+
id: rust-cache
285+
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
279286
with:
280287
cache-targets: true
281-
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c #stabled
288+
shared-key: default
289+
save-if: ${{ github.ref == 'refs/heads/main' }}
290+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
291+
- uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c #stable
282292
- uses: taiki-e/cache-cargo-install-action@7447f04c51f2ba27ca35e7f1e28fab848c5b3ba7 # 2.3.1
283293
with:
284294
tool: cargo-deny

.github/workflows/pr-title-semver-check.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,13 @@ jobs:
101101
ln -sf ~/.rustup/toolchains/${{ steps.nightly-version.outputs.version }}-x86_64-unknown-linux-gnu ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu
102102
103103
- name: Cache [rust]
104+
id: rust-cache
104105
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1
105106
with:
106107
cache-targets: true
108+
shared-key: default
109+
save-if: ${{ github.ref == 'refs/heads/main' }}
110+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
107111

108112
- name: Install dependencies
109113
run: |

.github/workflows/release-proposal-dispatch.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,14 @@ jobs:
215215
- name: Read nightly version from nightly-toolchain.toml
216216
id: nightly-version
217217
run: echo "version=$(grep -Po '^channel = "\K[^"]+' nightly-toolchain.toml)" >> $GITHUB_OUTPUT
218-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
218+
- name: Cache [rust]
219+
id: rust-cache
220+
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
219221
with:
220222
cache-targets: true
223+
shared-key: default
224+
save-if: ${{ github.ref == 'refs/heads/main' }}
225+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
221226
- uses: dtolnay/rust-toolchain@7c8d7d138f5c09cef361f8214cf96882cd029cdb #nightly
222227
with:
223228
toolchain: ${{ steps.nightly-version.outputs.version }}

.github/workflows/test-ffi.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,16 @@ jobs:
108108
cache: false
109109

110110
- name: Cache [rust]
111+
id: rust-cache
111112
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1
112113
env:
113114
RUSTFLAGS: "${{ matrix.flags }}"
114115
with:
115116
cache-targets: true # cache build artifacts
116117
cache-bin: true # cache the ~/.cargo/bin directory
118+
shared-key: release
119+
save-if: ${{ github.ref == 'refs/heads/main' }}
120+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
117121
- name: "Generate profiling FFI"
118122
shell: bash
119123
env:

.github/workflows/test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,14 @@ jobs:
120120
go-version: 'stable'
121121
cache: false
122122
- name: Cache [rust]
123+
id: rust-cache
123124
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1
124125
with:
125126
cache-targets: true # cache build artifacts
126127
cache-bin: true # cache the ~/.cargo/bin directory
128+
shared-key: all-features
129+
save-if: ${{ github.ref == 'refs/heads/main' }}
130+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
127131
- name: "Remove nextest CI report"
128132
shell: bash
129133
run: rm -rf target/nextest/ci/junit.xml
@@ -310,10 +314,14 @@ jobs:
310314
with:
311315
submodules: recursive
312316
- name: Cache [rust]
317+
id: rust-cache
313318
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1
314319
with:
315320
cache-targets: true # cache build artifacts
316321
cache-bin: true # cache the ~/.cargo/bin directory
322+
shared-key: centos7
323+
save-if: ${{ github.ref == 'refs/heads/main' }}
324+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
317325
- name: Build CentOS 7 Docker image
318326
run: docker build -t libdatadog-centos7 -f tools/docker/Dockerfile.centos .
319327
- name: "cargo nextest run (centos7)"
@@ -402,10 +410,14 @@ jobs:
402410
with:
403411
submodules: recursive
404412
- name: Cache [rust]
413+
id: rust-cache
405414
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1
406415
with:
407416
cache-targets: true
408417
cache-bin: true
418+
shared-key: default
419+
save-if: ${{ github.ref == 'refs/heads/main' }}
420+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
409421
- name: Set up Docker Buildx
410422
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # 3.10.0
411423
- name: Pre-fetch dependencies (requires network/certs on the runner)
@@ -451,10 +463,14 @@ jobs:
451463
- name: Install wasm32 target
452464
run: rustup target add wasm32-unknown-unknown
453465
- name: Cache [rust]
466+
id: rust-cache
454467
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1
455468
with:
456469
cache-targets: true
457470
cache-bin: true
471+
shared-key: wasm
472+
save-if: ${{ github.ref == 'refs/heads/main' }}
473+
- run: echo "rust-cache ${{ steps.rust-cache.outputs.cache-hit == 'true' && 'HIT' || 'MISS' }}"
458474
- name: Install wasm-bindgen test runner
459475
run: cargo install wasm-bindgen-cli --version 0.2.100 --locked
460476
- name: "cargo check -p libdd-data-pipeline --target wasm32-unknown-unknown --no-default-features"

0 commit comments

Comments
 (0)