Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions lib/entry-points.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions lib/upload-lib.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export enum Feature {
QaTelemetryEnabled = "qa_telemetry_enabled",
/** Note that this currently only disables baseline file coverage information. */
SkipFileCoverageOnPrs = "skip_file_coverage_on_prs",
StartProxyRemoveUnusedRegistries = "start_proxy_remove_unused_registries",
StartProxyUseFeaturesRelease = "start_proxy_use_features_release",
UploadOverlayDbToApi = "upload_overlay_db_to_api",
ValidateDbConfig = "validate_db_config",
Expand Down Expand Up @@ -365,11 +364,6 @@ export const featureConfig = {
minimumVersion: undefined,
toolsFeature: ToolsFeature.SuppressesMissingFileBaselineWarning,
},
[Feature.StartProxyRemoveUnusedRegistries]: {
defaultValue: false,
envVar: "CODEQL_ACTION_START_PROXY_REMOVE_UNUSED_REGISTRIES",
minimumVersion: undefined,
},
[Feature.StartProxyUseFeaturesRelease]: {
defaultValue: false,
envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE",
Expand Down
8 changes: 1 addition & 7 deletions src/start-proxy-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as core from "@actions/core";

import * as actionsUtil from "./actions-util";
import { getGitHubVersion } from "./api-client";
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
import { FeatureEnablement, initFeatures } from "./feature-flags";
import { BuiltInLanguage, parseBuiltInLanguage } from "./languages";
import { getActionsLogger, Logger } from "./logging";
import { getRepositoryNwo } from "./repository";
Expand Down Expand Up @@ -57,18 +57,12 @@ async function run(startedAt: Date) {
const languageInput = actionsUtil.getOptionalInput("language");
language = languageInput ? parseBuiltInLanguage(languageInput) : undefined;

// Query the FF for whether we should use the reduced registry mapping.
const skipUnusedRegistries = await features.getValue(
Feature.StartProxyRemoveUnusedRegistries,
);

// Get the registry configurations from one of the inputs.
const credentials = getCredentials(
logger,
actionsUtil.getOptionalInput("registry_secrets"),
actionsUtil.getOptionalInput("registries_credentials"),
language,
skipUnusedRegistries,
);

if (credentials.length === 0) {
Expand Down
26 changes: 4 additions & 22 deletions src/start-proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,6 @@ test("getCredentials validates 'replaces-base' correctly", async (t) => {
undefined,
credentialsInput,
BuiltInLanguage.java,
false,
);

t.is(credentials.length, 3);
Expand All @@ -604,52 +603,35 @@ test("getCredentials validates 'replaces-base' correctly", async (t) => {
getRunnerLogger(true),
undefined,
toEncodedJSON([{ ...baseInvalid, "replaces-base": null }]),
BuiltInLanguage.actions,
false,
BuiltInLanguage.java,
),
);
t.throws(() =>
startProxyExports.getCredentials(
getRunnerLogger(true),
undefined,
toEncodedJSON([{ ...baseInvalid, "replaces-base": 123 }]),
BuiltInLanguage.actions,
false,
BuiltInLanguage.java,
),
);
t.throws(() =>
startProxyExports.getCredentials(
getRunnerLogger(true),
undefined,
toEncodedJSON([{ ...baseInvalid, "replaces-base": "true" }]),
BuiltInLanguage.actions,
false,
BuiltInLanguage.java,
),
);
});

test("getCredentials returns all credentials for Actions when using LANGUAGE_TO_REGISTRY_TYPE", async (t) => {
test("getCredentials returns no credentials for Actions", async (t) => {
const credentialsInput = toEncodedJSON(mixedCredentials);

const credentials = startProxyExports.getCredentials(
getRunnerLogger(true),
undefined,
credentialsInput,
BuiltInLanguage.actions,
false,
);
t.is(credentials.length, mixedCredentials.length);
});

test("getCredentials returns no credentials for Actions when using NEW_LANGUAGE_TO_REGISTRY_TYPE", async (t) => {
const credentialsInput = toEncodedJSON(mixedCredentials);

const credentials = startProxyExports.getCredentials(
getRunnerLogger(true),
undefined,
credentialsInput,
BuiltInLanguage.actions,
true,
);
t.deepEqual(credentials, []);
});
Expand Down
18 changes: 2 additions & 16 deletions src/start-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,7 @@ function isPAT(value: string) {

type RegistryMapping = Partial<Record<BuiltInLanguage, string[]>>;

const LANGUAGE_TO_REGISTRY_TYPE: RegistryMapping = {
java: ["maven_repository"],
csharp: ["nuget_feed"],
javascript: ["npm_registry"],
python: ["python_index"],
ruby: ["rubygems_server"],
rust: ["cargo_registry"],
go: ["goproxy_server", "git_source"],
} as const;

const NEW_LANGUAGE_TO_REGISTRY_TYPE: Required<RegistryMapping> = {
const LANGUAGE_TO_REGISTRY_TYPE: Required<RegistryMapping> = {
actions: [],
cpp: [],
java: ["maven_repository"],
Expand Down Expand Up @@ -251,13 +241,9 @@ export function getCredentials(
registrySecrets: string | undefined,
registriesCredentials: string | undefined,
language: BuiltInLanguage | undefined,
skipUnusedRegistries: boolean = false,
): Credential[] {
const registryMapping = skipUnusedRegistries
? NEW_LANGUAGE_TO_REGISTRY_TYPE
: LANGUAGE_TO_REGISTRY_TYPE;
const registryTypeForLanguage = language
? registryMapping[language]
? LANGUAGE_TO_REGISTRY_TYPE[language]
: undefined;

let credentialsStr: string;
Expand Down
Loading