Skip to content
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

Respect exclude-from-incremental query tag for diff-informed analysis #2831

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

cklin
Copy link
Contributor

@cklin cklin commented Mar 27, 2025

This PR changes the action to add the following settings to the Code Scanning configuration file when performing diff-informed analysis:

query-filters:
    - exclude:
        tags: exclude-from-incremental

Code Scanning configuration file for non-diff-informed analysis remains unchanged.

Commit-by-commit review recommended. The first few commits are preparatory; they change code structure while preserving existing code behavior. The second-last commit adds the new functionality, and the last commit rebuilds the js files.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

cklin added 6 commits March 27, 2025 10:27
This commit adds a defaultQueryFilters field to AugmentationProperties
and incorporates its value into the augmented Code Scanning config.
However, in this commit defaultQueryFilters is always empty, so there is
not yet any actual behavior change.
@cklin cklin force-pushed the cklin/diff-informed-query-filtering branch from 4e9ec05 to 1a1a4f3 Compare March 27, 2025 21:23
@cklin cklin marked this pull request as ready for review March 27, 2025 21:35
@Copilot Copilot bot review requested due to automatic review settings March 27, 2025 21:35
@cklin cklin requested a review from a team as a code owner March 27, 2025 21:35
Copy link
Contributor

@Copilot Copilot AI left a 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 ensures that diff-informed analysis respects the "exclude-from-incremental" query tag by adding a default query filter when running on pull requests. It updates the configuration augmentation logic and replaces the legacy diff filtering utilities with the new diff-informed analysis utilities.

  • Updated import paths and usage of diff utilities across the codebase.
  • Modified the augmentation logic to conditionally add a query filter.
  • Adjusted tests to account for the new asynchronous behavior and defaultQueryFilters property.

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/upload-lib.ts Updated import to use diff-informed analysis utils.
src/diff-informed-analysis-utils.ts Added new diff utility functions and removal of diff-filtering-utils.
src/diff-filtering-utils.ts Removed legacy diff filtering functionality.
src/config-utils.ts Updated calculateAugmentation to be asynchronous and add defaultQueryFilters.
src/config-utils.test.ts Modified tests to include the new defaultQueryFilters property.
src/codeql.ts Merged defaultQueryFilters into the Code Scanning config generation.
src/analyze.ts Adjusted diff analysis function calls to use the new utilities.
src/analyze-action.ts Updated diff-informed query run call logic with branches check.
lib/upload-lib.js Updated import path for diff-informed analysis utilities.
lib/diff-informed-analysis-utils.js Added new diff utility functions and exported shouldPerformDiffInformedAnalysis.
lib/config-utils.test.js Test adjustments for asynchronous augmentation calculation.
lib/config-utils.js Updated calculateAugmentation to async and integrated defaultQueryFilters.
lib/codeql.js Injected defaultQueryFilters into the augmented Code Scanning config.
lib/analyze.js Replaced legacy diff utility usage with the new diff-informed approaches.
lib/analyze-action.js Adjusted diff-informed analysis setup to use branch information.

Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more

angelapwen
angelapwen previously approved these changes Mar 28, 2025
Copy link
Contributor

@angelapwen angelapwen left a comment

Choose a reason for hiding this comment

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

Logic looks 👍!

Non-blocking nit: could shouldPerformDiffInformedQueries return a boolean and then the branches value be returned elsewhere? Or alternatively maybe we could rename the function something even longer and gnarlier, like getBranchesIfDiffInformedQueriesEnabled 😬

@henrymercer
Copy link
Contributor

Yeah, or just checkDiffInformedQueries — we don't have to explain the return type in the function name, but should is usually associated with a boolean return type.

cklin added 2 commits March 28, 2025 12:29
This commit renames the original shouldPerformDiffInformedAnalysis(),
which returns `PullRequestBranches | undefined`, to
getDiffInformedAnalysisBranches(). It also adds a new
shouldPerformDiffInformedAnalysis() function that returns boolean.

Separating these two functions makes it clear what the intended uses and
return values should be for each.
@cklin cklin force-pushed the cklin/diff-informed-query-filtering branch from 1a1a4f3 to e4ca874 Compare March 28, 2025 19:30
@cklin
Copy link
Contributor Author

cklin commented Mar 28, 2025

Thank you for your suggestions @angelapwen and @henrymercer!

I updated the PR, and there are now two helper functions.

  • shouldPerformDiffInformedAnalysis() returns Promise<boolean>
  • getDiffInformedAnalysisBranches() returns Promise<PullRequestBranches | undefined>

@cklin cklin requested a review from angelapwen March 28, 2025 19:32
Copy link
Contributor

@angelapwen angelapwen left a comment

Choose a reason for hiding this comment

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

Thank you 🙇‍♀️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants