Upload CodeQL databases

This commit is contained in:
Robert
2021-06-22 13:05:12 +01:00
parent b2d10b39b0
commit 146c897909
24 changed files with 981 additions and 24 deletions

View File

@@ -1,10 +1,13 @@
import * as fs from "fs";
import * as path from "path";
import test from "ava";
import * as yaml from "js-yaml";
import sinon from "sinon";
import * as actionsutil from "./actions-util";
import { setupTests } from "./testing-utils";
import { getMode, initializeEnvironment, Mode } from "./util";
import { getMode, initializeEnvironment, Mode, withTmpDir } from "./util";
function errorCodes(
actual: actionsutil.CodedError[],
@@ -652,3 +655,28 @@ test("initializeEnvironment", (t) => {
t.deepEqual(getMode(), Mode.runner);
t.deepEqual(process.env.CODEQL_ACTION_VERSION, "4.5.6");
});
test("isAnalyzingDefaultBranch()", async (t) => {
await withTmpDir(async (tmpDir) => {
const envFile = path.join(tmpDir, "event.json");
fs.writeFileSync(
envFile,
JSON.stringify({
repository: {
default_branch: "main",
},
})
);
process.env["GITHUB_EVENT_PATH"] = envFile;
process.env["GITHUB_REF"] = "main";
process.env["GITHUB_SHA"] = "1234";
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), true);
process.env["GITHUB_REF"] = "refs/heads/main";
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), true);
process.env["GITHUB_REF"] = "feature";
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), false);
});
});