Skip to content

Commit

Permalink
ci: try out the sccache for caching rust code (#10445)
Browse files Browse the repository at this point in the history
  • Loading branch information
nagisa authored Jan 30, 2024
1 parent c5a46ac commit d3ea7ed
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 45 deletions.
90 changes: 46 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ jobs:
tool: just,cargo-nextest,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 }}"
save-if: "${{ github.event_name == 'merge_group' }}" # save the cache only from master CI
- uses: mozilla-actions/sccache-action@1e15924c00ed1446db9e44e8f02628488e7258ec
- run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
# Run the tests:
- run: mkdir -p coverage/profraw/{unit,integration,binaries}
Expand Down Expand Up @@ -114,14 +113,14 @@ jobs:
- uses: taiki-e/install-action@91af8c38814c3998cb755869e5cbeffd3ab0e462
with:
tool: 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: echo "CARGO=1" >> "$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 @@ -144,14 +143,14 @@ jobs:
- uses: taiki-e/install-action@91af8c38814c3998cb755869e5cbeffd3ab0e462
with:
tool: 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: echo "CARGO=1" >> "$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 @@ -178,16 +177,16 @@ jobs:
- uses: taiki-e/install-action@91af8c38814c3998cb755869e5cbeffd3ab0e462
with:
tool: 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: echo "CARGO=1" >> "$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 @@ -214,14 +213,14 @@ jobs:
- uses: taiki-e/install-action@91af8c38814c3998cb755869e5cbeffd3ab0e462
with:
tool: 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: echo "CARGO=1" >> "$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 @@ -259,14 +258,14 @@ jobs:
- uses: taiki-e/install-action@91af8c38814c3998cb755869e5cbeffd3ab0e462
with:
tool: 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: echo "CARGO=1" >> "$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 @@ -282,9 +281,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
save-if: "${{ github.event_name == 'merge_group' }}" # save the cache only from master CI
- uses: mozilla-actions/sccache-action@1e15924c00ed1446db9e44e8f02628488e7258ec
- run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- uses: taiki-e/install-action@91af8c38814c3998cb755869e5cbeffd3ab0e462
with:
tool: just
Expand Down Expand Up @@ -317,9 +317,10 @@ jobs:
- uses: taiki-e/install-action@91af8c38814c3998cb755869e5cbeffd3ab0e462
with:
tool: just
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
save-if: "${{ github.event_name == 'merge_group' }}" # save the cache only from master CI
- 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 @@ -360,9 +361,10 @@ jobs:
- uses: taiki-e/install-action@91af8c38814c3998cb755869e5cbeffd3ab0e462
with:
tool: just,cargo-udeps
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43
with:
save-if: "${{ github.event_name == 'merge_group' }}" # save the cache only from master CI
- 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 }}
mkdir -p coverage/codecov
cargo llvm-cov report --profile dev-release --codecov --output-path coverage/codecov/new.json
Expand Down
File renamed without changes.

0 comments on commit d3ea7ed

Please sign in to comment.