respond to review comments
This commit is contained in:
parent
cca1ddefc0
commit
ebda17e859
5 changed files with 45 additions and 60 deletions
|
|
@ -42,7 +42,7 @@ export enum EnvVar {
|
|||
HAS_WARNED_ABOUT_DISK_SPACE = "CODEQL_ACTION_HAS_WARNED_ABOUT_DISK_SPACE",
|
||||
|
||||
/** Whether the init action has been run. */
|
||||
INIT_ACTION_HAS_RUN = "CODEQL_INIT_ACTION_HAS_RUN",
|
||||
INIT_ACTION_HAS_RUN = "CODEQL_ACTION_INIT_HAS_RUN",
|
||||
|
||||
/** UUID representing the current job run. */
|
||||
JOB_RUN_UUID = "JOB_RUN_UUID",
|
||||
|
|
|
|||
|
|
@ -9,21 +9,26 @@ import { withTmpDir } from "./util";
|
|||
|
||||
setupTests(test);
|
||||
|
||||
function setupEnvironmentAndStub(tmpDir: string) {
|
||||
setupActionsVars(tmpDir, tmpDir);
|
||||
|
||||
process.env["CODEQL_ACTION_ANALYSIS_KEY"] = "analysis-key";
|
||||
process.env["GITHUB_REF"] = "refs/heads/main";
|
||||
process.env["GITHUB_REPOSITORY"] = "octocat/HelloWorld";
|
||||
process.env["GITHUB_RUN_ATTEMPT"] = "2";
|
||||
process.env["GITHUB_RUN_ID"] = "100";
|
||||
process.env["GITHUB_SHA"] = "a".repeat(40);
|
||||
process.env["ImageVersion"] = "2023.05.19.1";
|
||||
process.env["RUNNER_OS"] = "macOS";
|
||||
process.env["RUNNER_TEMP"] = tmpDir;
|
||||
|
||||
const getRequiredInput = sinon.stub(actionsUtil, "getRequiredInput");
|
||||
getRequiredInput.withArgs("matrix").resolves("input/matrix");
|
||||
}
|
||||
|
||||
test("createStatusReportBase", async (t) => {
|
||||
await withTmpDir(async (tmpDir: string) => {
|
||||
setupActionsVars(tmpDir, tmpDir);
|
||||
|
||||
process.env["CODEQL_ACTION_ANALYSIS_KEY"] = "analysis-key";
|
||||
process.env["GITHUB_REF"] = "refs/heads/main";
|
||||
process.env["GITHUB_REPOSITORY"] = "octocat/HelloWorld";
|
||||
process.env["GITHUB_RUN_ATTEMPT"] = "2";
|
||||
process.env["GITHUB_RUN_ID"] = "100";
|
||||
process.env["GITHUB_SHA"] = "a".repeat(40);
|
||||
process.env["ImageVersion"] = "2023.05.19.1";
|
||||
process.env["RUNNER_OS"] = "macOS";
|
||||
|
||||
const getRequiredInput = sinon.stub(actionsUtil, "getRequiredInput");
|
||||
getRequiredInput.withArgs("matrix").resolves("input/matrix");
|
||||
setupEnvironmentAndStub(tmpDir);
|
||||
|
||||
const statusReport = await createStatusReportBase(
|
||||
"init",
|
||||
|
|
@ -43,14 +48,14 @@ test("createStatusReportBase", async (t) => {
|
|||
);
|
||||
t.is(statusReport.analysis_key, "analysis-key");
|
||||
t.is(statusReport.cause, "failure cause");
|
||||
t.is(statusReport.commit_oid, process.env["GITHUB_SHA"]);
|
||||
t.is(statusReport.commit_oid, process.env["GITHUB_SHA"]!);
|
||||
t.is(statusReport.exception, "exception stack trace");
|
||||
t.is(statusReport.job_name, process.env["GITHUB_JOB"] || "");
|
||||
t.is(typeof statusReport.job_run_uuid, "string");
|
||||
t.is(statusReport.ref, process.env["GITHUB_REF"]);
|
||||
t.is(statusReport.ref, process.env["GITHUB_REF"]!);
|
||||
t.is(statusReport.runner_available_disk_space_bytes, 100);
|
||||
t.is(statusReport.runner_image_version, process.env["ImageVersion"]);
|
||||
t.is(statusReport.runner_os, process.env["RUNNER_OS"]);
|
||||
t.is(statusReport.runner_os, process.env["RUNNER_OS"]!);
|
||||
t.is(statusReport.started_at, process.env[EnvVar.WORKFLOW_STARTED_AT]!);
|
||||
t.is(statusReport.status, "failure");
|
||||
t.is(statusReport.workflow_name, process.env["GITHUB_WORKFLOW"] || "");
|
||||
|
|
@ -61,20 +66,7 @@ test("createStatusReportBase", async (t) => {
|
|||
|
||||
test("createStatusReportBase_firstParty", async (t) => {
|
||||
await withTmpDir(async (tmpDir: string) => {
|
||||
setupActionsVars(tmpDir, tmpDir);
|
||||
|
||||
process.env["CODEQL_ACTION_ANALYSIS_KEY"] = "analysis-key";
|
||||
process.env["GITHUB_REF"] = "refs/heads/main";
|
||||
process.env["GITHUB_REPOSITORY"] = "octocat/HelloWorld";
|
||||
process.env["GITHUB_RUN_ATTEMPT"] = "2";
|
||||
process.env["GITHUB_RUN_ID"] = "100";
|
||||
process.env["GITHUB_SHA"] = "a".repeat(40);
|
||||
process.env["ImageVersion"] = "2023.05.19.1";
|
||||
process.env["RUNNER_OS"] = "macOS";
|
||||
process.env["RUNNER_TEMP"] = tmpDir;
|
||||
|
||||
const getRequiredInput = sinon.stub(actionsUtil, "getRequiredInput");
|
||||
getRequiredInput.withArgs("matrix").resolves("input/matrix");
|
||||
setupEnvironmentAndStub(tmpDir);
|
||||
|
||||
t.is(
|
||||
(
|
||||
|
|
@ -104,7 +96,7 @@ test("createStatusReportBase_firstParty", async (t) => {
|
|||
true,
|
||||
);
|
||||
|
||||
process.env["CODEQL_INIT_ACTION_HAS_RUN"] = "foobar";
|
||||
process.env["CODEQL_ACTION_INIT_HAS_RUN"] = "foobar";
|
||||
t.is(
|
||||
(
|
||||
await createStatusReportBase(
|
||||
|
|
@ -133,7 +125,7 @@ test("createStatusReportBase_firstParty", async (t) => {
|
|||
true,
|
||||
);
|
||||
|
||||
process.env["CODEQL_INIT_ACTION_HAS_RUN"] = "true";
|
||||
process.env["CODEQL_ACTION_INIT_HAS_RUN"] = "true";
|
||||
t.is(
|
||||
(
|
||||
await createStatusReportBase(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue