Fix script to handle SARIF file recategorization #689
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ******************************************************************************* | |
| # Copyright (c) 2025 Contributors to the Eclipse Foundation | |
| # | |
| # See the NOTICE file(s) distributed with this work for additional | |
| # information regarding copyright ownership. | |
| # | |
| # This program and the accompanying materials are made available under the | |
| # terms of the Apache License Version 2.0 which is available at | |
| # https://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # SPDX-License-Identifier: Apache-2.0 | |
| # ******************************************************************************* | |
| name: "CodeQL - Multi-Repo Source Scan" | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize] | |
| merge_group: | |
| types: [checks_requested] | |
| push: | |
| branches: | |
| - main | |
| release: | |
| types: [created] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| # Do not flood CI with unneeded previous runs in PR | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | |
| cancel-in-progress: ${{ github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') }} | |
| jobs: | |
| analyze-repos: | |
| name: Analyze Multiple Repositories | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 120 # Prevent indefinite hanging | |
| permissions: | |
| security-events: write | |
| packages: read | |
| actions: read | |
| contents: read | |
| steps: | |
| - name: Checkout central repository | |
| uses: actions/checkout@v4 | |
| - name: Install sarif-tools for HTML report generation | |
| run: | | |
| python3 -m pip install --upgrade pip | |
| pip3 install sarif-tools | |
| - name: Cache repository checkouts | |
| uses: actions/cache@v4 | |
| with: | |
| path: repos/ | |
| key: repos-${{ hashFiles('known_good.json') }} | |
| restore-keys: | | |
| repos- | |
| - name: Checkout all pinned repositories | |
| id: checkout-repos | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| bazel run //scripts/tooling:checkout_repos | |
| - name: Initialize CodeQL for all repositories | |
| uses: github/codeql-action/init@v4 | |
| with: | |
| languages: cpp | |
| build-mode: none | |
| packs: codeql/misra-cpp-coding-standards@2.57.0 | |
| config-file: ./.github/codeql/codeql-config.yml | |
| - name: Perform CodeQL Analysis | |
| uses: github/codeql-action/analyze@v4 | |
| with: | |
| upload-database: false | |
| output: sarif-results/ | |
| category: "multi-repo-scan" | |
| - name: Cleanup repository checkouts | |
| if: always() | |
| run: | | |
| echo "Cleaning up checked out repositories to free disk space" | |
| rm -rf repos/ | |
| - name: Checkout CodeQL Coding Standards scripts | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: github/codeql-coding-standards | |
| path: codeql-coding-standards-repo | |
| ref: v2.57.0 | |
| - name: Recategorize Guidelines | |
| if: always() | |
| run: | | |
| bazel run //scripts/tooling:recategorize_guidelines | |
| - name: Generate HTML Report from SARIF | |
| run: | | |
| SARIF_FILE="sarif-results/cpp.sarif" | |
| if [ ! -f "$SARIF_FILE" ]; then | |
| echo "Error: SARIF file not found at $SARIF_FILE" | |
| exit 1 | |
| fi | |
| sarif html "$SARIF_FILE" --output codeql-report.html | |
| - name: Upload SARIF results as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: codeql-sarif-results | |
| path: sarif-results/ | |
| - name: Upload HTML Report as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: codeql-html-report | |
| path: codeql-report.html |