|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +name: CodeQL |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + merge_group: |
| 9 | + types: [checks_requested] |
| 10 | + push: |
| 11 | + branches: [main] |
| 12 | + schedule: |
| 13 | + - cron: "29 5 * * 6" |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +jobs: |
| 24 | + analyze: |
| 25 | + name: CodeQL (${{ matrix.language }}) |
| 26 | + runs-on: ubuntu-latest |
| 27 | + timeout-minutes: 90 |
| 28 | + strategy: |
| 29 | + fail-fast: false |
| 30 | + matrix: |
| 31 | + include: |
| 32 | + - language: rust |
| 33 | + build-mode: none |
| 34 | + - language: go |
| 35 | + build-mode: manual |
| 36 | + - language: python |
| 37 | + build-mode: none |
| 38 | + - language: javascript-typescript |
| 39 | + build-mode: none |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 42 | + with: |
| 43 | + persist-credentials: false |
| 44 | + |
| 45 | + - name: Set up Go |
| 46 | + if: matrix.language == 'go' |
| 47 | + uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 |
| 48 | + with: |
| 49 | + go-version-file: sdk/go/go.mod |
| 50 | + cache-dependency-path: sdk/go/go.sum |
| 51 | + |
| 52 | + - name: Initialize CodeQL |
| 53 | + uses: github/codeql-action/init@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7 |
| 54 | + with: |
| 55 | + languages: ${{ matrix.language }} |
| 56 | + build-mode: ${{ matrix.build-mode }} |
| 57 | + config-file: ./.github/codeql/codeql-config.yml |
| 58 | + |
| 59 | + - name: Build Go SDK |
| 60 | + if: matrix.language == 'go' |
| 61 | + working-directory: sdk/go |
| 62 | + run: go build ./... |
| 63 | + |
| 64 | + - name: Analyze |
| 65 | + id: analyze |
| 66 | + uses: github/codeql-action/analyze@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7 |
| 67 | + with: |
| 68 | + category: /language:${{ matrix.language }} |
| 69 | + output: codeql-results |
| 70 | + upload: never |
| 71 | + |
| 72 | + - name: Summarize findings |
| 73 | + if: always() |
| 74 | + env: |
| 75 | + LANGUAGE: ${{ matrix.language }} |
| 76 | + shell: bash |
| 77 | + run: | |
| 78 | + set -euo pipefail |
| 79 | + shopt -s globstar nullglob |
| 80 | + sarif_files=(codeql-results/**/*.sarif) |
| 81 | +
|
| 82 | + { |
| 83 | + echo "### CodeQL: $LANGUAGE" |
| 84 | + echo |
| 85 | + if [ "${#sarif_files[@]}" -eq 0 ]; then |
| 86 | + echo "No SARIF report was produced." |
| 87 | + else |
| 88 | + finding_count=$(jq -s '[.[].runs[]?.results[]?] | length' "${sarif_files[@]}") |
| 89 | + echo "Findings: $finding_count" |
| 90 | + echo |
| 91 | + echo "Findings are informational and do not fail CI." |
| 92 | + fi |
| 93 | + } >> "$GITHUB_STEP_SUMMARY" |
| 94 | +
|
| 95 | + - name: Upload SARIF |
| 96 | + if: always() |
| 97 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 98 | + with: |
| 99 | + name: codeql-${{ matrix.language }}-${{ github.run_id }} |
| 100 | + path: codeql-results |
| 101 | + if-no-files-found: ignore |
| 102 | + retention-days: 14 |
| 103 | + |
| 104 | + result: |
| 105 | + name: OpenShell / CodeQL (informational) |
| 106 | + if: always() |
| 107 | + needs: analyze |
| 108 | + runs-on: ubuntu-latest |
| 109 | + permissions: {} |
| 110 | + steps: |
| 111 | + - name: Evaluate analyzer execution |
| 112 | + env: |
| 113 | + ANALYZE_RESULT: ${{ needs.analyze.result }} |
| 114 | + shell: bash |
| 115 | + run: | |
| 116 | + if [ "$ANALYZE_RESULT" != "success" ]; then |
| 117 | + echo "::error::One or more CodeQL analyzers did not complete successfully." |
| 118 | + exit 1 |
| 119 | + fi |
| 120 | + echo "All CodeQL analyzers completed; findings remain informational." |
0 commit comments