-
Notifications
You must be signed in to change notification settings - Fork 85
Split CodeQL database generation and analysis phases #521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+251
−31
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 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 | ||
| # ******************************************************************************* | ||
|
|
||
| # Workflow: CodeQL analysis — split into database creation and analysis phases. | ||
| # | ||
| # Phase 1 (create-codeql-database): Builds the codebase with CodeQL tracing | ||
| # and produces a reusable CodeQL database artifact. | ||
| # | ||
| # Phase 2 (analysis): Downloads the database and runs CodeQL queries. | ||
| # - PR / push to main: runs the incremental (quick) query set defined in | ||
| # config.yaml, which excludes queries tagged "exclude-from-incremental". | ||
| # - Nightly (schedule): runs the full MISRA pack including slow queries. | ||
| # | ||
| # This split avoids rebuilding the database for each analysis profile and | ||
| # enables running different query sets for PR feedback vs nightly compliance. | ||
| # | ||
| # Reference: https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github | ||
|
|
||
| name: CodeQL Analysis | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '0 2 * * *' # Nightly at 2 AM UTC | ||
| workflow_dispatch: # Allow maintainers to trigger manually when needed | ||
|
|
||
| permissions: | ||
| contents: read | ||
| security-events: write # Required to upload SARIF results to GitHub Code Scanning | ||
|
|
||
| concurrency: | ||
| group: codeql-${{ github.ref }} | ||
| cancel-in-progress: false # Never cancel an in-progress CodeQL run; it takes hours | ||
|
|
||
| env: | ||
| ANDROID_HOME: "" | ||
| ANDROID_SDK_ROOT: "" | ||
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | ||
|
|
||
| jobs: | ||
| # ── Phase 1: Create CodeQL database ────────────────────────────────────── | ||
| create-codeql-database: | ||
| runs-on: ubuntu-24.04 | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Free Disk Space (Ubuntu) | ||
| uses: eclipse-score/more-disk-space@v1 | ||
| with: | ||
| level: 4 | ||
|
|
||
| - name: Setup Bazel | ||
| uses: castler/setup-bazel@cache-optimized | ||
|
|
||
| - name: Allow linux-sandbox | ||
| uses: ./actions/unblock_user_namespace_for_linux_sandbox | ||
|
|
||
| - name: Create CodeQL database | ||
| run: | | ||
| bazel run //quality/static_analysis:codeql_lint -- \ | ||
| --phase create-database \ | ||
| --database-path /var/tmp/codeql_databases/codeql_db \ | ||
| --target //score/message_passing/... //score/mw/com/... | ||
| - name: Upload CodeQL database artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: codeql-database | ||
| path: /var/tmp/codeql_databases/codeql_db | ||
| retention-days: 1 | ||
|
|
||
| # ── Phase 2: Full analysis (nightly) ───────────────────────────────────── | ||
| analyze-nightly: | ||
| needs: create-codeql-database | ||
| runs-on: ubuntu-24.04 | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Free Disk Space (Ubuntu) | ||
| uses: eclipse-score/more-disk-space@v1 | ||
| with: | ||
| level: 4 | ||
|
|
||
| - name: Setup Bazel | ||
| uses: castler/setup-bazel@cache-optimized | ||
|
|
||
| - name: Allow linux-sandbox | ||
| uses: ./actions/unblock_user_namespace_for_linux_sandbox | ||
|
|
||
| - name: Download CodeQL database | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: codeql-database | ||
| path: /var/tmp/codeql_databases/codeql_db | ||
|
|
||
| - name: Run CodeQL analysis (full — all MISRA rules) | ||
| run: | | ||
| bazel run //quality/static_analysis:codeql_lint -- \ | ||
| --phase analyze-database \ | ||
| --database-path /var/tmp/codeql_databases/codeql_db \ | ||
| --output-dir /tmp/codeql-results \ | ||
| --output-prefix codeql-nightly | ||
| - name: Upload SARIF to GitHub Code Scanning | ||
| uses: github/codeql-action/upload-sarif@v4 | ||
| with: | ||
| sarif_file: /tmp/codeql-results/codeql-nightly.sarif | ||
| category: codeql-nightly | ||
|
|
||
| - name: Upload CSV results | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: codeql-csv-results | ||
| path: /tmp/codeql-results/codeql-nightly.csv | ||
| retention-days: 30 | ||
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.