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

Improve logs for combined SARIF debug artifact #2762

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

henrymercer
Copy link
Contributor

Avoid starting a "Uploading combined SARIF debug artifact" log group if we aren't going to do the upload.

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.

Don't start a "Uploading combined SARIF debug artifact" log group if we aren't going to do the upload.
@Copilot Copilot bot review requested due to automatic review settings February 12, 2025 16:27
@henrymercer henrymercer requested a review from a team as a code owner February 12, 2025 16:27
Copy link

@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.

PR Overview

This PR improves logging for the combined SARIF debug artifact upload process by ensuring that a log group is only created when an upload is actually attempted. The changes remove the redundant withGroup wrapping in the analyze-action-post files and move the log grouping logic inside the uploadCombinedSarifArtifacts functions in both the src and lib locations.

  • Removed withGroup import and call from analyze-action-post files.
  • Added withGroup wrapping in uploadCombinedSarifArtifacts functions in both JavaScript and TypeScript implementations.
  • Ensured that the log group is triggered only when the CODEQL_ACTION_DEBUG_COMBINED_SARIF environment variable is set.

Changes

File Description
src/analyze-action-post.ts Removed withGroup usage to avoid creating an unnecessary log group.
lib/debug-artifacts.js Added withGroup wrapping inside uploadCombinedSarifArtifacts to control logging.
src/debug-artifacts.ts Added withGroup wrapping inside uploadCombinedSarifArtifacts to control logging.
lib/analyze-action-post.js Removed the withGroup wrapping for consistency with the refactored logic.

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more

.filter((f) => f.endsWith(".sarif"));
for (const sarifFile of sarifFiles) {
toUpload.push(path.resolve(baseTempDir, outputDir, sarifFile));
await (0, logging_1.withGroup)("Uploading combined SARIF debug artifact", async () => {
Copy link
Preview

Copilot AI Feb 12, 2025

Choose a reason for hiding this comment

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

Consider checking if there are artifacts to upload (for example, verifying that the 'toUpload' array is non-empty) before starting the log group, so that empty log groups are not created.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
logger.info(
"Uploading available combined SARIF files as Actions debugging artifact...",
);
await withGroup("Uploading combined SARIF debug artifact", async () => {
Copy link
Preview

Copilot AI Feb 12, 2025

Choose a reason for hiding this comment

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

Consider verifying that there are artifacts to upload prior to initiating the log group to fully align with the goal of avoiding empty log groups when no upload occurs.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Contributor

Choose a reason for hiding this comment

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

Kind of a fair comment — we could log this only after checking if toUpload isn't empty in ~line 69.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the way it's currently set up I believe we'll see a log warning if toUpload is empty, as we expect it to contain at least something. There are definitely further improvements we could make to the code but I think I'll leave it as is for now.

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.

Bikeshedding with Copilot 🤖 but I think this is good as is!

logger.info(
"Uploading available combined SARIF files as Actions debugging artifact...",
);
await withGroup("Uploading combined SARIF debug artifact", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Kind of a fair comment — we could log this only after checking if toUpload isn't empty in ~line 69.

@henrymercer henrymercer merged commit 1c15a48 into main Feb 12, 2025
267 checks passed
@henrymercer henrymercer deleted the henrymercer/debug-upload-nit branch February 12, 2025 20:49
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.

2 participants