name: "CodeQL"

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
  schedule:
    - cron: "15 19 * * 6"

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

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

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Initialize CodeQL
        uses: github/codeql-action/init@v4
        with:
          languages: ${{ matrix.language }}
          config-file: ./.github/codeql.yml
          queries: +security-and-quality
          build-mode: ${{ matrix.language == 'cpp' && 'manual' || 'none' }}



      - name: Build cpp
        if: ${{ matrix.language == 'cpp' }}
        run: |
          sudo apt-get update
          sudo apt-get install -y libuv1-dev libev-dev libglib2.0-dev libgnutls28-dev
          mkdir build
          cd build
          cmake ..
          make -j$(nproc)

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v4
        with:
          category: "/language:${{ matrix.language }}"
