Skip to content

Commit 230820a

Browse files
Fix Rust Cache invalid key warning (#59)
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.
1 parent b581713 commit 230820a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,17 @@ jobs:
4343
# https://github.com/actions/runner/issues/409#issuecomment-752775072
4444
components: ${{ contains(matrix.channel, 'nightly') && 'miri' || '' }}
4545

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

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

0 commit comments

Comments
 (0)