diff --git a/.githooks/pre-commit b/.githooks/pre-commit old mode 100644 new mode 100755 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000..d11ffb328 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,95 @@ +name: "CodeQL" + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: "0 6 * * 1" # Weekly on Monday at 06:00 UTC + +permissions: + contents: read + security-events: write + +jobs: + changes: + name: Detect changed paths + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + outputs: + java: ${{ steps.filter.outputs.java }} + js: ${{ steps.filter.outputs.js }} + python: ${{ steps.filter.outputs.python }} + go: ${{ steps.filter.outputs.go }} + csharp: ${{ steps.filter.outputs.csharp }} + actions: ${{ steps.filter.outputs.actions }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + java: + - 'java/**' + js: + - 'nodejs/**' + - 'scripts/**' + python: + - 'python/**' + go: + - 'go/**' + csharp: + - 'dotnet/**' + actions: + - '.github/workflows/**' + - '.github/actions/**' + + analyze: + name: Analyze (${{ matrix.language }}) + needs: changes + # Run even if 'changes' is skipped (e.g. on push/schedule where paths-filter + # may not flag changes). Each step has its own gate condition. + if: always() + runs-on: ubuntu-latest + permissions: + security-events: write + contents: read + strategy: + fail-fast: false + matrix: + include: + - language: java-kotlin + gate: java + - language: javascript-typescript + gate: js + - language: python + gate: python + - language: go + gate: go + - language: csharp + gate: csharp + - language: actions + gate: actions + steps: + - name: Checkout repository + if: ${{ needs.changes.outputs[matrix.gate] == 'true' || github.event_name == 'schedule' || github.event_name == 'push' }} + uses: actions/checkout@v4 + + - name: Initialize CodeQL + if: ${{ needs.changes.outputs[matrix.gate] == 'true' || github.event_name == 'schedule' || github.event_name == 'push' }} + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + if: ${{ needs.changes.outputs[matrix.gate] == 'true' || github.event_name == 'schedule' || github.event_name == 'push' }} + uses: github/codeql-action/autobuild@v3 + + - name: Perform CodeQL Analysis + if: ${{ needs.changes.outputs[matrix.gate] == 'true' || github.event_name == 'schedule' || github.event_name == 'push' }} + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{ matrix.language }}"