name: libbpf-ci-coverity

on:
  push:
    branches:
      - master
  schedule:
    - cron:  '0 18 * * *'

jobs:
  coverity:
    runs-on: ubuntu-latest
    name: Coverity
    env:
      COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
    steps:
      - uses: actions/checkout@v4
      - uses: ./.github/actions/setup
      - name: Run coverity
        if: ${{ env.COVERITY_SCAN_TOKEN }}
        run: |
          source /tmp/ci_setup
          export COVERITY_SCAN_NOTIFICATION_EMAIL="${AUTHOR_EMAIL}"
          export COVERITY_SCAN_BRANCH_PATTERN=${GITHUB_REF##refs/*/}
          export TRAVIS_BRANCH=${COVERITY_SCAN_BRANCH_PATTERN}
          scripts/coverity.sh
        env:
          COVERITY_SCAN_PROJECT_NAME: libbpf
          COVERITY_SCAN_BUILD_COMMAND_PREPEND: 'cd src/'
          COVERITY_SCAN_BUILD_COMMAND: 'make'
      - name: SCM log
        run: cat /home/runner/work/libbpf/libbpf/src/cov-int/scm_log.txt
