Compare commits
42 Commits
Author | SHA1 | Date | |
---|---|---|---|
a12ae43dd8 | |||
f1dee55574 | |||
23487cb16f | |||
84560243ae | |||
3e54e516ae | |||
2f717c44f2 | |||
4a6ab128b0 | |||
f9b6927981 | |||
41858b8c7c | |||
67236c010b | |||
544d2efb30 | |||
0dd30832fc | |||
e1ae6cf354 | |||
0ef0ffc44e | |||
125ac487c1 | |||
e246bba31d | |||
147f37a473 | |||
a19645e82f | |||
286cf073ea | |||
7641a6707d | |||
e4e910b0ce | |||
89d96d6c20 | |||
45f3a377de | |||
943013ec20 | |||
49a9e469b1 | |||
528677aa24 | |||
85798b53e5 | |||
d164f0d6d8 | |||
9cf34bb2b8 | |||
629aad184c | |||
1bac7d9888 | |||
44fae30515 | |||
689e90e8a0 | |||
d73150ab3c | |||
2c3839ff26 | |||
f881d993a0 | |||
d3f3b8adb7 | |||
e3e2a92cbd | |||
e1bd4355fb | |||
345e5340e3 | |||
13e9e901f4 | |||
771153bfbc |
@ -1,7 +1,13 @@
|
||||
{
|
||||
"env": { "node": true, "jest": true },
|
||||
"env": {
|
||||
"node": true,
|
||||
"jest": true
|
||||
},
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": { "ecmaVersion": 2020, "sourceType": "module" },
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2020,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
@ -9,15 +15,18 @@
|
||||
"plugin:import/errors",
|
||||
"plugin:import/warnings",
|
||||
"plugin:import/typescript",
|
||||
"plugin:prettier/recommended",
|
||||
"prettier/@typescript-eslint"
|
||||
"plugin:prettier/recommended"
|
||||
],
|
||||
"plugins": [
|
||||
"@typescript-eslint",
|
||||
"simple-import-sort"
|
||||
],
|
||||
"plugins": ["@typescript-eslint", "simple-import-sort"],
|
||||
"rules": {
|
||||
"import/first": "error",
|
||||
"import/newline-after-import": "error",
|
||||
"import/no-duplicates": "error",
|
||||
"simple-import-sort/sort": "error",
|
||||
"simple-import-sort/imports": "error",
|
||||
"simple-import-sort/exports": "error",
|
||||
"sort-imports": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
15
README.md
15
README.md
@ -2,7 +2,7 @@
|
||||
|
||||
[](https://github.com/golangci/golangci-lint-action/actions)
|
||||
|
||||
It's the official GitHub action for [golangci-lint](https://github.com/golangci/golangci-lint) from it's authors.
|
||||
It's the official GitHub action for [golangci-lint](https://github.com/golangci/golangci-lint) from its authors.
|
||||
The action runs [golangci-lint](https://github.com/golangci/golangci-lint) and reports issues from linters.
|
||||
|
||||

|
||||
@ -36,7 +36,7 @@ jobs:
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
||||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
|
||||
version: v1.29
|
||||
|
||||
# Optional: working directory, useful for monorepos
|
||||
@ -47,6 +47,15 @@ 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
|
||||
|
||||
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
|
||||
# skip-pkg-cache: true
|
||||
|
||||
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
|
||||
# skip-build-cache: true
|
||||
```
|
||||
|
||||
We recommend running this action in a job separate from other jobs (`go test`, etc)
|
||||
@ -94,7 +103,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
|
||||
|
14
action.yml
14
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"
|
||||
@ -21,7 +20,18 @@ 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
|
||||
skip-pkg-cache:
|
||||
description: "if set to true then the action don't cache or restore ~/go/pkg."
|
||||
default: false
|
||||
required: true
|
||||
skip-build-cache:
|
||||
description: "if set to true then the action don't cache or restore ~/.cache/go-build."
|
||||
default: false
|
||||
required: true
|
||||
runs:
|
||||
using: "node12"
|
||||
main: "dist/run/index.js"
|
||||
|
23508
dist/post_run/index.js
vendored
23508
dist/post_run/index.js
vendored
File diff suppressed because one or more lines are too long
23510
dist/run/index.js
vendored
23510
dist/run/index.js
vendored
File diff suppressed because one or more lines are too long
4544
package-lock.json
generated
4544
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -26,28 +26,28 @@
|
||||
"author": "golangci",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^1.0.2",
|
||||
"@actions/cache": "^1.0.6",
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "^1.0.1",
|
||||
"@actions/github": "^4.0.0",
|
||||
"@actions/tool-cache": "^1.6.0",
|
||||
"@actions/tool-cache": "^1.6.1",
|
||||
"@types/semver": "^7.3.4",
|
||||
"@types/tmp": "^0.2.0",
|
||||
"setup-go": "git+https://github.com/actions/setup-go.git#v2.1.3",
|
||||
"tmp": "^0.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.11.10",
|
||||
"@types/node": "^14.14.31",
|
||||
"@types/uuid": "^8.3.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
||||
"@typescript-eslint/parser": "^2.34.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.15.1",
|
||||
"@typescript-eslint/parser": "^4.15.1",
|
||||
"@zeit/ncc": "^0.22.3",
|
||||
"eslint": "^6.6.0",
|
||||
"eslint-config-prettier": "^6.13.0",
|
||||
"eslint": "^7.20.0",
|
||||
"eslint-config-prettier": "^8.0.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-prettier": "^3.1.4",
|
||||
"eslint-plugin-simple-import-sort": "^5.0.2",
|
||||
"prettier": "^2.1.2",
|
||||
"typescript": "^4.0.3"
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"eslint-plugin-simple-import-sort": "^7.0.0",
|
||||
"prettier": "^2.2.1",
|
||||
"typescript": "^4.1.5"
|
||||
}
|
||||
}
|
||||
|
17
src/cache.ts
17
src/cache.ts
@ -25,7 +25,22 @@ const getLintCacheDir = (): string => {
|
||||
|
||||
const getCacheDirs = (): string[] => {
|
||||
// Not existing dirs are ok here: it works.
|
||||
return [getLintCacheDir(), path.resolve(`${process.env.HOME}/.cache/go-build`), path.resolve(`${process.env.HOME}/go/pkg`)]
|
||||
const skipPkgCache = core.getInput(`skip-pkg-cache`, { required: true }).trim()
|
||||
const skipBuildCache = core.getInput(`skip-build-cache`, { required: true }).trim()
|
||||
const dirs = [getLintCacheDir()]
|
||||
|
||||
if (skipBuildCache.toLowerCase() == "true") {
|
||||
core.info(`Omitting ~/.cache/go-build from cache directories`)
|
||||
} else {
|
||||
dirs.push(path.resolve(`${process.env.HOME}/.cache/go-build`))
|
||||
}
|
||||
if (skipPkgCache.toLowerCase() == "true") {
|
||||
core.info(`Omitting ~/go/pkg from cache directories`)
|
||||
} else {
|
||||
dirs.push(path.resolve(`${process.env.HOME}/go/pkg`))
|
||||
}
|
||||
|
||||
return dirs
|
||||
}
|
||||
|
||||
const getIntervalKey = (invalidationIntervalDays: number): string => {
|
||||
|
@ -45,7 +45,12 @@ export async function installLint(versionConfig: VersionConfig): Promise<string>
|
||||
extractedDir = await tc.extractZip(archivePath, process.env.HOME)
|
||||
repl = /\.zip$/
|
||||
} else {
|
||||
extractedDir = await tc.extractTar(archivePath, process.env.HOME)
|
||||
// We want to always overwrite files if the local cache already has them
|
||||
const args = ["xz"]
|
||||
if (process.platform.toString() != "darwin") {
|
||||
args.push("--overwrite")
|
||||
}
|
||||
extractedDir = await tc.extractTar(archivePath, process.env.HOME, args)
|
||||
}
|
||||
|
||||
const urlParts = assetURL.split(`/`)
|
||||
@ -56,6 +61,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()
|
||||
|
@ -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}`)
|
||||
|
Reference in New Issue
Block a user