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 — Fix computation of fallback version number by henrymercer · Pull Request #1510 · github/codeql-action

Conversation

@henrymercer

@henrymercer henrymercer commented Jan 26, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

This PR addresses a bug where we would compute a fallback version number like 0.0.0-codeql-bundle-20230105 rather than one like 0.0.0-20230105. This happened because we used the tag name 0.0.0-codeql-bundle-20230105 rather than the bundle version 20230105 to compute the fallback version number.

This fallback version number is crucial at the moment, because the controlled switchover changes haven't yet rolled out to the GitHub-hosted runner images, and therefore at the moment, the GitHub-hosted runner images version the CodeQL tools as 0.0.0-20230105 rather than 2.0.0-20230105 (or 2.0.0). So if we get the fallback version number wrong, we end up having to download the bundle from the GitHub Release in most workflows.

The fix is pretty simple — I've split out the tag -> bundle version logic from getBundleVersionFromUrl into a new function getBundleVersionFromTagName and called this in getCodeQLSource when we compute the fallback version. Another approach would have been to call getBundleVersionFromUrl(`/${tagName}/`) but that's a little hacky.

I think part of the reason why this bug happened is that some of our unit tests do too much stuff. So I've rewritten the ones that test lookup to mock the toolcache, rather than using our own logic to install things into the toolcache. This allows us to test fallback versions like 0.0.0-20230105 more easily and readably by separating out concerns. I've removed one of the cases where the bundle is not cached because this is already tested in the "downloads and caches explicitly requested bundles that aren't in the toolcache" test.

  • Example run before — note the following logs:
    ##[debug]Computed a fallback toolcache version number of 0.0.0-codeql-bundle-20230105 for CodeQL tools version 2.12.0.
    ##[debug]isExplicit: 0.0.0-codeql-bundle-20230105
    ##[debug]explicit? true
    ##[debug]checking cache: /opt/hostedtoolcache/CodeQL/0.0.0-codeql-bundle-20230105/x64
    ##[debug]not found
    ##[debug]Did not find CodeQL tools version 2.12.0 in the toolcache.
    
  • Example run after — note that the bundle is now found in the toolcache:
    ##[debug]Computed a fallback toolcache version number of 0.0.0-20230105 for CodeQL tools version 2.12.0.
    ##[debug]isExplicit: 0.0.0-20230105
    ##[debug]explicit? true
    ##[debug]checking cache: /opt/hostedtoolcache/CodeQL/0.0.0-20230105/x64
    ##[debug]Found tool in cache CodeQL 0.0.0-20230105 x64
    ##[debug]CodeQL found in cache /opt/hostedtoolcache/CodeQL/0.0.0-20230105/x64
    

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.

Sorry, something went wrong.

Uh oh!

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

All reactions
henrymercer added 2 commits January 26, 2023 11:49
@henrymercer
Add failing regression test
0a9e9db
@henrymercer
Fix computation of fallback version
75ae065
@henrymercer
henrymercer requested a review from nickfyson January 26, 2023 12:15
@henrymercer
henrymercer requested a review from a team as a code owner January 26, 2023 12:15
@henrymercer
henrymercer enabled auto-merge January 26, 2023 13:30
nickfyson
nickfyson approved these changes Jan 26, 2023
View reviewed changes

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

LGTM

Bug fix itself makes sense, though I have lower confidence in my assessment of the test improvements (all rather unfamiliar) 😅

Sorry, something went wrong.

Uh oh!

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

All reactions
@henrymercer
henrymercer merged commit 43f1a6c into main Jan 26, 2023
@henrymercer
henrymercer deleted the henrymercer/fix-fallback-version-number branch January 26, 2023 14:17
@github-actions github-actions Bot mentioned this pull request Jan 26, 2023
Merge main into releases/v2 #1511
Merged
4 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@nickfyson nickfyson nickfyson approved these changes

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.

2 participants

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