-
Notifications
You must be signed in to change notification settings - Fork 494
Improve connection tests #3853
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 connection tests #3853
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
/v3/index.json for NuGet feed check
- Loading branch information
There are no files selected for viewing
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 |
|---|---|---|
|
|
@@ -7,6 +7,35 @@ import { getErrorMessage } from "../util"; | |
|
|
||
| import { getAddressString, ProxyInfo, Registry } from "./types"; | ||
|
|
||
| /** Represents registry-specific connection test configurations. */ | ||
| export interface ConnectionTestConfig { | ||
|
mbg marked this conversation as resolved.
|
||
| /** An optional path to append to the end of the base url. */ | ||
| path?: string; | ||
| } | ||
|
|
||
| /** A partial mapping of registry types to extra connection test configurations. */ | ||
| export const connectionTestConfig: Partial< | ||
| Record<string, ConnectionTestConfig> | ||
| > = { | ||
| nuget_feed: { path: "v3/index.json" }, | ||
|
Contributor
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. I presume v3 is old enough that we can rely on this existing / the proxy only supports v3 anyway?
Member
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. AFAIK nothing else exists. I.e. I am not aware that |
||
| }; | ||
|
|
||
| /** | ||
| * Applies the registry-specific check configuration to the base URL, if any and applicable. | ||
| */ | ||
| export function makeTestUrl( | ||
| config: ConnectionTestConfig | undefined, | ||
| base: URL, | ||
| ): URL { | ||
| if (config?.path === undefined) { | ||
| return base; | ||
| } | ||
| if (base.pathname.endsWith(config.path)) { | ||
| return base; | ||
| } | ||
| return new url(/sitelet?url=https%3A%2F%2Fgithub.com%2Fgithub%2Fcodeql-action%2Fpull%2F3853%2Fcommits%2Fconfig.path%2C%2520base); | ||
| } | ||
|
|
||
| export class ReachabilityError extends Error { | ||
| constructor(public readonly statusCode?: number | undefined) { | ||
| super(); | ||
|
|
@@ -92,6 +121,7 @@ export async function checkConnections( | |
| } | ||
|
|
||
| for (const registry of proxy.registries) { | ||
| const config = connectionTestConfig[registry.type]; | ||
| const address = getAddressString(registry); | ||
| const url = URL.parse(address); | ||
|
|
||
|
|
@@ -102,9 +132,11 @@ export async function checkConnections( | |
| continue; | ||
| } | ||
|
|
||
| const testUrl = makeTesturl(/sitelet?url=https%3A%2F%2Fgithub.com%2Fgithub%2Fcodeql-action%2Fpull%2F3853%2Fcommits%2Fconfig%2C%2520url); | ||
|
|
||
| try { | ||
| logger.debug(`Testing connection to ${url}...`); | ||
| const statusCode = await backend.checkConnection(url); | ||
| const statusCode = await backend.checkConnection(testUrl); | ||
|
|
||
| logger.info(`Successfully tested connection to ${url} (${statusCode})`); | ||
| result.add(registry); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.