Skip to content

Commit 002e5e9

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a56b623 commit 002e5e9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/workflows/coverity.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,45 @@ jobs:
2929
env:
3030
runs_on_pool: ubuntu-latest
3131

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 }}
3252
- name: download the Coverity Build Tool (${{ env.COVERITY_LANGUAGE }} / ${{ env.COVERITY_PLATFORM}})
53+
if: steps.cache.outputs.cache-hit != 'true'
3354
run: |
3455
curl https://scan.coverity.com/download/$COVERITY_LANGUAGE/$COVERITY_PLATFORM \
3556
--fail --no-progress-meter \
3657
--output $RUNNER_TEMP/cov-analysis.tgz \
3758
--form token='${{ secrets.COVERITY_SCAN_TOKEN }}' \
3859
--form project="$COVERITY_PROJECT"
3960
- name: extract the Coverity Build Tool
61+
if: steps.cache.outputs.cache-hit != 'true'
4062
run: |
4163
mkdir $RUNNER_TEMP/cov-analysis &&
4264
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 }}
4371
- name: build with cov-build
4472
run: |
4573
export PATH="$RUNNER_TEMP/cov-analysis/bin:$PATH" &&

0 commit comments

Comments
 (0)