Repository navigation
Conversation
362e7d4 to
cd87ccd
Compare
cd87ccd to
133ffeb
Compare
| test.serial("getCodeQLActionRepository", (t) => { | ||
| const logger = getRunnerLogger(true); | ||
|
|
||
| test.serial("getCodeQLActionRepository", async (t) => { |
There was a problem hiding this comment.
Can this now be run in parallel with other tests?
There was a problem hiding this comment.
Ah, I see it can't because initializeEnvironment updates process.env directly.
There was a problem hiding this comment.
Well, it goes via exportVariable, which we know is causing problems in tests since we never resolved the issue that #3930 aims to address.
That PR predates ActionState, so maybe it's worth reviving that effort with a suitable method on the Env or Actions states. What do you think?
There was a problem hiding this comment.
That PR predates
ActionState, so maybe it's worth reviving that effort with a suitable method on theEnvorActionsstates. What do you think?
Sounds good to me.
| /**A download source is a pair of strings. */ | ||
| export type DownloadSource = [string, string]; |
There was a problem hiding this comment.
Could this be something like [DownloadURL, RepositoryNwo] instead (both of which could still be typed as strings)?
| ): Promise<DownloadURL> { | ||
| const codeQLActionRepository = getCodeQLActionRepository(action); | ||
|
|
||
| const potentialDownloadSources: Array<[string, string]> = [ |
There was a problem hiding this comment.
Why not DownloadSource[]?
| }, | ||
| ); | ||
|
|
||
| for (const [apiURL, repository] of uniqueDownloadSources) { |
There was a problem hiding this comment.
This is just a URL, not an API URL, i.e. it doesn't start with api.
| /** | ||
| * Asserts that `stub` must have been called once with at least the `expected` arguments. | ||
| */ | ||
| onceWith: <TArgs extends readonly any[]>( |
There was a problem hiding this comment.
Beyond your later fix in f9a9962, I think this should just be calledWith, since unlike calledOnce / calledOnceWithExactly / calledOnceWithMatch we don't validate that the stub was only called once.
| export type DownloadURL = string; | ||
|
|
||
| /** Gets the default GitHub.com download URL for `assetName` in a release tagged `tagName`. */ | ||
| export function getDefaultDotComDownloadURL( |
There was a problem hiding this comment.
Nit: elsewhere, we use Dotcom
| @@ -569,15 +533,15 @@ | |||
| * @returns The path to the proxy binary. | |||
| */ | |||
| export async function getProxyBinaryPath( | |||
There was a problem hiding this comment.
Consider creating a log group for the download step and including more progress information in the logs. In the PR check for instance "The CodeQL Action is checked out locally. Using the default CodeQL Action repository." is logged, and there's an untar, but it's unclear to most users what's going on.
henrymercer
left a comment
There was a problem hiding this comment.
Couple of additional comments
| /** Types that all of our logging functions accept. */ | ||
| export type Loggable = string | string[]; |
There was a problem hiding this comment.
Looking back at this after a commit-by-commit review, does anything use this? If not, let's remove it.
| ); | ||
|
|
||
| for (const [apiURL, repository] of uniqueDownloadSources) { | ||
| // If we've reached the final case, short-circuit the API check since we know the bundle exists and is public. |
There was a problem hiding this comment.
Nit: update this comment to refer to an "asset"
| try { | ||
| // Download the proxy archive from `url`. We let `downloadTool` choose where | ||
| // to store it. The path to the downloaded file will be returned if successful. | ||
| return toolcache.downloadTool(url, /* dest: */ undefined, authorization, { |
There was a problem hiding this comment.
Should this be awaited (so the try catches errors that happen asynchronously)?
| SAMPLE_DOTCOM_API_DETAILS, | ||
| ); | ||
|
|
||
| t.is(getReleaseByTag.callCount, 1); |
There was a problem hiding this comment.
An existing issue to some extent, but because mockGetReleaseByTag returns the result of mockGetApiClient, this is actually asserting the number of calls to getApiClient.
| st.onceWith(extractTar, archivePath); | ||
| st.onceWith(cacheDir, extractedPath); | ||
|
|
||
| t.assert(extractTar.calledOnceWith(archivePath)); | ||
| t.assert(cacheDir.calledOnceWith(extractedPath)); |
There was a problem hiding this comment.
There's some duplication here
| test.serial("getCodeQLActionRepository", (t) => { | ||
| const logger = getRunnerLogger(true); | ||
|
|
||
| test.serial("getCodeQLActionRepository", async (t) => { |
There was a problem hiding this comment.
Ah, I see it can't because initializeEnvironment updates process.env directly.
| tagName: string, | ||
| assetName: string, | ||
| ): DownloadURL { | ||
| return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${tagName}/${assetName}`; |
There was a problem hiding this comment.
Nit: we could use GITHUB_DOTCOM_URL here.
The
start-proxyAction currently uses its owngetReleaseByVersionfunction to get hold of the release that we expect to find the proxy assets at. That function has hard-codedownerandrepovalues for the defaultgithub/codeql-actionrepository. This repository may not be available in all environments. In such environments,getReleaseByVersionfails and we fall-back to the hard-coded release obtained fromgetFallbackUrlinstead.Broadly, this PR does the following:
getCodeQLActionRepositoryandgetCodeQLBundleDownloadURLare refactored out ofsetup-codeqlinto a newsetup/repositorymodule.getCodeQLAssetDownloadURL(renamed fromgetCodeQLBundleDownloadURL) in thestart-proxyaction to apply the same logic for finding a suitable release as used bysetup-codeql.getCodeQLBundleDownloadURLis essentially equivalent, except that it uses the linked version rather than a hard-coded one. We have been shipping proxy artifacts successfully with releases for a good while now, so the fallback shouldn't be needed anymore.There are some drive-by improvements to logging and assertions for sinon stubs.
Risk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
Workflow types:
dynamicworkflows (Default Setup, Code Quality, ...).Products:
analysis-kinds: code-scanning.analysis-kinds: code-quality.Environments:
github.comand/or GitHub Enterprise Cloud with Data Residency.How did/will you validate this change?
.test.tsfiles).pr-checks).If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist