GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allow Code Quality only analysis by mbg · Pull Request #3064 · github/codeql-action

Conversation

@mbg

@mbg mbg commented Aug 28, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This is a first stab at enabling Code Quality analysis to be able to run on its own, while also maintaining the ability for it to run in addition to a Code Scanning analysis.

Fundamentally, this means that there are two separate ways in which Code Quality analysis can run:

  1. The existing "add-on" implementation, where the database is initialised for Code Scanning, and we inject the code-quality suite into the run-queries call. The Code Quality SARIF is then generated by an extra call to interpret-results.
  2. The new "standalone" implementation, where the database is initialised for Code Quality by disabling default queries and configuring the database with code-quality queries.

43d9bc8 and 5d95d46 implement the bulk of the changes needed for the "add-on" implementation that result from needing to check whether Code Quality is enabled in addition to or instead of Code Scanning.

1746aed implements the bulk of the changes needed for the "standalone" implementation. Concretely, this checks whether Code Quality is enabled on its own, and then mutates the configuration as necessary.

Probably best reviewed commit-by-commit.

Risk assessment

For internal use only. Please select the risk level of this change:

  • High risk: Changes are not fully under feature flags, have limited visibility and/or cannot be tested outside of production.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Consider adding a changelog entry for this change.
  • Confirm the readme and docs have been updated if necessary.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
github-advanced-security[bot]
github-advanced-security AI found potential problems Aug 28, 2025
View reviewed changes
Comment thread src/analyze.ts Fixed

Uh oh!

There was an error while loading. Please reload this page.

@mbg
mbg force-pushed the mbg/cq/allow-cq-only-analysis branch 4 times, most recently from e28ecb0 to 603a572 Compare September 1, 2025 15:17
@mbg
mbg marked this pull request as ready for review September 1, 2025 15:17
@mbg
mbg requested a review from a team as a code owner September 1, 2025 15:17
@mbg
mbg requested review from Copilot and henrymercer September 1, 2025 15:17

This comment was marked as outdated.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mbg
mbg force-pushed the mbg/cq/allow-cq-only-analysis branch from 5b9c46f to a99145b Compare September 1, 2025 15:47
henrymercer
henrymercer reviewed Sep 1, 2025
View reviewed changes
Comment thread src/config-utils.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/config-utils.ts Outdated
Comment on lines +1140 to +1142
logger.warning(
"Query customizations will be ignored, because only `code-quality` analysis is enabled.",
);

@henrymercer henrymercer Sep 1, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we actually error in these cases? It's easy to miss Actions warnings, and users could think they're analysing something that doesn't actually work. That also avoids us the slight confusion of then having to override config.originalUserInput.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mbg mbg Sep 1, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure about this, but decided to go with a warning because in Default Setup we provide inputs to queries and config. We can probably change that there for when Code Quality is enabled, but Code Scanning isn't, but I didn't want to make this an error just yet in case it causes us problems during the transition there.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@henrymercer henrymercer Sep 1, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate wanting to make the transition smooth, but I have some concerns about modifying config.originalUserInput, particularly since we use this to generate telemetry.

My understanding is today we have analyses with a quality-queries input and without an analysis-kinds input. This means we'll run code scanning, and therefore shouldn't hit this case. Then the transition can move to an explicit analysis-kinds input with the config and other customization inputs removed.

Is there anything I'm missing here?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mbg mbg Sep 1, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are two separate points here:

  1. Whether we can swap over from using quality-queries to analysis-kinds and remove the queries input in CQ-only mode in one go. (Probably "yes" and this being a warning is just overly defensive.)
  2. That modifying config.originalUserInput is an issue for telemetry.

