name: "CodeQL"

on:
  push:
    branches: [ 2_0_X ]
  pull_request:
    branches: [ 2_0_X ]

permissions:
  contents: read

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-22.04
    permissions:
      actions: read
      contents: read
      security-events: write

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

    steps:
    - name: Checkout repository
      uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

    - name: Initialize CodeQL
      uses: github/codeql-action/init@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v3.29.5
      with:
        languages: ${{ matrix.language }}

    - name: Install dependencies
      run: |
        sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
        sudo apt-get update
        sudo ./contrib/ci/fwupd_setup_helpers.py install-dependencies --yes -o ubuntu
        python3 -m pip install --user "meson >= 0.62.0"

    - name: Build
      run: |
        mkdir -p $GITHUB_WORKSPACE/build
        cd $GITHUB_WORKSPACE/build
        meson setup .. -Dman=false --prefix=$GITHUB_WORKSPACE/dist -Dlibxmlb:gtkdoc=false
        ninja

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v3.29.5
