Skip to content

Commit

Permalink
Cross-check Go binary in analyze Action
Browse files Browse the repository at this point in the history
  • Loading branch information
mbg committed Sep 28, 2023
1 parent b5e0a68 commit d4722a8
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/analyze-action.js

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

2 changes: 1 addition & 1 deletion lib/analyze-action.js.map

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

14 changes: 14 additions & 0 deletions src/analyze-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from "path";
import { performance } from "perf_hooks";

import * as core from "@actions/core";
import { safeWhich } from "@chrisgavin/safe-which";

import * as actionsUtil from "./actions-util";
import {
Expand Down Expand Up @@ -236,6 +237,19 @@ async function run() {
logger,
);

// Check that the Go wrapper script still exists, if set
const goWrapperPath = process.env[EnvVar.GO_BINARY_LOCATION];

if (goWrapperPath !== undefined) {
const goBinaryPath = await safeWhich("go");

if (goWrapperPath !== goBinaryPath) {
core.warning(
"Unexpected result for `which go`: please ensure that the correct version of Go is installed before the `codeql-action/init` Action is used.",
);
}
}

await runAutobuildIfLegacyGoWorkflow(config, logger);

dbCreationTimings = await runFinalize(
Expand Down
35 changes: 35 additions & 0 deletions src/resolve-environment.test.ts.ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import test from "ava";

import { ResolveBuildEnvironmentOutput } from "./codeql";
import * as resolveEnvironment from "./resolve-environment";

test("inferRunnerImage inserts runnerImage key", async (t) => {
t.assert(
resolveEnvironment.inferRunnerImage({ name: "windows" }).runnerImage ===
"windows-latest",
"Result does not contain expected runnerImage"
);
t.assert(
resolveEnvironment.inferRunnerImage({ name: "linux" }).runnerImage ===
"ubuntu-latest",
"Result does not contain expected runnerImage"
);
t.assert(
resolveEnvironment.inferRunnerImage({ name: "macos" }).runnerImage ===
"macos-latest",
"Result does not contain expected runnerImage"
);
});

test("inferRunnerImages inserts runnerImage keys", async (t) => {
const testData: ResolveBuildEnvironmentOutput = {
configuration: {
csharp: { os: { name: "windows" } },
swift: { os: { name: "macos" } },
},
};
resolveEnvironment.inferRunnerImages(testData);

t.assert(testData.configuration?.csharp.os?.runnerImage, "blerg");

});

0 comments on commit d4722a8

Please sign in to comment.