Regarding 2., I agree that this isn't a very nice approach. I'll have a look at refactoring this tomorrow so that originalUserInput can remain as-is and we set up the configuration for a CQ-only database differently.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/upload-lib.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/config-utils.ts Outdated
*
* @returns Returns `CodeScanning` if `AnalysisKind.CodeScanning` is enabled; otherwise `CodeQuality`.
*/
export function getDbAnalysisConfig(config: Config): AnalysisConfig {

@henrymercer henrymercer Sep 1, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a detail of how saving SARIF results currently works, in particular the fact that when both modes are on, we currently produce a code scanning file, then filter that to produce a code quality file. I don't really think it's a property of the database, since we'll ask the database to analyse both code scanning and code quality results in that situation.

I'd consider removing this in favour of some more explicit logic concerning the SARIF extension in analyze, unless there are more situations where this notion of "primary consumer" matters.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mbg mbg Sep 1, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a detail of how saving SARIF results currently works, in particular the fact that when both modes are on, we currently produce a code scanning file, then filter that to produce a code quality file. I don't really think it's a property of the database, since we'll ask the database to analyse both code scanning and code quality results in that situation.

I don't think this is true, since in CQ-only mode the database is specifically initialised with code-quality queries. What getDbAnalysisConfig tells us is whether the database is initialised with a Code Scanning configuration (in CS only or CS+CQ mode) or a Code Quality configuration (in CQ only mode).

It's true though that this is currently only relevant when we are generating the "primary" SARIF file.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@henrymercer henrymercer Sep 1, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is true, since in CQ-only mode the database is specifically initialised with code-quality queries. What getDbAnalysisConfig tells us is whether the database is initialised with a Code Scanning configuration (in CS only or CS+CQ mode) or a Code Quality configuration (in CQ only mode).

I'm unsure how much meaning this has in practice. For instance, if I really wanted to, I could create a code scanning configuration that runs the code quality queries only by disabling the default queries and running a custom query pack. I'd expect the database to be identical to a database with analysis-kinds: code-quality. The only difference I can see is the name of the SARIF file and the upload API.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
This was referenced Sep 2, 2025
Fix missing/wrong properties in createTestConfig #3071
Merged
Overlay databases: Use Config instead of AugmentationProperties #3072
Merged
Hard-code quality queries #3074
Merged
mbg added 15 commits September 4, 2025 11:38
@mbg
Update checks to use analysis-kinds instead of quality-queries
434df8e
@mbg
Add utility function to check if code scanning is enabled
85a4853
@mbg
Move UploadTarget definitions to analyses.ts
ca7dd4a
@mbg
Rename UploadTarget to AnalysisConfig
0162708
@mbg
Add kind property to AnalysisConfig and documentation
cb8f28f
@mbg
Only specify queries for run-queries if both analysis kinds are ena…
e4ffe6f
…bled
@mbg
Handle different permutations of analysis kinds in analyze action
ff57bbf
@mbg
Add note for getPerQueryAlertCounts
6d2d204
@mbg
Add sarifExtension field to AnalysisConfig
04bb074
@mbg
Add and use helpers for determining analysis config the DB is initial…
8ea50b8
…ised with
@mbg
Add test with analysisKindsInput: code-quality
244e04c
@mbg
Move isDefined from start-proxy to util
811aef8
@mbg
Override query configuration for Code Quality only analyses
01fe6a1
@mbg
Fix addSarifExtension and add tests
86275f6
@mbg
Check if Code Scanning is enabled before uploading Code Scanning SARIF
7baedbc
mbg added 2 commits September 4, 2025 11:44
@mbg
Update condition and comment for CQ-only config
3ee9287
@mbg
Remove default arguments from uploadSpecifiedFiles and `validateUni…
51d74ac
…queCategory`
Copilot AI review requested due to automatic review settings September 4, 2025 10:48
@mbg
mbg force-pushed the mbg/cq/allow-cq-only-analysis branch from f8915bb to d2e5cc8 Compare September 4, 2025 10:49
@mbg
Do not mutate originalUserInput
f4fca70
Copilot AI reviewed Sep 4, 2025
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the ability to run Code Quality analysis independently from Code Scanning analysis, while maintaining backwards compatibility for combined analysis. The main purpose is to provide a "standalone" implementation where the database can be initialized specifically for Code Quality analysis by disabling default queries and configuring quality-specific queries.

Key changes include:

  • Refactored upload targets into a new analyses.ts module with dedicated configurations for both Code Scanning and Code Quality
  • Added logic to detect when only Code Quality analysis is enabled and configure the database accordingly
  • Updated upload functions to use the new analysis configuration objects

Reviewed Changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/analyses.ts New module defining analysis configurations and endpoints for Code Scanning and Code Quality
src/config-utils.ts Enhanced with functions to determine database analysis kind and handle Code Quality-only configurations
src/util.ts Added isDefined utility function for type narrowing
src/upload-lib.ts Refactored to use new analysis configurations instead of hardcoded upload targets
src/analyze.ts Updated SARIF file generation logic to handle different analysis configurations
Various test files Updated test cases to use new analysis configuration objects
Workflow files Updated to use analysis-kinds input instead of deprecated quality-queries

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/analyses.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

mbg added 3 commits September 4, 2025 12:03
@mbg
Make code that builds the list of queries for run-queries more robu…
ae2df70
…st in the event of future changes
@mbg
Make conditions for interpret-results more robust
d08e9a2
@mbg
Add runInterpretResultsFor to de-duplicate code for `interpret-resu…
38f1a70
…lts`
@mbg
mbg force-pushed the mbg/cq/allow-cq-only-analysis branch from d2e5cc8 to 38f1a70 Compare September 4, 2025 11:26
@mbg
mbg requested a review from henrymercer September 4, 2025 16:44
mbg added 3 commits September 5, 2025 12:35
@mbg
Matrix over analysis-kinds in quality-queries check
6d0bcea
@mbg
Rename getDbAnalysisKind and getDbAnalysisConfig
5d822f1
@mbg
Throw an error if query customisations are enabled for a `code-qualit…
918e792
…y`-only analysis
@mbg
mbg force-pushed the mbg/cq/allow-cq-only-analysis branch from 1ff29bf to 7916994 Compare September 5, 2025 13:04
@mbg
Fix: Include matrix.analysis-kinds in artifact names
e75b5d3
@mbg
mbg force-pushed the mbg/cq/allow-cq-only-analysis branch from 7916994 to e75b5d3 Compare September 5, 2025 13:27
henrymercer
henrymercer approved these changes Sep 8, 2025
View reviewed changes
@mbg
mbg merged commit 0a56aad into main Sep 8, 2025
@mbg
mbg deleted the mbg/cq/allow-cq-only-analysis branch September 8, 2025 15:13
@github-actions github-actions Bot mentioned this pull request Sep 9, 2025
Merge main into releases/v3 #3090
Merged
5 of 8 tasks
krsjenswbp
krsjenswbp reviewed Sep 11, 2025
View reviewed changes

@krsjenswbp krsjenswbp left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mbg mbg mentioned this pull request Sep 18, 2025
Fix upload-sarif Action failing if there are no Code Scanning SARIF files #3123
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@henrymercer henrymercer henrymercer approved these changes
+1 more reviewer
@krsjenswbp krsjenswbp krsjenswbp left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@mbg @henrymercer @github-advanced-security @krsjenswbp
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.