From f5eb1b3da955e39f4630493c28ff68c27a39f088 Mon Sep 17 00:00:00 2001 From: Tony Date: Sat, 15 Oct 2022 01:45:37 +0200 Subject: [PATCH] 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. --- .github/workflows/ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c21f9ea88f..eb53d9d7ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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