Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix path for go.sum #550

Merged
merged 2 commits into from
Jun 25, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion src/cache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as cache from "@actions/cache";
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as crypto from "crypto";
import * as fs from "fs";
import * as path from "path";
Expand All @@ -15,7 +16,10 @@ export interface State {

export async function restore(cwd: string): Promise<State> {
const keyPrefix = `${process.platform}-golangci-`;
const hash = await hashFiles(path.join(cwd, "go.sum"));
const goSumPath = await getGoSumPath(cwd);
core.info(`go.sum path is ${goSumPath}`);

const hash = await hashFiles(goSumPath);
const key = keyPrefix + hash;
const restoreKeys = [keyPrefix];

Expand All @@ -40,6 +44,13 @@ export async function restore(cwd: string): Promise<State> {
return { key, cachedKey };
}

async function getGoSumPath(cwd: string): Promise<string> {
const opt = { cwd };
const output = await exec.getExecOutput("go", ["env", "GOMOD"], opt);
const goModPath = output.stdout.trim();
return path.join(path.dirname(goModPath), "go.sum");
}

export async function save(state: State): Promise<void> {
const { cachedKey, key } = state;
if (cachedKey === key) {
Expand Down
2 changes: 1 addition & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async function tagToVersion(tag: string, owner: string, repo: string): Promise<s
const headers = { [http.Headers.Accept]: "application/json" };
const response = await client.getJson<Release>(url, headers);

if (response.statusCode != http.HttpCodes.OK) {
if (response.statusCode !== http.HttpCodes.OK) {
core.error(`${url} returns unexpected HTTP status code: ${response.statusCode}`);
}
if (!response.result) {
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as flags from "./flags";
import * as setupGo from "./setup-go/main";
import * as cache from "./cache";

async function run() {
async function run(): Promise<void> {
const runnerTmpdir = process.env["RUNNER_TEMP"] || os.tmpdir();
const tmpdir = await fs.mkdtemp(path.join(runnerTmpdir, "reviewdog-"));

Expand Down Expand Up @@ -119,4 +119,4 @@ async function run() {
}
}

run();
void run();