Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Adjust caching/installation in CI (#13169)

Alex Crichtoneb7a3f61290a
diff --git a/.github/actions/cargo-install/action.yml b/.github/actions/cargo-install/action.yml
new file mode 100644
index 0000000000..fc8b63f9fa
--- /dev/null
+++ b/.github/actions/cargo-install/action.yml
@@ -0,0 +1,42 @@
+name: 'Run `cargo install`'
+description: 'Run `cargo install`'
+
+inputs:
+ crate:
+ description: 'Crate to install'
+ required: true
+ version:
+ description: 'Version to install'
+ required: true
+
+runs:
+ using: composite
+ steps:
+ - uses: actions/cache/restore@v5
+ id: cache-restore
+ with:
+ path: ${{ runner.tool_cache }}/${{ inputs.crate }}
+ key: ${{ inputs.crate }}-bin-${{ inputs.version }}
+
+ - name: Add installation destination to PATH
+ shell: bash
+ run: echo "${{ runner.tool_cache }}/${{ inputs.crate }}/bin" >> $GITHUB_PATH
+
+ - name: Run cargo install
+ shell: bash
+ run: |
+ cargo install \
+ --root ${{ runner.tool_cache }}/${{ inputs.crate }} \
+ --version ${{ inputs.version }} \
+ --locked \
+ ${{ inputs.crate }}
+
+ # Avoid polluting caches related to merge queue branches or PRs since our
+ # cache space is at a premium with our CI. Only save these caches for the
+ # main branch and for release branches.
+ - name: Save Github Actions cache
+ uses: actions/cache/save@v5
+ if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release-')
+ with:
+ path: ${{ runner.tool_cache }}/${{ inputs.crate }}
+ key: ${{ steps.cache-restore.outputs.cache-primary-key }}
diff --git a/.github/actions/docker-build-cached/action.yml b/.github/actions/docker-build-cached/action.yml
index d9015a5675..47585d0a4f 100644
--- a/.github/actions/docker-build-cached/action.yml
+++ b/.github/actions/docker-build-cached/action.yml
@@ -35,7 +35,8 @@ runs:
# limit, so this is the next-best attempt to do something a bit more
# targeted.
- name: Setup Github Actions cache
- uses: actions/cache@v5
+ uses: actions/cache/restore@v5
+ id: cache-restore
with:
path: ${{ runner.tool_cache }}/docker-buildx-cache
key: ${{ inputs.cache_key_prefix }}-${{ hashFiles(inputs.file) }}
@@ -49,3 +50,16 @@ runs:
cache-from: type=local,src=${{ runner.tool_cache }}/docker-buildx-cache
cache-to: type=local,dest=${{ runner.tool_cache }}/docker-buildx-cache
outputs: type=docker
+
+ # Only save caches on the `main` branch since these docker images are
+ # relatively large. This means that caches aren't filled through the merge
+ # queue nor through PRs, but instead only through the `main` branch. PRs and
+ # the merge queue will pull from the `main` branch cache, but only after a
+ # ~1 day delay after merging a change because the `main` branch CI runs only
+ # nightly to prime the caches.
+ - name: Save Github Actions cache
+ uses: actions/cache/save@v5
+ if: github.ref == 'refs/heads/main'
+ with:
+ path: ${{ runner.tool_cache }}/docker-buildx-cache
+ key: ${{ steps.cache-restore.outputs.cache-primary-key }}
diff --git a/.github/actions/install-cargo-vet/action.yml b/.github/actions/install-cargo-vet/action.yml
deleted file mode 100644
index 823480e60a..0000000000
--- a/.github/actions/install-cargo-vet/action.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-name: 'Install the `cargo-vet` tool'
-description: 'Runs `cargo install cargo-vet`'
-
-inputs:
- version:
- description: 'Version to install'
- required: false
- default: '8b40d6351ed9758a73a4a0bf2c930c17a35c5e15'
-
-runs:
- using: composite
- steps:
- - uses: actions/cache@v5
- with:
- path: ${{ runner.tool_cache }}/cargo-vet
- key: cargo-vet-bin-${{ inputs.version }}
- - run: echo "${{ runner.tool_cache }}/cargo-vet/bin" >> $GITHUB_PATH
- shell: bash
- - run: |
- cargo install \
- --root ${{ runner.tool_cache }}/cargo-vet \
- --rev ${{ inputs.version }} \
- --git https://github.com/mozilla/cargo-vet \
- --locked \
- cargo-vet
- shell: bash
diff --git a/.github/actions/install-plugins-prerequisites/action.yml b/.github/actions/install-plugins-prerequisites/action.yml
index f8285b92a3..04a144da32 100644
--- a/.github/actions/install-plugins-prerequisites/action.yml
+++ b/.github/actions/install-plugins-prerequisites/action.yml
@@ -9,9 +9,11 @@ runs:
if: runner.os == 'Linux'
shell: bash
- name: Install wit-bindgen (Linux)
- run: cargo install [email protected]
if: runner.os == 'Linux'
- shell: bash
+ uses: ./.github/actions/cargo-install
+ with:
+ crate: wit-bindgen-cli
+ version: 0.46.0
- name: Install jco (Linux)
run: npm install --global @bytecodealliance/[email protected] && npm install --global @bytecodealliance/[email protected]
if: runner.os == 'Linux'
diff --git a/.github/workflows/cargo-audit.yml b/.github/workflows/cargo-audit.yml
index ccf5a7b724..92aca398b4 100644
--- a/.github/workflows/cargo-audit.yml
+++ b/.github/workflows/cargo-audit.yml
@@ -5,19 +5,14 @@ on:
jobs:
security_audit:
runs-on: ubuntu-latest
- env:
- CARGO_AUDIT_VERSION: 0.22.1
steps:
- uses: actions/checkout@v6
with:
submodules: true
- - uses: actions/cache@v5
+ - uses: ./.github/actions/cargo-install
with:
- path: ${{ runner.tool_cache }}/cargo-audit
- key: cargo-audit-${{ env.CARGO_AUDIT_VERSION }}
- - run: |
- echo "${{ runner.tool_cache }}/cargo-audit/bin" >> $GITHUB_PATH
- cargo install --root ${{ runner.tool_cache }}/cargo-audit --version ${{ env.CARGO_AUDIT_VERSION }} cargo-audit --locked
+ crate: cargo-audit
+ version: 0.22.1
- uses: rustsec/audit-check@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 80cbdeae93..ef9295c5ee 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -93,13 +93,10 @@ jobs:
with:
submodules: true
- uses: ./.github/actions/install-rust
- - run: |
- set -e
- curl --retry 5 --retry-all-errors -L -o cargo-deny.tar.gz https://github.com/EmbarkStudios/cargo-deny/releases/download/0.18.2/cargo-deny-0.18.2-x86_64-unknown-linux-musl.tar.gz
- tar xzf cargo-deny.tar.gz
- rm cargo-deny.tar.gz
- mv cargo-deny-*-x86_64-unknown-linux-musl/cargo-deny cargo-deny
- echo `pwd` >> $GITHUB_PATH
+ - uses: ./.github/actions/cargo-install
+ with:
+ crate: cargo-deny
+ version: 0.18.2
- run: cargo deny check bans licenses
# Ensure dependencies are vetted. See https://mozilla.github.io/cargo-vet/
@@ -122,7 +119,10 @@ jobs:
with:
submodules: true
- uses: ./.github/actions/install-rust
- - uses: ./.github/actions/install-cargo-vet
+ - uses: ./.github/actions/cargo-install
+ with:
+ crate: cargo-vet
+ version: 0.10.2
- id: vet
run: cargo vet --locked
continue-on-error: ${{ github.event_name == 'pull_request' }}
@@ -264,8 +264,6 @@ jobs:
name: Doc build
runs-on: ubuntu-latest
env:
- MDBOOK_VERSION: 0.4.37
- MDBOOK_LANGTABS_VERSION: 0.1.1
RUSTDOCFLAGS: -Dwarnings --cfg docsrs
OPENVINO_SKIP_LINKING: 1
steps:
@@ -286,14 +284,14 @@ jobs:
- run: cmake --build target/c-api --target doc
# install mdbook, build the docs, and test the docs
- - uses: actions/cache@v5
+ - uses: ./.github/actions/cargo-install
with:
- path: ${{ runner.tool_cache }}/mdbook
- key: cargo-mdbook-${{ env.MDBOOK_VERSION }}-langtabs-${{ env.MDBOOK_LANGTABS_VERSION }}
- - run: |
- echo "${{ runner.tool_cache }}/mdbook/bin" >> $GITHUB_PATH
- cargo install --root ${{ runner.tool_cache }}/mdbook --version ${{ env.MDBOOK_VERSION }} mdbook --locked
- cargo install --root ${{ runner.tool_cache }}/mdbook --version ${{ env.MDBOOK_LANGTABS_VERSION }} mdbook-langtabs --locked
+ crate: mdbook
+ version: 0.4.37
+ - uses: ./.github/actions/cargo-install
+ with:
+ crate: mdbook-langtabs
+ version: 0.1.1
- run: (cd docs && mdbook build)
# Build Rust API documentation.
@@ -663,7 +661,10 @@ jobs:
#
# Install the OCaml packages necessary for fuzz targets that use the
# `wasm-spec-interpreter`.
- - run: cargo install cargo-fuzz --vers "^0.11" --locked
+ - uses: ./.github/actions/cargo-install
+ with:
+ crate: cargo-fuzz
+ version: 0.13.1
- uses: ./.github/actions/apt-get-install
with:
packages: ocaml-nox ocamlbuild ocaml-findlib libzarith-ocaml-dev
@@ -1152,7 +1153,10 @@ jobs:
with:
submodules: true
- uses: ./.github/actions/install-rust
- - run: cargo install [email protected] --locked
+ - uses: ./.github/actions/cargo-install
+ with:
+ crate: cbindgen
+ version: 0.29.0
- run: rustup target add x86_64-unknown-none
- run: rustup target add wasm32-wasip2
- run: ./build.sh x86_64-unknown-none
@@ -1256,7 +1260,6 @@ jobs:
name: Miri
runs-on: ubuntu-latest
env:
- CARGO_NEXTEST_VERSION: 0.9.88
MIRIFLAGS: -Zmiri-permissive-provenance
steps:
- uses: actions/checkout@v6
@@ -1266,12 +1269,10 @@ jobs:
with:
toolchain: wasmtime-ci-pinned-nightly
- run: rustup component add rust-src miri
- - uses: actions/cache@v5
+ - uses: ./.github/actions/cargo-install
with:
- path: ${{ runner.tool_cache }}/cargo-nextest
- key: cargo-nextest-bin-${{ env.CARGO_NEXTEST_VERSION }}
- - run: echo "${{ runner.tool_cache }}/cargo-nextest/bin" >> $GITHUB_PATH
- - run: cargo install --root ${{ runner.tool_cache }}/cargo-nextest --version ${{ env.CARGO_NEXTEST_VERSION }} cargo-nextest --locked
+ crate: cargo-nextest
+ version: 0.9.133
- run: |
cargo miri nextest run -j4 --no-fail-fast -p ${{ matrix.crate }}
if: ${{ matrix.crate }}