Skip to content

Commit 5728ade

Browse files
author
Sergey Vilgelm
committed
Add skip-go-installation to use pre-installed Go
Add the golangci-lint to PATH
1 parent 302bfa5 commit 5728ade

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ jobs:
4747

4848
# Optional: show only new issues if it's a pull request. The default value is `false`.
4949
# only-new-issues: true
50+
51+
# Optional: if set to true then the action will use pre-installed Go
52+
# skip-go-installation: true
5053
```
5154

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

9699
```.gitattributes
97-
*.go text eol=lf
100+
*.go text eol=lf
98101
```
99102

100103
## Comments and Annotations

action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
name: "Run golangci-lint"
32
description: "Official golangci-lint action with line-attached annotations for found issues, caching and parallel execution."
43
author: "golangci"
@@ -21,7 +20,10 @@ inputs:
2120
description: "if set to true and the action runs on a pull request - the action outputs only newly found issues"
2221
default: false
2322
required: true
24-
23+
skip-go-installation:
24+
description: "if set to true then the action uses pre-install Go"
25+
default: false
26+
required: true
2527
runs:
2628
using: "node12"
2729
main: "dist/run/index.js"

src/install.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ export async function installLint(versionConfig: VersionConfig): Promise<string>
5656
}
5757

5858
export async function installGo(): Promise<void> {
59+
const skipGoInstallation = core.getInput(`skip-go-installation`, { required: true }).trim()
60+
if (skipGoInstallation.toLowerCase() == "true") {
61+
core.info(`Skipping the installation of Go`)
62+
return
63+
}
64+
5965
const startedAt = Date.now()
6066
process.env[`INPUT_GO-VERSION`] = `1`
6167
await setupGo()

src/run.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
187187
export async function run(): Promise<void> {
188188
try {
189189
const { lintPath, patchPath } = await core.group(`prepare environment`, prepareEnv)
190+
core.addPath(path.dirname(lintPath))
190191
await core.group(`run golangci-lint`, () => runLint(lintPath, patchPath))
191192
} catch (error) {
192193
core.error(`Failed to run: ${error}, ${error.stack}`)

0 commit comments

Comments
 (0)