Skip to content
Merged
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
4 changes: 2 additions & 2 deletions lib/analyze-action.js

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

4 changes: 2 additions & 2 deletions lib/autobuild-action.js

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

4 changes: 2 additions & 2 deletions lib/init-action-post.js

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

4 changes: 2 additions & 2 deletions lib/init-action.js

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

4 changes: 2 additions & 2 deletions lib/resolve-environment-action.js

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

23 changes: 15 additions & 8 deletions lib/start-proxy-action.js

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

4 changes: 2 additions & 2 deletions lib/upload-sarif-action.js

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

18 changes: 15 additions & 3 deletions src/start-proxy-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import { pki } from "node-forge";

import * as actionsUtil from "./actions-util";
import { getApiDetails, getAuthorizationHeaderFor } from "./api-client";
import { Config } from "./config-utils";
import { KnownLanguage } from "./languages";
import { getActionsLogger, Logger } from "./logging";
import {
Credential,
getCredentials,
getDownloadUrl,
parseLanguage,
UPDATEJOB_PROXY,
} from "./start-proxy";
import {
Expand Down Expand Up @@ -98,14 +101,15 @@ interface StartProxyStatus extends StatusReportBase {

async function sendSuccessStatusReport(
startedAt: Date,
config: Partial<Config>,
registry_types: string[],
logger: Logger,
) {
const statusReportBase = await createStatusReportBase(
ActionName.StartProxy,
"success",
startedAt,
undefined,
config,
await util.checkDiskUsage(logger),
logger,
);
Expand All @@ -125,6 +129,7 @@ async function runWrapper() {
actionsUtil.persistInputs();

const logger = getActionsLogger();
let language: KnownLanguage | undefined;

try {
// Setup logging for the proxy
Expand All @@ -133,11 +138,13 @@ async function runWrapper() {
core.saveState("proxy-log-file", proxyLogFilePath);

// Get the configuration options
const languageInput = actionsUtil.getOptionalInput("language");
language = languageInput ? parseLanguage(languageInput) : undefined;
const credentials = getCredentials(
logger,
actionsUtil.getOptionalInput("registry_secrets"),
actionsUtil.getOptionalInput("registries_credentials"),
actionsUtil.getOptionalInput("language"),
language,
);

if (credentials.length === 0) {
Expand Down Expand Up @@ -165,6 +172,9 @@ async function runWrapper() {
// Report success if we have reached this point.
await sendSuccessStatusReport(
startedAt,
{
languages: language && [language],
},
proxyConfig.all_credentials.map((c) => c.type),
logger,
);
Expand All @@ -178,7 +188,9 @@ async function runWrapper() {
ActionName.StartProxy,
getActionsStatus(error),
startedAt,
undefined,
{
languages: language && [language],
},
await util.checkDiskUsage(logger),
logger,
);
Expand Down
4 changes: 2 additions & 2 deletions src/start-proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ test("getCredentials filters by language when specified", async (t) => {
getRunnerLogger(true),
undefined,
toEncodedJSON(mixedCredentials),
"java",
KnownLanguage.java,
);
t.is(credentials.length, 1);
t.is(credentials[0].type, "maven_repository");
Expand All @@ -120,7 +120,7 @@ test("getCredentials returns all for a language when specified", async (t) => {
getRunnerLogger(true),
undefined,
toEncodedJSON(mixedCredentials),
"go",
KnownLanguage.go,
);
t.is(credentials.length, 2);

Expand Down
3 changes: 1 addition & 2 deletions src/start-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ export function getCredentials(
logger: Logger,
registrySecrets: string | undefined,
registriesCredentials: string | undefined,
languageString: string | undefined,
language: KnownLanguage | undefined,
): Credential[] {
const language = languageString ? parseLanguage(languageString) : undefined;
const registryTypeForLanguage = language
? LANGUAGE_TO_REGISTRY_TYPE[language]
: undefined;
Expand Down
43 changes: 43 additions & 0 deletions src/status-report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,49 @@ test("createStatusReportBase", async (t) => {
});
});

test("createStatusReportBase - empty configuration", async (t) => {
await withTmpDir(async (tmpDir: string) => {
setupEnvironmentAndStub(tmpDir);

const statusReport = await createStatusReportBase(
ActionName.StartProxy,
"success",
new Date("May 19, 2023 05:19:00"),
{},
{ numAvailableBytes: 100, numTotalBytes: 500 },
getRunnerLogger(false),
);

if (t.truthy(statusReport)) {
t.is(statusReport.action_name, ActionName.StartProxy);
t.is(statusReport.status, "success");
}
});
});

test("createStatusReportBase - partial configuration", async (t) => {
await withTmpDir(async (tmpDir: string) => {
setupEnvironmentAndStub(tmpDir);

const statusReport = await createStatusReportBase(
ActionName.StartProxy,
"success",
new Date("May 19, 2023 05:19:00"),
{
languages: ["go"],
},
{ numAvailableBytes: 100, numTotalBytes: 500 },
getRunnerLogger(false),
);

if (t.truthy(statusReport)) {
t.is(statusReport.action_name, ActionName.StartProxy);
t.is(statusReport.status, "success");
t.is(statusReport.languages, "go");
}
});
});

test("createStatusReportBase_firstParty", async (t) => {
await withTmpDir(async (tmpDir: string) => {
setupEnvironmentAndStub(tmpDir);
Expand Down
6 changes: 3 additions & 3 deletions src/status-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export async function createStatusReportBase(
actionName: ActionName,
status: ActionStatus,
actionStartedAt: Date,
config: Config | undefined,
config: Partial<Config> | undefined,
diskInfo: DiskUsage | undefined,
logger: Logger,
cause?: string,
Expand Down Expand Up @@ -299,7 +299,7 @@ export async function createStatusReportBase(
action_ref: actionRef,
action_started_at: actionStartedAt.toISOString(),
action_version: getActionVersion(),
analysis_kinds: config?.analysisKinds.join(","),
analysis_kinds: config?.analysisKinds?.join(","),
analysis_key,
build_mode: config?.buildMode,
commit_oid: commitOid,
Expand All @@ -324,7 +324,7 @@ export async function createStatusReportBase(
}

if (config) {
statusReport.languages = config.languages.join(",");
statusReport.languages = config.languages?.join(",");
}

if (diskInfo) {
Expand Down
Loading