From 78919a5fc416b1a43e4f6c3278eae63897b9a73a Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Tue, 5 Mar 2024 08:18:32 +0200 Subject: [PATCH] ci: Use Swatinem/rust-cache (#1700) * ci: See if Swatinem/rust-cache is faster than mozilla-actions/sccache-action * Install Rust tools before caching * Set shell * Use correct toolchain * Add cargo bin to PATH --- .github/actions/rust/action.yml | 22 ++++++++++++++++------ .github/workflows/bench.yml | 6 +++--- .github/workflows/check.yml | 11 +---------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/actions/rust/action.yml b/.github/actions/rust/action.yml index b489029fa9..df10b58480 100644 --- a/.github/actions/rust/action.yml +++ b/.github/actions/rust/action.yml @@ -20,11 +20,21 @@ runs: toolchain: ${{ inputs.version }} components: ${{ inputs.components }} - - name: Use sccache - uses: mozilla-actions/sccache-action@v0.0.4 + - name: Install cargo-binstall (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: Set-ExecutionPolicy Unrestricted -Scope Process; iex (iwr "https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1").Content - - name: Enable sscache + - name: Install cargo-binstall (Windows) + if: runner.os != 'Windows' shell: bash - run: | - echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV" - echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV" + run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash + + - name: Install Rust tools + shell: bash + run: cargo +${{ inputs.version }} binstall --no-confirm cargo-llvm-cov cargo-nextest flamegraph + + - name: Use Rust cache + uses: Swatinem/rust-cache@v2 + with: + cache-all-crates: "true" diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 7d4220c8dc..7d6c793580 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -25,15 +25,15 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Set PATH + run: echo "/home/bench/.cargo/bin" >> "${GITHUB_PATH}" + - name: Install Rust uses: ./.github/actions/rust with: version: $TOOLCHAIN components: rustfmt - - name: Configure Rust - run: cargo install flamegraph - - name: Fetch NSS and NSPR uses: ./.github/actions/nss diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 42a903ee3b..8ce5383dbe 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -53,7 +53,6 @@ jobs: DEBIAN_FRONTEND: noninteractive run: | sudo apt-get install -y --no-install-recommends gyp mercurial ninja-build lld - curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash echo "RUSTFLAGS=-C link-arg=-fuse-ld=lld" >> "$GITHUB_ENV" # In addition to installing dependencies, first make sure System Integrity Protection (SIP) @@ -65,7 +64,7 @@ jobs: if: runner.os == 'MacOS' run: | csrutil status | grep disabled - brew install ninja mercurial cargo-binstall llvm + brew install ninja mercurial llvm echo "/opt/homebrew/opt/llvm/bin" >> "$GITHUB_PATH" ln -s /opt/homebrew/bin/python3 /opt/homebrew/bin/python # python3 -m pip install gyp-next @@ -76,11 +75,6 @@ jobs: echo "$(python3 -m site --user-base)/bin" >> "$GITHUB_PATH" echo "RUSTFLAGS=-C link-arg=-fuse-ld=lld" >> "$GITHUB_ENV" - - name: Install dependencies (Windows) - if: runner.os == 'Windows' - shell: pwsh - run: Set-ExecutionPolicy Unrestricted -Scope Process; iex (iwr "https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.ps1").Content - - name: Use MSYS2 environment and install more dependencies (Windows) if: runner.os == 'Windows' run: | @@ -95,9 +89,6 @@ jobs: if: runner.os == 'Windows' uses: ilammy/msvc-dev-cmd@v1 - - name: Install Rust tools - run: cargo +${{ matrix.rust-toolchain }} binstall --no-confirm cargo-llvm-cov cargo-nextest - # This step might be removed if the distro included a recent enough # version of NSS. Ubuntu 20.04 only has 3.49, which is far too old. # (neqo-crypto/build.rs would also need to query pkg-config to get the