name: CodeQL

on:
  push:
    branches:
      - master
  schedule:
    # Sunday 09:00
    - cron: '0 9 * * 0'

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

    strategy:
      fail-fast: false
      matrix:
        language: ['cpp']

    steps:
    - uses: actions/checkout@v4
      with:
        submodules: 'recursive'
        # We must fetch at least the immediate parents so that if this is
        # a pull request then we can checkout the head.
        fetch-depth: 2

    # Initializes the CodeQL tools for scanning.
    - name: Initialize CodeQL
      uses: github/codeql-action/init@v3
      with:
        languages: ${{ matrix.language }}
        # If you wish to specify custom queries, you can do so here or in a config file.
        # By default, queries listed here will override any specified in a config file. 
        # Prefix the list here with "+" to use these queries and those in the config file.
        # queries: ./path/to/local/query, your-org/your-repo/queries@main

    - name: Install dependencies
      run: ./scripts/github-ci-linux-get-dependencies.sh
    - name: Build
      run: ./scripts/github-ci.sh experimental build

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