Skip to content

Commit b157a2f

Browse files
committed
Cross-check Go binary in analyze Action
1 parent 69111d3 commit b157a2f

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

Diff for: lib/analyze-action.js

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: lib/analyze-action.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/analyze-action.ts

+14
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from "path";
33
import { performance } from "perf_hooks";
44

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

78
import * as actionsUtil from "./actions-util";
89
import {
@@ -231,6 +232,19 @@ async function run() {
231232
logger,
232233
);
233234

235+
// Check that the Go wrapper script still exists, if set
236+
const goWrapperPath = process.env[EnvVar.GO_BINARY_LOCATION];
237+
238+
if (goWrapperPath !== undefined) {
239+
const goBinaryPath = await safeWhich("go");
240+
241+
if (goWrapperPath !== goBinaryPath) {
242+
core.warning(
243+
"Unexpected result for `which go`: please ensure that the correct version of Go is installed before the `codeql-action/init` Action is used.",
244+
);
245+
}
246+
}
247+
234248
await runAutobuildIfLegacyGoWorkflow(config, logger);
235249

236250
dbCreationTimings = await runFinalize(

Diff for: src/resolve-environment.test.ts.ignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import test from "ava";
2+
3+
import { ResolveBuildEnvironmentOutput } from "./codeql";
4+
import * as resolveEnvironment from "./resolve-environment";
5+
6+
test("inferRunnerImage inserts runnerImage key", async (t) => {
7+
t.assert(
8+
resolveEnvironment.inferRunnerImage({ name: "windows" }).runnerImage ===
9+
"windows-latest",
10+
"Result does not contain expected runnerImage"
11+
);
12+
t.assert(
13+
resolveEnvironment.inferRunnerImage({ name: "linux" }).runnerImage ===
14+
"ubuntu-latest",
15+
"Result does not contain expected runnerImage"
16+
);
17+
t.assert(
18+
resolveEnvironment.inferRunnerImage({ name: "macos" }).runnerImage ===
19+
"macos-latest",
20+
"Result does not contain expected runnerImage"
21+
);
22+
});
23+
24+
test("inferRunnerImages inserts runnerImage keys", async (t) => {
25+
const testData: ResolveBuildEnvironmentOutput = {
26+
configuration: {
27+
csharp: { os: { name: "windows" } },
28+
swift: { os: { name: "macos" } },
29+
},
30+
};
31+
resolveEnvironment.inferRunnerImages(testData);
32+
33+
t.assert(testData.configuration?.csharp.os?.runnerImage, "blerg");
34+
35+
});

0 commit comments

Comments
 (0)