coverity: cache the Coverity Build Tool
It would add a 1GB+ download for every run, better cache it. This is inspired by the GitHub Action `vapier/coverity-scan-action`, however, it uses the finer-grained `restore`/`save` method to be able to cache the Coverity Build Tool even if an unrelated step in the GitHub workflow fails later on. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Sep 25, 2023 at 11:50 UTC
002e5e9ad163f30e1664a2bf37e45097c8ab6be5
1 file changed
+28
.github/workflows/coverity.yml
+28
@@ -29,7 +29,28 @@ jobs:
29
env:
30
runs_on_pool: ubuntu-latest
31
32
+ # The Coverity site says the tool is usually updated twice yearly, so the
33
+ # MD5 of download can be used to determine whether there's been an update.
34
+ - name: get the Coverity Build Tool hash
35
+ id: lookup
36
+ run: |
37
+ MD5=$(curl https://scan.coverity.com/download/$COVERITY_LANGUAGE/$COVERITY_PLATFORM \
38
+ --fail \
39
+ --form token='${{ secrets.COVERITY_SCAN_TOKEN }}' \
40
+ --form project="$COVERITY_PROJECT" \
41
+ --form md5=1) &&
42
+ echo "hash=$MD5" >>$GITHUB_OUTPUT
43
+
44
+ # Try to cache the tool to avoid downloading 1GB+ on every run.
45
+ # A cache miss will add ~30s to create, but a cache hit will save minutes.
46
+ - name: restore the Coverity Build Tool
47
+ id: cache
48
+ uses: actions/cache/restore@v3
49
+ with:
50
+ path: ${{ runner.temp }}/cov-analysis
51
+ key: cov-build-${{ env.COVERITY_LANGUAGE }}-${{ env.COVERITY_PLATFORM }}-${{ steps.lookup.outputs.hash }}
52
- name: download the Coverity Build Tool (${{ env.COVERITY_LANGUAGE }} / ${{ env.COVERITY_PLATFORM}})
53
+ if: steps.cache.outputs.cache-hit != 'true'
54
run: |
55
curl https://scan.coverity.com/download/$COVERITY_LANGUAGE/$COVERITY_PLATFORM \
56
--fail --no-progress-meter \
@@ -37,9 +58,16 @@ jobs:
58
--form token='${{ secrets.COVERITY_SCAN_TOKEN }}' \
59
--form project="$COVERITY_PROJECT"
60
- name: extract the Coverity Build Tool
61
+ if: steps.cache.outputs.cache-hit != 'true'
62
run: |
63
mkdir $RUNNER_TEMP/cov-analysis &&
64
tar -xzf $RUNNER_TEMP/cov-analysis.tgz --strip 1 -C $RUNNER_TEMP/cov-analysis
65
+ - name: cache the Coverity Build Tool
66
+ if: steps.cache.outputs.cache-hit != 'true'
67
+ uses: actions/cache/save@v3
68
+ with:
69
+ path: ${{ runner.temp }}/cov-analysis
70
+ key: cov-build-${{ env.COVERITY_LANGUAGE }}-${{ env.COVERITY_PLATFORM }}-${{ steps.lookup.outputs.hash }}
71
- name: build with cov-build
72
run: |
73
export PATH="$RUNNER_TEMP/cov-analysis/bin:$PATH" &&