-
Notifications
You must be signed in to change notification settings - Fork 450
Support requesting latest nightly with tools: nightly
#3130
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
Changes from 1 commit
0f4529e
9e8cbee
67427c6
39be66a
48017e9
a25c57c
79e0afb
bd51630
e2e36b1
4901f54
5ab5aef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,8 +33,11 @@ export enum ToolsSource { | |
| } | ||
|
|
||
| export const CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action"; | ||
| const CODEQL_NIGHTLIES_REPOSITORY_OWNER = "dsp-testing"; | ||
| const CODEQL_NIGHTLIES_REPOSITORY_NAME = "codeql-cli-nightlies"; | ||
|
|
||
| const CODEQL_BUNDLE_VERSION_ALIAS: string[] = ["linked", "latest"]; | ||
| const CODEQL_NIGHTLY_TOOLS_INPUTS = ["nightly", "nightly-latest"]; | ||
|
|
||
| function getCodeQLBundleExtension( | ||
| compressionMethod: tar.CompressionMethod, | ||
|
|
@@ -277,6 +280,7 @@ export async function getCodeQLSource( | |
| if ( | ||
| toolsInput && | ||
| !CODEQL_BUNDLE_VERSION_ALIAS.includes(toolsInput) && | ||
| !CODEQL_NIGHTLY_TOOLS_INPUTS.includes(toolsInput) && | ||
| !toolsInput.startsWith("http") | ||
| ) { | ||
| logger.info(`Using CodeQL CLI from local path ${toolsInput}`); | ||
|
mbg marked this conversation as resolved.
|
||
|
|
@@ -331,6 +335,13 @@ export async function getCodeQLSource( | |
| */ | ||
| let url: string | undefined; | ||
|
|
||
| if ( | ||
| toolsInput !== undefined && | ||
| CODEQL_NIGHTLY_TOOLS_INPUTS.includes(toolsInput) | ||
| ) { | ||
| toolsInput = await getNightlyToolsUrl(logger); | ||
| } | ||
|
|
||
| if (forceShippedTools) { | ||
| cliVersion = defaults.cliVersion; | ||
| tagName = defaults.bundleVersion; | ||
|
|
@@ -771,3 +782,35 @@ async function useZstdBundle( | |
| function getTempExtractionDir(tempDir: string) { | ||
| return path.join(tempDir, uuidV4()); | ||
| } | ||
|
|
||
| /** | ||
| * Get the URL of the latest nightly CodeQL bundle. | ||
| */ | ||
| async function getNightlyToolsUrl(logger: Logger) { | ||
| const zstdAvailability = await tar.isZstdAvailable(logger); | ||
| // The nightly is guaranteed to have a zstd bundle | ||
| const compressionMethod = (await useZstdBundle( | ||
| CODEQL_VERSION_ZSTD_BUNDLE, | ||
| zstdAvailability.available, | ||
| )) | ||
| ? "zstd" | ||
| : "gzip"; | ||
|
|
||
| // Since nightlies are prereleases, we can't just download the latest release | ||
| // on the repository. So instead we need to find the latest pre-release | ||
| // version and construct the download URL from that. | ||
| const release = await api.getApiClient().rest.repos.listReleases({ | ||
| owner: CODEQL_NIGHTLIES_REPOSITORY_OWNER, | ||
| repo: CODEQL_NIGHTLIES_REPOSITORY_NAME, | ||
| per_page: 1, | ||
| page: 1, | ||
| prerelease: true, | ||
| }); | ||
|
henrymercer marked this conversation as resolved.
Outdated
|
||
|
|
||
| const latestRelease = release.data[0]; | ||
| if (!latestRelease) { | ||
| throw new Error("Could not find latest nightly release."); | ||
|
henrymercer marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| return `https://github.com/${CODEQL_NIGHTLIES_REPOSITORY_OWNER}/${CODEQL_NIGHTLIES_REPOSITORY_NAME}/releases/download/${latestRelease.tag_name}/${getCodeQLBundleName(compressionMethod)}`; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to look through the release artifacts and search for the one we want, like we do for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could do but using the http URL is closer to how users would specify a bundle with the |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.