Skip to content

Commit

Permalink
[CI] Optimize (and fix) caching (#106)
Browse files Browse the repository at this point in the history
- Remove redundant flags in `key` when using rust-cache. They are
  automatically added by the action.
- Add 'push to main' as trigger to reuse cache across PRs. See https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows\#restrictions-for-accessing-a-cache

Resolves #85
  • Loading branch information
glokta1 authored Oct 27, 2022
1 parent f42f36d commit 79dcfd2
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Build & Tests

on:
pull_request:
push:
branches: main

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -110,17 +112,10 @@ jobs:
# https://github.com/actions/runner/issues/409#issuecomment-752775072
components: clippy ${{ matrix.toolchain == 'nightly' && ', miri' || '' }}

# The features string contains commas which cannot be part of the cache
# key for the Rust Cache action. Instead, we hash the features
# to get a string of legal characters.
- name: Set feature string for cache key
run: |
echo "FEATURES_HASH=$(echo ${{ matrix.features }} | sha256sum | cut -d ' ' -f 1)" >> $GITHUB_ENV
- name: Rust Cache
uses: Swatinem/[email protected]
with:
key: "${{ env.ZC_TOOLCHAIN }}-${{ matrix.target }}-${{ env.FEATURES_HASH }}-${{ hashFiles('**/Cargo.lock') }}"
key: "${{ matrix.target }}"

- name: Check
run: cargo +${{ env.ZC_TOOLCHAIN }} check --manifest-path ${{ matrix.manifest-path }} --target ${{ matrix.target }} ${{ matrix.features }} --verbose
Expand Down

0 comments on commit 79dcfd2

Please sign in to comment.