Skip to content

Commit

Permalink
ci: Use Swatinem/rust-cache (#1700)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
larseggert authored Mar 5, 2024
1 parent 06b5f29 commit 78919a5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
22 changes: 16 additions & 6 deletions .github/actions/rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@ runs:
toolchain: ${{ inputs.version }}
components: ${{ inputs.components }}

- name: Use sccache
uses: mozilla-actions/[email protected]
- 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"
6 changes: 3 additions & 3 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 1 addition & 10 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand Down

0 comments on commit 78919a5

Please sign in to comment.