Skip to content

Commit

Permalink
ci: try out the sccache for caching rust code
Browse files Browse the repository at this point in the history
  • Loading branch information
nagisa committed Jan 16, 2024
1 parent db20a66 commit e91041a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 38 deletions.
78 changes: 41 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ jobs:
crate: cargo-llvm-cov

# Setup the dependency rust cache and llvm-cov
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
prefix-key: "0" # change this to invalidate CI cache
shared-key: "cargo_nextest-${{ matrix.cache_id }}"
- uses: mozilla-actions/sccache-action@1e15924c00ed1446db9e44e8f02628488e7258ec
- run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
# Run the tests
- run: just codecov "nextest-unit ${{ matrix.type }}"
Expand Down Expand Up @@ -100,14 +100,13 @@ jobs:
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: cargo-llvm-cov
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
prefix-key: "0" # change this to invalidate CI cache
shared-key: "cargo_nextest-linux"
save-if: "false" # use the cache from nextest, but don’t double-save
- uses: mozilla-actions/sccache-action@1e15924c00ed1446db9e44e8f02628488e7258ec
- run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- run: pip3 install --user -r pytest/requirements.txt
- run: cargo llvm-cov show-env | grep -v RUSTFLAGS | tr -d "'" >> "$GITHUB_ENV"
- run: echo "RUSTC_WORKSPACE_WRAPPER=$PWD/scripts/rustc-coverage-wrapper.sh" >> "$GITHUB_ENV"
- run: echo "RUSTC_WORKSPACE_WRAPPER=$PWD/scripts/coverage-wrapper/rustc" >> "$GITHUB_ENV"
- run: cargo build --locked --profile dev-release -p neard --bin neard
- run: echo "CURRENT_NEARD=$PWD/target/dev-release/neard" >> "$GITHUB_ENV"
- run: cd pytest && python3 tests/sanity/backward_compatible.py
Expand All @@ -129,14 +128,13 @@ jobs:
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: cargo-llvm-cov
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
prefix-key: "0" # change this to invalidate CI cache
shared-key: "cargo_nextest-linux"
save-if: "false" # use the cache from nextest, but don’t double-save
- uses: mozilla-actions/sccache-action@1e15924c00ed1446db9e44e8f02628488e7258ec
- run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- run: pip3 install --user -r pytest/requirements.txt
- run: cargo llvm-cov show-env | grep -v RUSTFLAGS | tr -d "'" >> "$GITHUB_ENV"
- run: echo "RUSTC_WORKSPACE_WRAPPER=$PWD/scripts/rustc-coverage-wrapper.sh" >> "$GITHUB_ENV"
- run: echo "RUSTC_WORKSPACE_WRAPPER=$PWD/scripts/coverage-wrapper/rustc" >> "$GITHUB_ENV"
- run: cargo build --locked --profile dev-release -p neard --bin neard
- run: echo "CURRENT_NEARD=$PWD/target/dev-release/neard" >> "$GITHUB_ENV"
- run: echo "NEAR_ROOT=$PWD" >> "$GITHUB_ENV"
Expand All @@ -162,16 +160,15 @@ jobs:
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: cargo-llvm-cov
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
prefix-key: "0" # change this to invalidate CI cache
shared-key: "cargo_nextest-linux"
save-if: "false" # use the cache from nextest, but don’t double-save
- uses: mozilla-actions/sccache-action@1e15924c00ed1446db9e44e8f02628488e7258ec
- run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- run: pip3 install --user -r pytest/requirements.txt
# This is the only job that uses `--features nightly` so we build this in-line instead of a
# separate job like done with the regular neard.
- run: cargo llvm-cov show-env | grep -v RUSTFLAGS | tr -d "'" >> "$GITHUB_ENV"
- run: echo "RUSTC_WORKSPACE_WRAPPER=$PWD/scripts/rustc-coverage-wrapper.sh" >> "$GITHUB_ENV"
- run: echo "RUSTC_WORKSPACE_WRAPPER=$PWD/scripts/coverage-wrapper/rustc" >> "$GITHUB_ENV"
- run: cargo build --profile dev-release -p neard --bin neard --features nightly
# Note: We're not running spin_up_cluster.py for non-nightly
# because spinning up non-nightly clusters is already covered
Expand All @@ -197,14 +194,13 @@ jobs:
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: cargo-llvm-cov
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
prefix-key: "0" # change this to invalidate CI cache
shared-key: "cargo_nextest-linux"
save-if: "false" # use the cache from nextest, but don’t double-save
- uses: mozilla-actions/sccache-action@1e15924c00ed1446db9e44e8f02628488e7258ec
- run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- run: pip3 install --user -r pytest/requirements.txt
- run: cargo llvm-cov show-env | grep -v RUSTFLAGS | tr -d "'" >> "$GITHUB_ENV"
- run: echo "RUSTC_WORKSPACE_WRAPPER=$PWD/scripts/rustc-coverage-wrapper.sh" >> "$GITHUB_ENV"
- run: echo "RUSTC_WORKSPACE_WRAPPER=$PWD/scripts/coverage-wrapper/rustc" >> "$GITHUB_ENV"
- run: cargo build --locked --profile dev-release -p neard --bin neard
- run: echo "CURRENT_NEARD=$PWD/target/dev-release/neard" >> "$GITHUB_ENV"
- run: python3 scripts/state/update_res.py check
Expand Down Expand Up @@ -241,14 +237,13 @@ jobs:
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: cargo-llvm-cov
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
prefix-key: "0" # change this to invalidate CI cache
shared-key: "cargo_nextest-linux"
save-if: "false" # use the cache from nextest, but don’t double-save
- uses: mozilla-actions/sccache-action@1e15924c00ed1446db9e44e8f02628488e7258ec
- run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- run: pip3 install --user -r pytest/requirements.txt
- run: cargo llvm-cov show-env | grep -v RUSTFLAGS | tr -d "'" >> "$GITHUB_ENV"
- run: echo "RUSTC_WORKSPACE_WRAPPER=$PWD/scripts/rustc-coverage-wrapper.sh" >> "$GITHUB_ENV"
- run: echo "RUSTC_WORKSPACE_WRAPPER=$PWD/scripts/coverage-wrapper/rustc" >> "$GITHUB_ENV"
- run: cargo build --locked --profile dev-release -p neard --bin neard
- run: echo "CURRENT_NEARD=$PWD/target/dev-release/neard" >> "$GITHUB_ENV"
- run: cd pytest && python3 tests/sanity/upgradable.py
Expand All @@ -263,7 +258,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
- uses: mozilla-actions/sccache-action@1e15924c00ed1446db9e44e8f02628488e7258ec
- run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: just
Expand Down Expand Up @@ -296,7 +294,10 @@ jobs:
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: just
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
- uses: mozilla-actions/sccache-action@1e15924c00ed1446db9e44e8f02628488e7258ec
- run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- run: just check-cargo-clippy

check_cargo_deny:
Expand Down Expand Up @@ -343,7 +344,10 @@ jobs:
- uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941
with:
crate: cargo-udeps
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
- uses: mozilla-actions/sccache-action@1e15924c00ed1446db9e44e8f02628488e7258ec
- run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- run: just check-cargo-udeps

cargo_audit:
Expand Down
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ codecov RULE:
# TODO: remove the RUSTFLAGS hack, see also https://github.com/rust-lang/cargo/issues/13040
cargo llvm-cov show-env --export-prefix | grep -v RUSTFLAGS > env
source ./env
export RUSTC_WORKSPACE_WRAPPER="{{ absolute_path("scripts/rustc-coverage-wrapper.sh") }}"
export RUSTC_WORKSPACE_WRAPPER="{{ absolute_path("scripts/coverage-wrapper/rustc") }}"
{{ just_executable() }} {{ RULE }}
cargo llvm-cov report --profile dev-release --codecov --output-path codecov.json
# See https://github.com/taiki-e/cargo-llvm-cov/issues/292
Expand Down
File renamed without changes.

0 comments on commit e91041a

Please sign in to comment.