name: Coverity
on:
  schedule:
    - cron:  '30 12 * * 0'

jobs:
  coverity:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 2

      - name: Install dependencies
        run: |
          sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu bionic main universe'
          sudo apt-get -qq update
          sudo apt-get install -y libftgl-dev freeglut3-dev libcurl4-openssl-dev libxmu-dev libxi-dev libfcgi-dev libxss-dev libnotify-dev libxcb-util0-dev libgtk2.0-dev libwebkitgtk-dev p7zip-full libxxf86vm-dev ocl-icd-opencl-dev zip

      - name: Cache dependencies
        uses: actions/cache@v2
        with:
          path: |
            3rdParty/buildCache
            !3rdParty/buildCache/linux/vcpkgcache/
          key: linux-coverity-${{ hashFiles('3rdParty/*Linux*.sh', 'linux/*.sh', '.github/workflows/coverity.yml') }}

      - name: Automake
        if: success()
        run: ./_autosetup

      - name: Prepare for scan
        if: success()
        run: ./3rdParty/buildLinuxDependencies.sh && ./configure --enable-apps --with-wx-prefix=${GITHUB_WORKSPACE}/3rdParty/buildCache/linux

      - name: Coverity Scan
        uses: vapier/coverity-scan-action@v0
        with:
          project: 'BOINC/boinc'
          token: ${{ secrets.COVERITY_SCAN_TOKEN }}
          email: 'boinc_cvs@ssl.berkeley.edu'
