Skip to content

Commit e4e910b

Browse files
author
Sergey Vilgelm
authored
Add a skip-go-installation to use pre-installed Go (#144)
* update package-lock.json * Add skip-go-installation to use pre-installed Go Add the golangci-lint to PATH
1 parent 89d96d6 commit e4e910b

File tree

7 files changed

+31
-7
lines changed

7 files changed

+31
-7
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 action uses pre-installed Go"
25+
default: false
26+
required: true
2527
runs:
2628
using: "node12"
2729
main: "dist/run/index.js"

dist/post_run/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7169,6 +7169,7 @@ function run() {
71697169
return __awaiter(this, void 0, void 0, function* () {
71707170
try {
71717171
const { lintPath, patchPath } = yield core.group(`prepare environment`, prepareEnv);
7172+
core.addPath(path.dirname(lintPath));
71727173
yield core.group(`run golangci-lint`, () => runLint(lintPath, patchPath));
71737174
}
71747175
catch (error) {
@@ -48591,6 +48592,11 @@ function installLint(versionConfig) {
4859148592
exports.installLint = installLint;
4859248593
function installGo() {
4859348594
return __awaiter(this, void 0, void 0, function* () {
48595+
const skipGoInstallation = core.getInput(`skip-go-installation`, { required: true }).trim();
48596+
if (skipGoInstallation.toLowerCase() == "true") {
48597+
core.info(`Skipping the installation of Go`);
48598+
return;
48599+
}
4859448600
const startedAt = Date.now();
4859548601
process.env[`INPUT_GO-VERSION`] = `1`;
4859648602
yield main_1.run();

dist/run/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7179,6 +7179,7 @@ function run() {
71797179
return __awaiter(this, void 0, void 0, function* () {
71807180
try {
71817181
const { lintPath, patchPath } = yield core.group(`prepare environment`, prepareEnv);
7182+
core.addPath(path.dirname(lintPath));
71827183
yield core.group(`run golangci-lint`, () => runLint(lintPath, patchPath));
71837184
}
71847185
catch (error) {
@@ -48601,6 +48602,11 @@ function installLint(versionConfig) {
4860148602
exports.installLint = installLint;
4860248603
function installGo() {
4860348604
return __awaiter(this, void 0, void 0, function* () {
48605+
const skipGoInstallation = core.getInput(`skip-go-installation`, { required: true }).trim();
48606+
if (skipGoInstallation.toLowerCase() == "true") {
48607+
core.info(`Skipping the installation of Go`);
48608+
return;
48609+
}
4860448610
const startedAt = Date.now();
4860548611
process.env[`INPUT_GO-VERSION`] = `1`;
4860648612
yield main_1.run();

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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)