| 1 | name: Coverity Scan |
| 2 | on: |
| 3 | workflow_dispatch: |
| 4 | schedule: |
| 5 | - cron: '30 0 * * *' |
| 6 | concurrency: |
| 7 | group: ${{ github.workflow }}-${{ github.ref }} |
| 8 | cancel-in-progress: true |
| 9 | jobs: |
| 10 | has_changed: |
| 11 | runs-on: ubuntu-latest |
| 12 | permissions: |
| 13 | contents: read |
| 14 | outputs: |
| 15 | changed: ${{ steps.check.outputs.changed }} |
| 16 | steps: |
| 17 | - uses: actions/checkout@v4 |
| 18 | - name: Print latest commit |
| 19 | run: echo ${{ github.sha }} |
| 20 | |
| 21 | - id: check |
| 22 | name: Check that there were changes in the repository in the last 24 hours |
| 23 | run: | |
| 24 | commits=`git rev-list --after="24 hours" ${{ github.sha }}` |
| 25 | if [ -z "$commits" ]; then |
| 26 | echo "::set-output name=changed::false" |
| 27 | exit 0 |
| 28 | fi |
| 29 | |
| 30 | echo "::set-output name=changed::true" |
| 31 | |
| 32 | submit: |
| 33 | needs: has_changed |
| 34 | if: ${{ needs.has_changed.outputs.changed == 'true' }} |
| 35 | runs-on: ubuntu-latest |
| 36 | permissions: |
| 37 | contents: read |
| 38 | env: |
| 39 | TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} |
| 40 | steps: |
| 41 | - name: Checkout repository |
| 42 | uses: actions/checkout@v4 |
| 43 | |
| 44 | - name: Load Coverity Scan tool from cache |
| 45 | id: cache |
| 46 | uses: actions/cache@v4 |
| 47 | with: |
| 48 | path: covscan |
| 49 | key: ${{ runner.os }}-covscan |
| 50 | |
| 51 | - name: Download Coverity Build Tool |
| 52 | if: steps.cache.outputs.cache-hit != 'true' |
| 53 | run: | |
| 54 | set -ex |
| 55 | |
| 56 | curl \ |
| 57 | --data "token=$TOKEN&project=authselect%2Fauthselect" \ |
| 58 | -o covscan.tar.gz \ |
| 59 | https://scan.coverity.com/download/linux64 |
| 60 | mkdir covscan |
| 61 | tar -xzf covscan.tar.gz --strip 1 -C covscan |
| 62 | rm covscan.tar.gz |
| 63 | |
| 64 | - name: Install dependencies |
| 65 | run: | |
| 66 | sudo scripts/auto install-build-deps |
| 67 | |
| 68 | - run: autoreconf -if && ./configure --enable-silent-rules |
| 69 | |
| 70 | - name: Build with cov-build |
| 71 | run: | |
| 72 | export PATH="$(pwd)/covscan/bin:$PATH" |
| 73 | cov-build --dir cov-int make |
| 74 | |
| 75 | - name: Print logs |
| 76 | run: | |
| 77 | cat cov-int/build-log.txt |
| 78 | |
| 79 | - name: Submit the result to Coverity Scan |
| 80 | run: | |
| 81 | tar -czvf build.tgz cov-int |
| 82 | curl \ |
| 83 | --form project=authselect/authselect \ |
| 84 | --form token=$TOKEN \ |
| 85 | --form [email protected] \ |
| 86 | --form [email protected] \ |
| 87 | --form version=master \ |
| 88 | --form description="Latest upstream code." \ |
| 89 | https://scan.coverity.com/builds?project=authselect%2Fauthselect |