name: "CodeQL"

on:
  push:
    branches: [ main, stable-0.16.x ]
  pull_request:
    branches: [ main, stable-0.16.x ]
  schedule:
    - cron: '43 21 * * 3'

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-22.04

    strategy:
      fail-fast: false

    steps:
    - name: Checkout repository
      uses: actions/checkout@v3

    - name: Initialize CodeQL
      uses: github/codeql-action/init@v2
      with:
        languages: cpp

    - name: Install dependencies
      run: sudo ./tests/ci/install-deps-deb.sh

    - name: Update Meson
      run: sudo pip install 'meson~=0.62'

    - name: Build
      run: CC=gcc CXX=g++ ./tests/ci/run-build.sh codeql

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v2
