Repository navigation
Give each Rust CI job its own cache and save caches only from main #1259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -51,12 +51,22 @@ runs: | |||||||||||||||||||||||
| # `.tool-versions` is the single source of truth for the Viceroy pin. | ||||||||||||||||||||||||
| run: echo "viceroy-version=$(grep '^viceroy ' .tool-versions | awk '{print $2}')" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - name: Remove runner-image Rust toolchain | ||||||||||||||||||||||||
| # rust-cache hashes every installed toolchain into its key, so the image's | ||||||||||||||||||||||||
| # preinstalled stable would rotate the key on each runner-image rollout. | ||||||||||||||||||||||||
| shell: bash | ||||||||||||||||||||||||
| run: if command -v rustup >/dev/null; then rustup toolchain uninstall stable; fi | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - name: Set up Rust toolchain | ||||||||||||||||||||||||
| uses: actions-rust-lang/setup-rust-toolchain@v1 | ||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||
| toolchain: ${{ steps.rust-version.outputs.rust-version }} | ||||||||||||||||||||||||
| target: wasm32-wasip1 | ||||||||||||||||||||||||
| cache-shared-key: cargo-${{ runner.os }} | ||||||||||||||||||||||||
| # Restore the axum job's main cache: it builds the same axum debug and | ||||||||||||||||||||||||
| # Fastly release WASM artifacts. Integration tests run on PRs only, and | ||||||||||||||||||||||||
| # PR caches are scoped to their ref and only evict main's shared caches. | ||||||||||||||||||||||||
| cache-shared-key: cargo-axum-${{ runner.os }} | ||||||||||||||||||||||||
| cache-save-if: ${{ github.ref == 'refs/heads/main' }} | ||||||||||||||||||||||||
|
Comment on lines
+65
to
+69
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔧 wrench: The save gate is open on Integration Tests also runs on All 18 dispatches so far ran on feature branches, so this hasn't happened yet. The action only needs to restore, so a constant closes it:
Suggested change
Checked in a scratch copy: the YAML parses to |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| - name: Cache Viceroy binary | ||||||||||||||||||||||||
| if: ${{ inputs.install-viceroy == 'true' }} | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,12 +33,20 @@ jobs: | |
| run: echo "node-version=$(grep '^nodejs ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT | ||
| shell: bash | ||
|
|
||
| - name: Remove runner-image Rust toolchain | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ♻️ refactor: One shared Rust setup action instead of nine copies This PR adds the same uninstall step and the same # .github/actions/setup-rust/action.yml
name: Set up pinned Rust
description: Install the .tool-versions Rust toolchain with a per-job cache that only main saves.
inputs:
cache-key:
description: Per-job cache key prefix.
required: true
target:
description: Comma-separated extra targets.
default: ""
components:
description: Comma-separated extra components.
default: ""
save-cache:
description: Set to "false" for restore-only callers.
default: "true"
runs:
using: composite
steps:
- id: rust-version
shell: bash
run: echo "rust-version=$(awk '$1 == "rust" { print $2 }' .tool-versions)" >> "$GITHUB_OUTPUT"
- name: Remove runner-image Rust toolchain
# rust-cache hashes every installed toolchain into its key.
shell: bash
run: if command -v rustup >/dev/null; then rustup toolchain uninstall stable; fi
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ steps.rust-version.outputs.rust-version }}
target: ${{ inputs.target }}
components: ${{ inputs.components }}
cache-shared-key: ${{ inputs.cache-key }}-${{ runner.os }}
cache-save-if: ${{ inputs.save-cache == 'true' && github.ref == 'refs/heads/main' }}Each job would then use |
||
| # rust-cache hashes every installed toolchain into its key, so the image's | ||
| # preinstalled stable would rotate the key on each runner-image rollout. | ||
| shell: bash | ||
| run: if command -v rustup >/dev/null; then rustup toolchain uninstall stable; fi | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 thinking: Removing the default toolchain lets rustup reinstall After this step rustup's default still points at Reproduced in if command -v rustup >/dev/null; then rustup toolchain uninstall stable && rustup default none; fiThis would go in all nine copies of the step. |
||
|
|
||
| - name: Set up Rust toolchain | ||
| uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
| with: | ||
| toolchain: ${{ steps.rust-version.outputs.rust-version }} | ||
| target: wasm32-wasip1 | ||
| cache-shared-key: cargo-${{ runner.os }} | ||
| cache-shared-key: cargo-fastly-${{ runner.os }} | ||
| # PR caches are scoped to their ref and only evict main's shared caches. | ||
| cache-save-if: ${{ github.ref == 'refs/heads/main' }} | ||
|
|
||
| - name: Cache Viceroy binary | ||
| id: cache-viceroy | ||
|
|
@@ -82,14 +90,22 @@ jobs: | |
| run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT | ||
| shell: bash | ||
|
|
||
| - name: Remove runner-image Rust toolchain | ||
| # rust-cache hashes every installed toolchain into its key, so the image's | ||
| # preinstalled stable would rotate the key on each runner-image rollout. | ||
| shell: bash | ||
| run: if command -v rustup >/dev/null; then rustup toolchain uninstall stable; fi | ||
|
|
||
| - name: Set up Rust toolchain | ||
| uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
| with: | ||
| toolchain: ${{ steps.rust-version.outputs.rust-version }} | ||
| # wasm32-wasip1 is required by the "Verify Fastly WASM release | ||
| # build" step below; the axum build and tests are native. | ||
| target: wasm32-wasip1 | ||
| cache-shared-key: cargo-${{ runner.os }} | ||
| cache-shared-key: cargo-axum-${{ runner.os }} | ||
| # PR caches are scoped to their ref and only evict main's shared caches. | ||
| cache-save-if: ${{ github.ref == 'refs/heads/main' }} | ||
|
|
||
| - name: Read pinned Node.js version for CLI fixtures | ||
| id: node-version | ||
|
|
@@ -136,12 +152,20 @@ jobs: | |
| run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT | ||
| shell: bash | ||
|
|
||
| - name: Remove runner-image Rust toolchain | ||
| # rust-cache hashes every installed toolchain into its key, so the image's | ||
| # preinstalled stable would rotate the key on each runner-image rollout. | ||
| shell: bash | ||
| run: if command -v rustup >/dev/null; then rustup toolchain uninstall stable; fi | ||
|
|
||
| - name: Set up Rust toolchain (native + wasm32-unknown-unknown) | ||
| uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
| with: | ||
| toolchain: ${{ steps.rust-version.outputs.rust-version }} | ||
| target: wasm32-unknown-unknown | ||
| cache-shared-key: cargo-${{ runner.os }} | ||
| cache-shared-key: cargo-cloudflare-${{ runner.os }} | ||
| # PR caches are scoped to their ref and only evict main's shared caches. | ||
| cache-save-if: ${{ github.ref == 'refs/heads/main' }} | ||
|
|
||
| - name: Check Cloudflare adapter (native host) | ||
| run: cargo check -p trusted-server-adapter-cloudflare | ||
|
|
@@ -163,12 +187,20 @@ jobs: | |
| run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT | ||
| shell: bash | ||
|
|
||
| - name: Remove runner-image Rust toolchain | ||
| # rust-cache hashes every installed toolchain into its key, so the image's | ||
| # preinstalled stable would rotate the key on each runner-image rollout. | ||
| shell: bash | ||
| run: if command -v rustup >/dev/null; then rustup toolchain uninstall stable; fi | ||
|
|
||
| - name: Set up Rust toolchain (native + wasm32-wasip1) | ||
| uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
| with: | ||
| toolchain: ${{ steps.rust-version.outputs.rust-version }} | ||
| target: wasm32-wasip1 | ||
| cache-shared-key: cargo-${{ runner.os }} | ||
| cache-shared-key: cargo-spin-${{ runner.os }} | ||
| # PR caches are scoped to their ref and only evict main's shared caches. | ||
| cache-save-if: ${{ github.ref == 'refs/heads/main' }} | ||
|
|
||
| - name: Check Spin adapter (native host) | ||
| run: cargo check -p trusted-server-adapter-spin | ||
|
|
@@ -202,12 +234,20 @@ jobs: | |
| run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT | ||
| shell: bash | ||
|
|
||
| - name: Remove runner-image Rust toolchain | ||
| # rust-cache hashes every installed toolchain into its key, so the image's | ||
| # preinstalled stable would rotate the key on each runner-image rollout. | ||
| shell: bash | ||
| run: if command -v rustup >/dev/null; then rustup toolchain uninstall stable; fi | ||
|
|
||
| - name: Set up Rust toolchain | ||
| uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
| with: | ||
| toolchain: ${{ steps.rust-version.outputs.rust-version }} | ||
| components: clippy, rustfmt | ||
| cache-shared-key: cargo-${{ runner.os }} | ||
| cache-shared-key: cargo-parity-${{ runner.os }} | ||
| # PR caches are scoped to their ref and only evict main's shared caches. | ||
| cache-save-if: ${{ github.ref == 'refs/heads/main' }} | ||
|
|
||
| - name: Format check (parity test crate) | ||
| run: cargo fmt --manifest-path crates/trusted-server-integration-tests/Cargo.toml -- --check | ||
|
|
@@ -233,12 +273,20 @@ jobs: | |
| run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT | ||
| shell: bash | ||
|
|
||
| - name: Remove runner-image Rust toolchain | ||
| # rust-cache hashes every installed toolchain into its key, so the image's | ||
| # preinstalled stable would rotate the key on each runner-image rollout. | ||
| shell: bash | ||
| run: if command -v rustup >/dev/null; then rustup toolchain uninstall stable; fi | ||
|
|
||
| - name: Set up Rust toolchain | ||
| uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
| with: | ||
| toolchain: ${{ steps.rust-version.outputs.rust-version }} | ||
| components: "clippy, rustfmt" | ||
| cache-shared-key: cargo-cli-${{ runner.os }} | ||
| # PR caches are scoped to their ref and only evict main's shared caches. | ||
| cache-save-if: ${{ github.ref == 'refs/heads/main' }} | ||
|
|
||
| - name: Read pinned Node.js version for CLI fixtures | ||
| id: node-version | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌱 seedling: Most of the integration jobs' Rust compile isn't in
cargo-axumcargo-axumcovers prepare-artifacts' axum debug build (277 crates) and Fastly release WASM build (255). The rest of the workflow's compiles aren't in any main cache. Counts are from this PR's run:integration testsandFastly EC lifecycleruncargo test --manifest-path crates/trusted-server-integration-tests/Cargo.toml --target x86_64-unknown-linux-gnu(376 crates). test-axum never builds that crate. At most 326 of those crate versions appear in test-axum's explicit-target CLI build, and feature differences will cut that further. test-parity compiles the same 376 crates, but without--target, so they land intarget/debuginstead. The explicit--targetdates from Add integration testing with testcontainers and Playwright #442, when.cargo/config.tomlset a global wasm32 build target. Add trusted-server-adapter-axum native dev server (PR 16) #643 removed that setting.generate-integration-viceroy-configs.shbuilds 228 crates intocrates/trusted-server-integration-tests/target, which rust-cache doesn't save.worker-build --release(198 crates) isn't built by any main job. test-cloudflare only runscargo check.Possible follow-up: drop
--targetfrom the twocargo teststeps, give this action a cache-key input, and have those two jobs restorecargo-parity-${{ runner.os }}. None of this is a regression from the shared key, so it can wait.