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

Add a skip-go-installation to use pre-installed Go #144

Merged
merged 2 commits into from Dec 31, 2020
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
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -47,6 +47,9 @@ jobs:

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go
# skip-go-installation: true
```

We recommend running this action in a job separate from other jobs (`go test`, etc)
Expand Down Expand Up @@ -94,7 +97,7 @@ jobs:
You will also likely need to add the following `.gitattributes` file to ensure that line endings for windows builds are properly formatted:

```.gitattributes
*.go text eol=lf
*.go text eol=lf
```

## Comments and Annotations
Expand Down
6 changes: 4 additions & 2 deletions action.yml
@@ -1,4 +1,3 @@
---
name: "Run golangci-lint"
description: "Official golangci-lint action with line-attached annotations for found issues, caching and parallel execution."
author: "golangci"
Expand All @@ -21,7 +20,10 @@ inputs:
description: "if set to true and the action runs on a pull request - the action outputs only newly found issues"
default: false
required: true

skip-go-installation:
description: "if set to true then action uses pre-installed Go"
default: false
required: true
runs:
using: "node12"
main: "dist/run/index.js"
Expand Down
6 changes: 6 additions & 0 deletions dist/post_run/index.js
Expand Up @@ -7169,6 +7169,7 @@ function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const { lintPath, patchPath } = yield core.group(`prepare environment`, prepareEnv);
core.addPath(path.dirname(lintPath));
yield core.group(`run golangci-lint`, () => runLint(lintPath, patchPath));
}
catch (error) {
Expand Down Expand Up @@ -48591,6 +48592,11 @@ function installLint(versionConfig) {
exports.installLint = installLint;
function installGo() {
return __awaiter(this, void 0, void 0, function* () {
const skipGoInstallation = core.getInput(`skip-go-installation`, { required: true }).trim();
if (skipGoInstallation.toLowerCase() == "true") {
core.info(`Skipping the installation of Go`);
return;
}
const startedAt = Date.now();
process.env[`INPUT_GO-VERSION`] = `1`;
yield main_1.run();
Expand Down
6 changes: 6 additions & 0 deletions dist/run/index.js
Expand Up @@ -7179,6 +7179,7 @@ function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const { lintPath, patchPath } = yield core.group(`prepare environment`, prepareEnv);
core.addPath(path.dirname(lintPath));
yield core.group(`run golangci-lint`, () => runLint(lintPath, patchPath));
}
catch (error) {
Expand Down Expand Up @@ -48601,6 +48602,11 @@ function installLint(versionConfig) {
exports.installLint = installLint;
function installGo() {
return __awaiter(this, void 0, void 0, function* () {
const skipGoInstallation = core.getInput(`skip-go-installation`, { required: true }).trim();
if (skipGoInstallation.toLowerCase() == "true") {
core.info(`Skipping the installation of Go`);
return;
}
const startedAt = Date.now();
process.env[`INPUT_GO-VERSION`] = `1`;
yield main_1.run();
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

6 changes: 6 additions & 0 deletions src/install.ts
Expand Up @@ -56,6 +56,12 @@ export async function installLint(versionConfig: VersionConfig): Promise<string>
}

export async function installGo(): Promise<void> {
const skipGoInstallation = core.getInput(`skip-go-installation`, { required: true }).trim()
if (skipGoInstallation.toLowerCase() == "true") {
core.info(`Skipping the installation of Go`)
return
}

const startedAt = Date.now()
process.env[`INPUT_GO-VERSION`] = `1`
await setupGo()
Expand Down
1 change: 1 addition & 0 deletions src/run.ts
Expand Up @@ -187,6 +187,7 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
export async function run(): Promise<void> {
try {
const { lintPath, patchPath } = await core.group(`prepare environment`, prepareEnv)
core.addPath(path.dirname(lintPath))
await core.group(`run golangci-lint`, () => runLint(lintPath, patchPath))
} catch (error) {
core.error(`Failed to run: ${error}, ${error.stack}`)
Expand Down