Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions .github/actions/setup-integration-test-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ outputs:
runs:
using: composite
steps:
- name: Retrieve Rust version
id: rust-version
shell: bash
run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> "$GITHUB_OUTPUT"

- name: Retrieve Node.js version
id: node-version
shell: bash
Expand All @@ -52,11 +47,15 @@ runs:
run: echo "viceroy-version=$(grep '^viceroy ' .tool-versions | awk '{print $2}')" >> "$GITHUB_OUTPUT"

- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
uses: ./.github/actions/setup-rust
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. Restore only: test-axum owns this key,
# and rust-cache never replaces an exact-match key, so a partial cache
# saved by a workflow_dispatch run on main would stick.
cache-key: cargo-axum
save-cache: "false"

- name: Cache Viceroy binary
if: ${{ inputs.install-viceroy == 'true' }}
Expand Down
45 changes: 45 additions & 0 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Set up pinned Rust
Comment thread
dhruv8sh marked this conversation as resolved.
description: Install the .tool-versions Rust toolchain with a per-job cache that only main saves.

inputs:
cache-key:
description: Per-job rust-cache key prefix; the runner OS is appended.
required: true
target:
description: Comma-separated extra targets.
required: false
default: ""
components:
description: Comma-separated extra components.
required: false
default: ""
save-cache:
description: Set to "false" for restore-only callers.
required: false
default: "true"

runs:
using: composite
steps:
- name: Retrieve Rust version
id: rust-version
shell: bash
run: echo "rust-version=$(grep '^rust ' .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.
# Unsetting the default stops rustup from silently reinstalling stable
# when cargo runs outside the checkout.
shell: bash
run: if command -v rustup >/dev/null; then rustup toolchain uninstall stable && rustup default none; fi

- name: Set up Rust toolchain
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 }}
# PR caches are scoped to their ref and only evict main's shared caches.
cache-save-if: ${{ inputs.save-cache == 'true' && github.ref == 'refs/heads/main' }}
18 changes: 12 additions & 6 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,24 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Retrieve Rust version
id: rust-version
run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
# Rust jobs must set up the toolchain through ./.github/actions/setup-rust,
# which removes the image's stable and only saves caches from main. A
# direct setup-rust-toolchain or rust-cache step skips both silently.
- name: Require the shared Rust setup action
shell: bash
run: |
if grep -rnE "uses:[[:space:]]*[\"']?(actions-rust-lang/setup-rust-toolchain|Swatinem/rust-cache)@" .github \
| grep -v '^\.github/actions/setup-rust/action\.yml:'; then
echo "::error::Set up Rust with ./.github/actions/setup-rust, not setup-rust-toolchain or rust-cache directly."
exit 1
fi

- name: Set up rust toolchain
Comment thread
dhruv8sh marked this conversation as resolved.
uses: actions-rust-lang/setup-rust-toolchain@v1
uses: ./.github/actions/setup-rust
with:
toolchain: ${{ steps.rust-version.outputs.rust-version }}
target: wasm32-wasip1,wasm32-unknown-unknown
components: "clippy, rustfmt"
cache-shared-key: cargo-${{ runner.os }}
cache-key: cargo-clippy

- name: Run cargo fmt
uses: actions-rust-lang/rustfmt@v1
Expand Down
60 changes: 12 additions & 48 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Retrieve Rust version
id: rust-version
run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
shell: bash

- name: Retrieve Viceroy version
id: viceroy-version
# `.tool-versions` is the single source of truth so this workflow and
Expand All @@ -34,11 +29,10 @@ jobs:
shell: bash

- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
uses: ./.github/actions/setup-rust
with:
toolchain: ${{ steps.rust-version.outputs.rust-version }}
target: wasm32-wasip1
cache-shared-key: cargo-${{ runner.os }}
cache-key: cargo-fastly

- name: Cache Viceroy binary
id: cache-viceroy
Expand Down Expand Up @@ -77,19 +71,13 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Retrieve Rust version
id: rust-version
run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
shell: bash

- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
uses: ./.github/actions/setup-rust
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-key: cargo-axum

- name: Read pinned Node.js version for CLI fixtures
id: node-version
Expand Down Expand Up @@ -131,17 +119,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Retrieve Rust version
id: rust-version
run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
shell: bash

- name: Set up Rust toolchain (native + wasm32-unknown-unknown)
uses: actions-rust-lang/setup-rust-toolchain@v1
uses: ./.github/actions/setup-rust
with:
toolchain: ${{ steps.rust-version.outputs.rust-version }}
target: wasm32-unknown-unknown
cache-shared-key: cargo-${{ runner.os }}
cache-key: cargo-cloudflare

- name: Check Cloudflare adapter (native host)
run: cargo check -p trusted-server-adapter-cloudflare
Expand All @@ -158,17 +140,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Retrieve Rust version
id: rust-version
run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
shell: bash

- name: Set up Rust toolchain (native + wasm32-wasip1)
uses: actions-rust-lang/setup-rust-toolchain@v1
uses: ./.github/actions/setup-rust
with:
toolchain: ${{ steps.rust-version.outputs.rust-version }}
target: wasm32-wasip1
cache-shared-key: cargo-${{ runner.os }}
cache-key: cargo-spin

- name: Check Spin adapter (native host)
run: cargo check -p trusted-server-adapter-spin
Expand Down Expand Up @@ -197,17 +173,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Retrieve Rust version
id: rust-version
run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
shell: bash

- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
uses: ./.github/actions/setup-rust
with:
toolchain: ${{ steps.rust-version.outputs.rust-version }}
components: clippy, rustfmt
cache-shared-key: cargo-${{ runner.os }}
cache-key: cargo-parity

- name: Format check (parity test crate)
run: cargo fmt --manifest-path crates/trusted-server-integration-tests/Cargo.toml -- --check
Expand All @@ -228,17 +198,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Retrieve Rust version
id: rust-version
run: echo "rust-version=$(grep '^rust ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT
shell: bash

- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
uses: ./.github/actions/setup-rust
with:
toolchain: ${{ steps.rust-version.outputs.rust-version }}
components: "clippy, rustfmt"
cache-shared-key: cargo-cli-${{ runner.os }}
cache-key: cargo-cli

- name: Read pinned Node.js version for CLI fixtures
id: node-version
Expand Down
Loading