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 bugs related to go_version_file input #392

Merged
merged 4 commits into from Aug 15, 2022
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
4 changes: 3 additions & 1 deletion action.yml
Expand Up @@ -53,7 +53,9 @@ inputs:
go_version:
description: "the version of Go. By default, the latest version of Go 1.x is installed."
required: false
default: "1.x"
go_version_file:
description: "Path to the go.mod file or the file containing only Go version."
required: false
cache:
deprecation: "enable cache"
default: true
Expand Down
12 changes: 7 additions & 5 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.

8 changes: 3 additions & 5 deletions src/main.ts
Expand Up @@ -31,11 +31,9 @@ async function run() {
const cwd = path.relative(process.env["GITHUB_WORKSPACE"] || process.cwd(), workdir);
const enableCache = core.getBooleanInput("cache");

if (goVersion !== "" || goVersionFile !== "") {
await core.group("Installing Go ...", async () => {
await setupGo.run(goVersion, goVersionFile);
});
}
await core.group("Installing Go ...", async () => {
await setupGo.run(goVersion, goVersionFile);
});
Comment on lines +34 to +36
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a user wants to use the default goVersion, the goVersion is passed as an empty string, so I removed this if block.


const reviewdog = await core.group(
"🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog",
Expand Down
6 changes: 6 additions & 0 deletions src/setup-go/main.ts
Expand Up @@ -9,6 +9,8 @@ import cp from "child_process";
import fs from "fs";
import path from "path";

const defaultGoVersion = "1.x";

export async function run(version: string, versionFilePath: string): Promise<void> {
try {
const versionSpec = resolveVersionInput(version, versionFilePath);
Expand Down Expand Up @@ -100,5 +102,9 @@ function resolveVersionInput(version: string, versionFilePath: string): string {
version = installer.parseGoVersionFile(versionFilePath);
}

if (!version) {
version = defaultGoVersion;
}

return version;
}