|
| 1 | +name: Coverity |
| 2 | + |
| 3 | +# This GitHub workflow automates submitting builds to Coverity Scan. To enable it, |
| 4 | +# set the repository variable `ENABLE_COVERITY_SCAN_FOR_BRANCHES` (for details, see |
| 5 | +# https://docs.github.com/en/actions/learn-github-actions/variables) to a JSON |
| 6 | +# string array containing the names of the branches for which the workflow should be |
| 7 | +# run, e.g. `["main", "next"]`. |
| 8 | +# |
| 9 | +# In addition, two repository secrets must be set (for details how to add secrets, see |
| 10 | +# https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions): |
| 11 | +# `COVERITY_SCAN_EMAIL` and `COVERITY_SCAN_TOKEN`. The former specifies the |
| 12 | +# email to which the Coverity reports should be sent and the latter can be |
| 13 | +# obtained from the Project Settings tab of the Coverity project). |
| 14 | + |
| 15 | +on: |
| 16 | + push: |
| 17 | + |
| 18 | +jobs: |
| 19 | + coverity: |
| 20 | + if: contains(fromJSON(vars.ENABLE_COVERITY_SCAN_FOR_BRANCHES || '[""]'), github.ref_name) |
| 21 | + runs-on: ubuntu-latest |
| 22 | + env: |
| 23 | + COVERITY_PROJECT: git |
| 24 | + COVERITY_LANGUAGE: cxx |
| 25 | + COVERITY_PLATFORM: linux64 |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v3 |
| 28 | + - run: ci/install-dependencies.sh |
| 29 | + env: |
| 30 | + runs_on_pool: ubuntu-latest |
| 31 | + |
| 32 | + - name: download the Coverity Build Tool (${{ env.COVERITY_LANGUAGE }} / ${{ env.COVERITY_PLATFORM}}) |
| 33 | + run: | |
| 34 | + curl https://scan.coverity.com/download/$COVERITY_LANGUAGE/$COVERITY_PLATFORM \ |
| 35 | + --fail --no-progress-meter \ |
| 36 | + --output $RUNNER_TEMP/cov-analysis.tgz \ |
| 37 | + --form token='${{ secrets.COVERITY_SCAN_TOKEN }}' \ |
| 38 | + --form project="$COVERITY_PROJECT" |
| 39 | + - name: extract the Coverity Build Tool |
| 40 | + run: | |
| 41 | + mkdir $RUNNER_TEMP/cov-analysis && |
| 42 | + tar -xzf $RUNNER_TEMP/cov-analysis.tgz --strip 1 -C $RUNNER_TEMP/cov-analysis |
| 43 | + - name: build with cov-build |
| 44 | + run: | |
| 45 | + export PATH="$RUNNER_TEMP/cov-analysis/bin:$PATH" && |
| 46 | + cov-configure --gcc && |
| 47 | + cov-build --dir cov-int make -j$(nproc) |
| 48 | + - name: package the build |
| 49 | + run: tar -czvf cov-int.tgz cov-int |
| 50 | + - name: submit the build to Coverity Scan |
| 51 | + run: | |
| 52 | + curl \ |
| 53 | + --fail \ |
| 54 | + --form token='${{ secrets.COVERITY_SCAN_TOKEN }}' \ |
| 55 | + --form email='${{ secrets.COVERITY_SCAN_EMAIL }}' \ |
| 56 | + |
| 57 | + --form version='${{ github.sha }}' \ |
| 58 | + "https://scan.coverity.com/builds?project=$COVERITY_PROJECT" |
0 commit comments