Skip to content

Commit

Permalink
Fix Rust Cache invalid key warning (#59)
Browse files Browse the repository at this point in the history
The `Swatinem/rust-cache` GitHub action does not support commas
in its cache key, but we use the Cargo feature set (which can have commas)
as part of the cache key. This commit hashes the feature set to avoid this
problem.
  • Loading branch information
AntoniosBarotsis authored and joshlf committed Aug 3, 2023
1 parent 55ddfe5 commit f5eb1b3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ jobs:
# https://github.com/actions/runner/issues/409#issuecomment-752775072
components: ${{ contains(matrix.channel, '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/rust-cache@v2.0.0
with:
key: "${{ matrix.channel }}-${{ matrix.target }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }}"
key: "${{ matrix.channel }}-${{ matrix.target }}-${{ env.FEATURES_HASH }}-${{ hashFiles('**/Cargo.lock') }}"

- name: Check
run: cargo +${{ matrix.channel }} check --target ${{ matrix.target }} --features "${{ matrix.features }}" --verbose
Expand Down

0 comments on commit f5eb1b3

Please sign in to comment.