| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -752,7 +752,10 @@ test.serial( | |||
| 752 | 752 | logger, | |
| 753 | 753 | features, | |
| 754 | 754 | }); | |
| 755 | - const info = await startProxyExports.getDownloadUrl(state); | ||
| 755 | + const info = await startProxyExports.getDownloadUrl( | ||
| 756 | + state, | ||
| 757 | + SAMPLE_DOTCOM_API_DETAILS, | ||
| 758 | + ); | ||
| 756 | 759 | ||
| 757 | 760 | t.is(info.version, startProxyExports.UPDATEJOB_PROXY_VERSION); | |
| 758 | 761 | t.is( | |
@@ -778,7 +781,10 @@ test.serial( | |||
| 778 | 781 | await withTmpDir(async (tempDir) => { | |
| 779 | 782 | const features = mockOfflineFeatures(tempDir, logger); | |
| 780 | 783 | const state = initAllState({ logger, features }); | |
| 781 | - const info = await startProxyExports.getDownloadUrl(state); | ||
| 784 | + const info = await startProxyExports.getDownloadUrl( | ||
| 785 | + state, | ||
| 786 | + SAMPLE_DOTCOM_API_DETAILS, | ||
| 787 | + ); | ||
| 782 | 788 | ||
| 783 | 789 | t.is(info.version, startProxyExports.UPDATEJOB_PROXY_VERSION); | |
| 784 | 790 | t.is( | |
@@ -803,7 +809,10 @@ test.serial( | |||
| 803 | 809 | ||
| 804 | 810 | for (const assets of testAssets) { | |
| 805 | 811 | const stub = mockGetReleaseByTag(assets); | |
| 806 | - const info = await startProxyExports.getDownloadUrl(state); | ||
| 812 | + const info = await startProxyExports.getDownloadUrl( | ||
| 813 | + state, | ||
| 814 | + SAMPLE_DOTCOM_API_DETAILS, | ||
| 815 | + ); | ||
| 807 | 816 | ||
| 808 | 817 | t.is(info.version, startProxyExports.UPDATEJOB_PROXY_VERSION); | |
| 809 | 818 | t.is( | |
@@ -833,7 +842,10 @@ test.serial("getDownloadUrl returns matching release asset", async (t) => { | |||
| 833 | 842 | ||
| 834 | 843 | await withTmpDir(async (tempDir) => { | |
| 835 | 844 | const features = mockOfflineFeatures(tempDir, logger); | |
| 836 | - const info = await startProxyExports.getDownloadUrl({ ...state, features }); | ||
| 845 | + const info = await startProxyExports.getDownloadUrl( | ||
| 846 | + { ...state, features }, | ||
| 847 | + SAMPLE_DOTCOM_API_DETAILS, | ||
| 848 | + ); | ||
| 837 | 849 | ||
| 838 | 850 | t.is(info.version, defaults.cliVersion); | |
| 839 | 851 | t.is(info.url, "url-we-want"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,10 +9,12 @@ import { | |||
| 9 | 9 | getApiDetails, | |
| 10 | 10 | getGitHubVersion, | |
| 11 | 11 | InstanceApiClient, | |
| 12 | + type GitHubApiDetails, | ||
| 12 | 13 | } from "./api-client"; | |
| 13 | 14 | import * as artifactScanner from "./artifact-scanner"; | |
| 14 | 15 | import { Config } from "./config-utils"; | |
| 15 | 16 | import * as defaults from "./defaults.json"; | |
| 17 | + import type { ReadOnlyEnv } from "./environment"; | ||
| 16 | 18 | import { | |
| 17 | 19 | CodeQLDefaultVersionInfo, | |
| 18 | 20 | Feature, | |
@@ -395,8 +397,12 @@ export function getFallbackUrl(proxyPackage: string): string { | |||
| 395 | 397 | * | |
| 396 | 398 | * @returns The response from the GitHub API. | |
| 397 | 399 | */ | |
| 398 | - async function getReleaseByVersion(version: string) { | ||
| 399 | - return getApiClient().rest.repos.getReleaseByTag({ | ||
| 400 | + async function getReleaseByVersion( | ||
| 401 | + env: ReadOnlyEnv, | ||
| 402 | + apiDetails: GitHubApiDetails, | ||
| 403 | + version: string, | ||
| 404 | + ) { | ||
| 405 | + return getApiClient(env, apiDetails).rest.repos.getReleaseByTag({ | ||
| 400 | 406 | owner: "github", | |
| 401 | 407 | repo: "codeql-action", | |
| 402 | 408 | tag: version, | |
@@ -419,7 +425,8 @@ async function getCliVersionFromFeatures( | |||
| 419 | 425 | * @returns Returns the download URL and version of the proxy package we plan to use. | |
| 420 | 426 | */ | |
| 421 | 427 | export async function getDownloadUrl( | |
| 422 | - action: ActionState<["Base", "Logger", "FeatureFlags"]>, | ||
| 428 | + action: ActionState<["Base", "ReadOnlyEnv", "Logger", "FeatureFlags"]>, | ||
| 429 | + apiDetails: GitHubApiDetails, | ||
| 423 | 430 | ): Promise<{ url: string; version: string }> { | |
| 424 | 431 | // Default to linux64 if we don't recognise the platform+arch pair. | |
| 425 | 432 | // This maintains the behaviour we had before switching to `getBundlePlatform` here. | |
@@ -448,7 +455,11 @@ export async function getDownloadUrl( | |||
| 448 | 455 | }; | |
| 449 | 456 | ||
| 450 | 457 | // Try to retrieve information about the CLI bundle release identified by `versionInfo`. | |
| 451 | - const cliRelease = await getReleaseByVersion(versionInfo.tagName); | ||
| 458 | + const cliRelease = await getReleaseByVersion( | ||
| 459 | + action.env, | ||
| 460 | + apiDetails, | ||
| 461 | + versionInfo.tagName, | ||
| 462 | + ); | ||
| 452 | 463 | ||
| 453 | 464 | // Search the release's assets to find the one we are looking for. | |
| 454 | 465 | for (const asset of cliRelease.data.assets) { | |
@@ -569,13 +580,13 @@ export function getProxyFilename() { | |||
| 569 | 580 | * @returns The path to the proxy binary. | |
| 570 | 581 | */ | |
| 571 | 582 | export async function getProxyBinaryPath( | |
| 572 | - action: ActionState<["Base", "Logger", "FeatureFlags"]>, | ||
| 583 | + action: ActionState<["Base", "ReadOnlyEnv", "Logger", "FeatureFlags"]>, | ||
| 573 | 584 | ): Promise<string> { | |
| 574 | 585 | const logger = action.logger; | |
| 575 | 586 | const apiDetails = getApiDetails(); | |
| 576 | 587 | const client = new InstanceApiClient(apiDetails); | |
| 577 | 588 | const proxyFileName = getProxyFilename(); | |
| 578 | - const proxyInfo = await getDownloadUrl(action); | ||
| 589 | + const proxyInfo = await getDownloadUrl(action, apiDetails); | ||
| 579 | 590 | ||
| 580 | 591 | let proxyBin = toolcache.find(proxyFileName, proxyInfo.version); | |
| 581 | 592 | if (!proxyBin) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments