|
| 1 | +name: "CodeQL" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + schedule: |
| 9 | + - cron: "0 6 * * 1" # Weekly on Monday at 06:00 UTC |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + security-events: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + changes: |
| 17 | + name: Detect changed paths |
| 18 | + if: github.event_name == 'pull_request' |
| 19 | + runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + pull-requests: read |
| 23 | + outputs: |
| 24 | + java: ${{ steps.filter.outputs.java }} |
| 25 | + js: ${{ steps.filter.outputs.js }} |
| 26 | + python: ${{ steps.filter.outputs.python }} |
| 27 | + go: ${{ steps.filter.outputs.go }} |
| 28 | + rust: ${{ steps.filter.outputs.rust }} |
| 29 | + csharp: ${{ steps.filter.outputs.csharp }} |
| 30 | + actions: ${{ steps.filter.outputs.actions }} |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + - uses: dorny/paths-filter@v3 |
| 34 | + id: filter |
| 35 | + with: |
| 36 | + filters: | |
| 37 | + java: |
| 38 | + - 'java/**' |
| 39 | + js: |
| 40 | + - 'nodejs/**' |
| 41 | + - 'scripts/**' |
| 42 | + - 'test/harness/**' |
| 43 | + python: |
| 44 | + - 'python/**' |
| 45 | + go: |
| 46 | + - 'go/**' |
| 47 | + rust: |
| 48 | + - 'rust/**' |
| 49 | + csharp: |
| 50 | + - 'dotnet/**' |
| 51 | + actions: |
| 52 | + - '.github/workflows/**' |
| 53 | + - '.github/actions/**' |
| 54 | +
|
| 55 | + analyze: |
| 56 | + name: Analyze (${{ matrix.language }}) |
| 57 | + needs: changes |
| 58 | + # Run even if 'changes' is skipped (e.g. on push/schedule where paths-filter |
| 59 | + # may not flag changes). Each step has its own gate condition. |
| 60 | + if: always() |
| 61 | + runs-on: ubuntu-latest |
| 62 | + permissions: |
| 63 | + security-events: write |
| 64 | + contents: read |
| 65 | + strategy: |
| 66 | + fail-fast: false |
| 67 | + matrix: |
| 68 | + include: |
| 69 | + - language: java-kotlin |
| 70 | + gate: java |
| 71 | + - language: javascript-typescript |
| 72 | + gate: js |
| 73 | + - language: python |
| 74 | + gate: python |
| 75 | + - language: go |
| 76 | + gate: go |
| 77 | + - language: rust |
| 78 | + gate: rust |
| 79 | + - language: csharp |
| 80 | + gate: csharp |
| 81 | + - language: actions |
| 82 | + gate: actions |
| 83 | + steps: |
| 84 | + - name: Checkout repository |
| 85 | + if: ${{ needs.changes.outputs[matrix.gate] == 'true' || github.event_name == 'schedule' || github.event_name == 'push' }} |
| 86 | + uses: actions/checkout@v4 |
| 87 | + |
| 88 | + - name: Initialize CodeQL |
| 89 | + if: ${{ needs.changes.outputs[matrix.gate] == 'true' || github.event_name == 'schedule' || github.event_name == 'push' }} |
| 90 | + uses: github/codeql-action/init@v3 |
| 91 | + with: |
| 92 | + languages: ${{ matrix.language }} |
| 93 | + |
| 94 | + - name: Autobuild |
| 95 | + if: ${{ needs.changes.outputs[matrix.gate] == 'true' || github.event_name == 'schedule' || github.event_name == 'push' }} |
| 96 | + uses: github/codeql-action/autobuild@v3 |
| 97 | + |
| 98 | + - name: Perform CodeQL Analysis |
| 99 | + if: ${{ needs.changes.outputs[matrix.gate] == 'true' || github.event_name == 'schedule' || github.event_name == 'push' }} |
| 100 | + uses: github/codeql-action/analyze@v3 |
| 101 | + with: |
| 102 | + category: "/language:${{ matrix.language }}" |
0 commit comments