mirror of
https://github.com/golangci/golangci-lint-action.git
synced 2026-01-16 12:24:31 +07:00
Compare commits
169 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b517f99ae2 | ||
|
|
9636c5bc97 | ||
|
|
03e4befc7a | ||
|
|
cdfc708aeb | ||
|
|
7d5614c3eb | ||
|
|
c675eb70db | ||
|
|
423fbafafc | ||
|
|
bcfc6f96bb | ||
|
|
d34ac2aef3 | ||
|
|
e4b538ed37 | ||
|
|
a288c0d3a6 | ||
|
|
b7a34f8320 | ||
|
|
129bcf9a1f | ||
|
|
153576c006 | ||
|
|
a9a9dff640 | ||
|
|
c5f5ea997d | ||
|
|
4a71b18a91 | ||
|
|
a4fdb6b72e | ||
|
|
ee1123f130 | ||
|
|
4ef1b2ec49 | ||
|
|
d218332866 | ||
|
|
f00c9148c4 | ||
|
|
f8f7d958bb | ||
|
|
bfc4fa1919 | ||
|
|
43be8d0cdd | ||
|
|
8067f9f84a | ||
|
|
f47759687a | ||
|
|
087e546081 | ||
|
|
5371bd590f | ||
|
|
24734036d2 | ||
|
|
21713123c6 | ||
|
|
9d1a680eed | ||
|
|
46a391f1c2 | ||
|
|
357a955e8e | ||
|
|
fce0498922 | ||
|
|
110e97717e | ||
|
|
1aecf21113 | ||
|
|
ef112b5be6 | ||
|
|
5125ed6d61 | ||
|
|
f05da40d4c | ||
|
|
a143bf8921 | ||
|
|
326fa87401 | ||
|
|
d2ac25d73f | ||
|
|
786003e9c7 | ||
|
|
62358f9da4 | ||
|
|
fe302dcadf | ||
|
|
c266032a10 | ||
|
|
d11c12cf90 | ||
|
|
959b4c2ca0 | ||
|
|
149c153930 | ||
|
|
1536a018c7 | ||
|
|
b436a39715 | ||
|
|
f8f6480e7d | ||
|
|
836191867d | ||
|
|
0559ce1d80 | ||
|
|
b88829864d | ||
|
|
b19e2b3c0a | ||
|
|
12240bc515 | ||
|
|
49b6acfed8 | ||
|
|
bab998e698 | ||
|
|
a832735f53 | ||
|
|
d36089f6c3 | ||
|
|
409e5d240e | ||
|
|
549764e76a | ||
|
|
f05cdc6faa | ||
|
|
a6989616e2 | ||
|
|
4f60444900 | ||
|
|
ac08543e75 | ||
|
|
75023663df | ||
|
|
4ff279027a | ||
|
|
31d144d116 | ||
|
|
15e20abff8 | ||
|
|
46f8c43497 | ||
|
|
14684a93ef | ||
|
|
0e9fa9c8e2 | ||
|
|
15ed67c1de | ||
|
|
caa1fa532d | ||
|
|
e62c1052cf | ||
|
|
caf7c34f5a | ||
|
|
7376bdf790 | ||
|
|
1f0d323737 | ||
|
|
a39c3ffed3 | ||
|
|
9a759fbc45 | ||
|
|
62e84c3c4c | ||
|
|
b25b8c7a74 | ||
|
|
bbd70929c2 | ||
|
|
60abaa8ea2 | ||
|
|
8c1e004312 | ||
|
|
6f6d8132f3 | ||
|
|
219bd32ab9 | ||
|
|
7ede1b4cda | ||
|
|
0117eff7bc | ||
|
|
06f6e1a8f1 | ||
|
|
df080e3b0c | ||
|
|
83f444df15 | ||
|
|
28e8ba14c9 | ||
|
|
087718c925 | ||
|
|
d1dab7c3b6 | ||
|
|
02697c5273 | ||
|
|
4deddfaddc | ||
|
|
932e5370e4 | ||
|
|
f6bac355f6 | ||
|
|
851656297a | ||
|
|
42fcadffd7 | ||
|
|
9110cf0ecc | ||
|
|
ea8f042b47 | ||
|
|
4603c8008d | ||
|
|
df58a55048 | ||
|
|
7cce37b0b4 | ||
|
|
fee05dc7f3 | ||
|
|
ce06d75c94 | ||
|
|
988235bf28 | ||
|
|
aa4608ff29 | ||
|
|
18265ba4d8 | ||
|
|
7bac37febb | ||
|
|
6dfbaa3535 | ||
|
|
54d492b16c | ||
|
|
27ed31ebd6 | ||
|
|
e027344f45 | ||
|
|
6d0159e91a | ||
|
|
4e7bbc596f | ||
|
|
6bfe1df230 | ||
|
|
8e3dd7cda3 | ||
|
|
d9309c3ecd | ||
|
|
27d36d540a | ||
|
|
15d9fe194e | ||
|
|
23ef4c9b80 | ||
|
|
ad3b558f83 | ||
|
|
b2f22d964b | ||
|
|
85a08b9006 | ||
|
|
2036e240da | ||
|
|
17d4bc397f | ||
|
|
c355eeab11 | ||
|
|
db69912a35 | ||
|
|
f14c093626 | ||
|
|
7f1a4282b7 | ||
|
|
0adb1986cf | ||
|
|
75ba1c2aad | ||
|
|
ac8bda106a | ||
|
|
1d44e6d1ee | ||
|
|
89fe568d08 | ||
|
|
c697566258 | ||
|
|
9ce9ed1016 | ||
|
|
3bb6112eb2 | ||
|
|
e4395de4fb | ||
|
|
52d77950b7 | ||
|
|
ebc78f9b2f | ||
|
|
835e616ef0 | ||
|
|
5c56cd6c9d | ||
|
|
e3c53feccf | ||
|
|
3b9f80ede5 | ||
|
|
9845713000 | ||
|
|
e789ee158f | ||
|
|
f2e9a96352 | ||
|
|
818081ab4c | ||
|
|
6671836543 | ||
|
|
526907ee72 | ||
|
|
6b6ba165e0 | ||
|
|
9cab4efcbd | ||
|
|
0c765721e5 | ||
|
|
0dfde21f77 | ||
|
|
9dcf389701 | ||
|
|
34d3904887 | ||
|
|
e30b22f33a | ||
|
|
8f30d2584c | ||
|
|
0b64a402d8 | ||
|
|
973b3a337d | ||
|
|
6ea3de1934 | ||
|
|
6eec6af39e |
32
.github/workflows/test.yml
vendored
32
.github/workflows/test.yml
vendored
@@ -15,7 +15,27 @@ jobs:
|
|||||||
npm install
|
npm install
|
||||||
npm run all
|
npm run all
|
||||||
|
|
||||||
|
# Update dist files if there is label dependencies
|
||||||
|
- name: Update dist files
|
||||||
|
if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'dependencies')
|
||||||
|
run: |
|
||||||
|
if [[ -z $(git status -s) ]]
|
||||||
|
then
|
||||||
|
echo "No change is required"
|
||||||
|
else
|
||||||
|
echo "Updating dist directory"
|
||||||
|
git config --local user.name "dependabot[bot]"
|
||||||
|
git config --local user.email "49699333+dependabot[bot]@users.noreply.github.com"
|
||||||
|
git add --update
|
||||||
|
git commit --message="Update dist files"
|
||||||
|
git push
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fail the build if there is dirty change
|
||||||
|
- run: git diff --exit-code
|
||||||
|
|
||||||
test: # make sure the action works on a clean machine without building
|
test: # make sure the action works on a clean machine without building
|
||||||
|
needs: [ build ]
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
@@ -28,15 +48,20 @@ jobs:
|
|||||||
- "v1.37"
|
- "v1.37"
|
||||||
- "v1.37.1"
|
- "v1.37.1"
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: read
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.version }}
|
version: ${{ matrix.version }}
|
||||||
args: --issues-exit-code=0 ./sample/...
|
args: --timeout=3m --issues-exit-code=0 ./sample/...
|
||||||
only-new-issues: true
|
only-new-issues: true
|
||||||
|
|
||||||
test-go-mod-version:
|
test-go-mod-version:
|
||||||
|
needs: [ build ]
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
@@ -44,9 +69,12 @@ jobs:
|
|||||||
- macos-latest
|
- macos-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
working-directory: sample-go-mod
|
working-directory: sample-go-mod
|
||||||
args: --issues-exit-code=0 ./...
|
args: --timeout=3m --issues-exit-code=0 ./...
|
||||||
|
|||||||
19
README.md
19
README.md
@@ -9,6 +9,8 @@ The action runs [golangci-lint](https://github.com/golangci/golangci-lint) and r
|
|||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
|
* `v3.0.0+` requires explicit setup-go installation step prior to using this action: `uses: actions/setup-go@v2`.
|
||||||
|
The `skip-go-installation` option has been removed.
|
||||||
* `v2.0.0+` works with `golangci-lint` version >= `v1.28.3`
|
* `v2.0.0+` works with `golangci-lint` version >= `v1.28.3`
|
||||||
* `v1.2.2` is deprecated due to we forgot to change the minimum version of `golangci-lint` to `v1.28.3` ([issue](https://github.com/golangci/golangci-lint-action/issues/39))
|
* `v1.2.2` is deprecated due to we forgot to change the minimum version of `golangci-lint` to `v1.28.3` ([issue](https://github.com/golangci/golangci-lint-action/issues/39))
|
||||||
* `v1.2.1` works with `golangci-lint` version >= `v1.14.0` ([issue](https://github.com/golangci/golangci-lint-action/issues/39))
|
* `v1.2.1` works with `golangci-lint` version >= `v1.14.0` ([issue](https://github.com/golangci/golangci-lint-action/issues/39))
|
||||||
@@ -27,11 +29,16 @@ on:
|
|||||||
- master
|
- master
|
||||||
- main
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
# Optional: allow read access to pull request. Use with `only-new-issues` option.
|
||||||
|
# pull-requests: read
|
||||||
jobs:
|
jobs:
|
||||||
golangci:
|
golangci:
|
||||||
name: lint
|
name: lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v2
|
uses: golangci/golangci-lint-action@v2
|
||||||
@@ -48,8 +55,9 @@ jobs:
|
|||||||
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
||||||
# only-new-issues: true
|
# only-new-issues: true
|
||||||
|
|
||||||
# Optional: if set to true then the action will use pre-installed Go.
|
# Optional: if set to true then the all caching functionality will be complete disabled,
|
||||||
# skip-go-installation: true
|
# takes precedence over all other caching options.
|
||||||
|
# skip-cache: true
|
||||||
|
|
||||||
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
|
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
|
||||||
# skip-pkg-cache: true
|
# skip-pkg-cache: true
|
||||||
@@ -75,6 +83,10 @@ on:
|
|||||||
- master
|
- master
|
||||||
- main
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
# Optional: allow read access to pull request. Use with `only-new-issues` option.
|
||||||
|
# pull-requests: read
|
||||||
jobs:
|
jobs:
|
||||||
golangci:
|
golangci:
|
||||||
strategy:
|
strategy:
|
||||||
@@ -84,6 +96,7 @@ jobs:
|
|||||||
name: lint
|
name: lint
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v2
|
uses: golangci/golangci-lint-action@v2
|
||||||
@@ -125,7 +138,6 @@ The action was implemented with performance in mind:
|
|||||||
|
|
||||||
For example, in a repository of [golangci-lint](https://github.com/golangci/golangci-lint) running this action without the cache takes 50s, but with cache takes 14s:
|
For example, in a repository of [golangci-lint](https://github.com/golangci/golangci-lint) running this action without the cache takes 50s, but with cache takes 14s:
|
||||||
* in parallel:
|
* in parallel:
|
||||||
* 13s to download Go
|
|
||||||
* 4s to restore 50 MB of cache
|
* 4s to restore 50 MB of cache
|
||||||
* 1s to find and install `golangci-lint`
|
* 1s to find and install `golangci-lint`
|
||||||
* 1s to run `golangci-lint` (it takes 35s without cache)
|
* 1s to run `golangci-lint` (it takes 35s without cache)
|
||||||
@@ -145,7 +157,6 @@ Inside our action we perform 3 steps:
|
|||||||
* restore [cache](https://github.com/actions/cache) of previous analyzes
|
* restore [cache](https://github.com/actions/cache) of previous analyzes
|
||||||
* fetch [action config](https://github.com/golangci/golangci-lint/blob/master/assets/github-action-config.json) and find the latest `golangci-lint` patch version
|
* fetch [action config](https://github.com/golangci/golangci-lint/blob/master/assets/github-action-config.json) and find the latest `golangci-lint` patch version
|
||||||
for needed version (users of this action can specify only minor version of `golangci-lint`). After that install [golangci-lint](https://github.com/golangci/golangci-lint) using [@actions/tool-cache](https://github.com/actions/toolkit/tree/master/packages/tool-cache)
|
for needed version (users of this action can specify only minor version of `golangci-lint`). After that install [golangci-lint](https://github.com/golangci/golangci-lint) using [@actions/tool-cache](https://github.com/actions/toolkit/tree/master/packages/tool-cache)
|
||||||
* install the latest Go 1.x version using [@actions/setup-go](https://github.com/actions/setup-go)
|
|
||||||
2. Run `golangci-lint` with specified by user `args`
|
2. Run `golangci-lint` with specified by user `args`
|
||||||
3. Save cache for later builds
|
3. Save cache for later builds
|
||||||
|
|
||||||
|
|||||||
12
action.yml
12
action.yml
@@ -20,20 +20,22 @@ inputs:
|
|||||||
description: "if set to true and the action runs on a pull request - the action outputs only newly found issues"
|
description: "if set to true and the action runs on a pull request - the action outputs only newly found issues"
|
||||||
default: false
|
default: false
|
||||||
required: true
|
required: true
|
||||||
skip-go-installation:
|
skip-cache:
|
||||||
description: "if set to true then action uses pre-installed Go"
|
description: |
|
||||||
|
if set to true then the all caching functionality will be complete disabled,
|
||||||
|
takes precedence over all other caching options.
|
||||||
default: false
|
default: false
|
||||||
required: true
|
required: true
|
||||||
skip-pkg-cache:
|
skip-pkg-cache:
|
||||||
description: "if set to true then the action don't cache or restore ~/go/pkg."
|
description: "if set to true then the action doesn't cache or restore ~/go/pkg."
|
||||||
default: false
|
default: false
|
||||||
required: true
|
required: true
|
||||||
skip-build-cache:
|
skip-build-cache:
|
||||||
description: "if set to true then the action don't cache or restore ~/.cache/go-build."
|
description: "if set to true then the action doesn't cache or restore ~/.cache/go-build."
|
||||||
default: false
|
default: false
|
||||||
required: true
|
required: true
|
||||||
runs:
|
runs:
|
||||||
using: "node12"
|
using: "node16"
|
||||||
main: "dist/run/index.js"
|
main: "dist/run/index.js"
|
||||||
post: "dist/post_run/index.js"
|
post: "dist/post_run/index.js"
|
||||||
branding:
|
branding:
|
||||||
|
|||||||
110669
dist/post_run/index.js
vendored
110669
dist/post_run/index.js
vendored
File diff suppressed because one or more lines are too long
110677
dist/run/index.js
vendored
110677
dist/run/index.js
vendored
File diff suppressed because one or more lines are too long
4120
package-lock.json
generated
4120
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@@ -1,12 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "golanci-lint-action",
|
"name": "golanci-lint-action",
|
||||||
"version": "2.0.0",
|
"version": "3.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "golangci-lint github action",
|
"description": "golangci-lint github action",
|
||||||
"main": "dist/main.js",
|
"main": "dist/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare-setup-go": "cd node_modules/setup-go && npm run build",
|
|
||||||
"prepare-deps": "npm run prepare-setup-go",
|
|
||||||
"build": "tsc && ncc build -o dist/run/ src/main.ts && ncc build -o dist/post_run/ src/post_main.ts",
|
"build": "tsc && ncc build -o dist/run/ src/main.ts && ncc build -o dist/post_run/ src/post_main.ts",
|
||||||
"watched_build_main": "tsc && ncc build -w -o dist/run/ src/main.ts",
|
"watched_build_main": "tsc && ncc build -w -o dist/run/ src/main.ts",
|
||||||
"watched_build_post_main": "tsc && ncc build -w -o dist/post_run/ src/post_main.ts",
|
"watched_build_post_main": "tsc && ncc build -w -o dist/post_run/ src/post_main.ts",
|
||||||
@@ -15,7 +13,7 @@
|
|||||||
"lint-fix": "eslint **/*.ts --cache --fix",
|
"lint-fix": "eslint **/*.ts --cache --fix",
|
||||||
"format": "prettier --write **/*.ts",
|
"format": "prettier --write **/*.ts",
|
||||||
"format-check": "prettier --check **/*.ts",
|
"format-check": "prettier --check **/*.ts",
|
||||||
"all": "npm run prepare-deps && npm run build && npm run format-check && npm run lint",
|
"all": "npm run build && npm run format-check && npm run lint",
|
||||||
"local": "npm run build && act -j test -b",
|
"local": "npm run build && act -j test -b",
|
||||||
"local-full-version": "npm run build && act -j test-full-version -b"
|
"local-full-version": "npm run build && act -j test-full-version -b"
|
||||||
},
|
},
|
||||||
@@ -26,28 +24,25 @@
|
|||||||
"author": "golangci",
|
"author": "golangci",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^1.0.6",
|
"@actions/cache": "^1.0.9",
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.6.0",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/github": "^4.0.0",
|
"@actions/github": "^5.0.0",
|
||||||
"@actions/tool-cache": "^1.6.1",
|
"@actions/tool-cache": "^1.7.1",
|
||||||
"@types/semver": "^7.3.4",
|
"@types/semver": "^7.3.9",
|
||||||
"@types/tmp": "^0.2.0",
|
"@types/tmp": "^0.2.3",
|
||||||
"setup-go": "git+https://github.com/actions/setup-go.git#v2.1.3",
|
|
||||||
"tmp": "^0.2.1"
|
"tmp": "^0.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^14.14.31",
|
"@typescript-eslint/eslint-plugin": "^5.12.1",
|
||||||
"@types/uuid": "^8.3.0",
|
"@typescript-eslint/parser": "^5.12.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.15.1",
|
"@vercel/ncc": "^0.33.3",
|
||||||
"@typescript-eslint/parser": "^4.15.1",
|
"eslint": "^8.10.0",
|
||||||
"@zeit/ncc": "^0.22.3",
|
"eslint-config-prettier": "^8.4.0",
|
||||||
"eslint": "^7.20.0",
|
"eslint-plugin-import": "^2.25.4",
|
||||||
"eslint-config-prettier": "^8.0.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
"eslint-plugin-import": "^2.22.1",
|
|
||||||
"eslint-plugin-prettier": "^3.3.1",
|
|
||||||
"eslint-plugin-simple-import-sort": "^7.0.0",
|
"eslint-plugin-simple-import-sort": "^7.0.0",
|
||||||
"prettier": "^2.2.1",
|
"prettier": "^2.5.1",
|
||||||
"typescript": "^4.1.5"
|
"typescript": "^4.5.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ async function buildCacheKeys(): Promise<string[]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function restoreCache(): Promise<void> {
|
export async function restoreCache(): Promise<void> {
|
||||||
|
if (core.getInput(`skip-cache`, { required: true }).trim() == "true") return
|
||||||
|
|
||||||
if (!utils.isValidEvent()) {
|
if (!utils.isValidEvent()) {
|
||||||
utils.logWarning(
|
utils.logWarning(
|
||||||
`Event Validation Error: The event type ${process.env[Events.Key]} is not supported because it's not tied to a branch or tag ref.`
|
`Event Validation Error: The event type ${process.env[Events.Key]} is not supported because it's not tied to a branch or tag ref.`
|
||||||
@@ -112,6 +114,8 @@ export async function restoreCache(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function saveCache(): Promise<void> {
|
export async function saveCache(): Promise<void> {
|
||||||
|
if (core.getInput(`skip-cache`, { required: true }).trim() == "true") return
|
||||||
|
|
||||||
// Validate inputs, this can cause task failure
|
// Validate inputs, this can cause task failure
|
||||||
if (!utils.isValidEvent()) {
|
if (!utils.isValidEvent()) {
|
||||||
utils.logWarning(
|
utils.logWarning(
|
||||||
|
|||||||
4
src/deps.d.ts
vendored
4
src/deps.d.ts
vendored
@@ -1,7 +1,3 @@
|
|||||||
declare module "setup-go/lib/main" {
|
|
||||||
function run(): Promise<void>
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module "cache/lib/restore" {
|
declare module "cache/lib/restore" {
|
||||||
function run(): Promise<void>
|
function run(): Promise<void>
|
||||||
export default run
|
export default run
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import * as core from "@actions/core"
|
|||||||
import * as tc from "@actions/tool-cache"
|
import * as tc from "@actions/tool-cache"
|
||||||
import os from "os"
|
import os from "os"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { run as setupGo } from "setup-go/lib/main"
|
|
||||||
|
|
||||||
import { VersionConfig } from "./version"
|
import { VersionConfig } from "./version"
|
||||||
|
|
||||||
@@ -59,16 +58,3 @@ export async function installLint(versionConfig: VersionConfig): Promise<string>
|
|||||||
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`)
|
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`)
|
||||||
return lintPath
|
return lintPath
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
|
||||||
core.info(`Installed Go in ${Date.now() - startedAt}ms`)
|
|
||||||
}
|
|
||||||
|
|||||||
17
src/run.ts
17
src/run.ts
@@ -7,7 +7,7 @@ import { dir } from "tmp"
|
|||||||
import { promisify } from "util"
|
import { promisify } from "util"
|
||||||
|
|
||||||
import { restoreCache, saveCache } from "./cache"
|
import { restoreCache, saveCache } from "./cache"
|
||||||
import { installGo, installLint } from "./install"
|
import { installLint } from "./install"
|
||||||
import { findLintVersion } from "./version"
|
import { findLintVersion } from "./version"
|
||||||
|
|
||||||
const execShellCommand = promisify(exec)
|
const execShellCommand = promisify(exec)
|
||||||
@@ -41,7 +41,7 @@ async function fetchPatch(): Promise<string> {
|
|||||||
const octokit = github.getOctokit(core.getInput(`github-token`, { required: true }))
|
const octokit = github.getOctokit(core.getInput(`github-token`, { required: true }))
|
||||||
let patch: string
|
let patch: string
|
||||||
try {
|
try {
|
||||||
const patchResp = await octokit.pulls.get({
|
const patchResp = await octokit.rest.pulls.get({
|
||||||
owner: ctx.repo.owner,
|
owner: ctx.repo.owner,
|
||||||
repo: ctx.repo.repo,
|
repo: ctx.repo.repo,
|
||||||
[`pull_number`]: pull.number,
|
[`pull_number`]: pull.number,
|
||||||
@@ -85,11 +85,9 @@ async function prepareEnv(): Promise<Env> {
|
|||||||
// Prepare cache, lint and go in parallel.
|
// Prepare cache, lint and go in parallel.
|
||||||
const restoreCachePromise = restoreCache()
|
const restoreCachePromise = restoreCache()
|
||||||
const prepareLintPromise = prepareLint()
|
const prepareLintPromise = prepareLint()
|
||||||
const installGoPromise = installGo()
|
|
||||||
const patchPromise = fetchPatch()
|
const patchPromise = fetchPatch()
|
||||||
|
|
||||||
const lintPath = await prepareLintPromise
|
const lintPath = await prepareLintPromise
|
||||||
await installGoPromise
|
|
||||||
await restoreCachePromise
|
await restoreCachePromise
|
||||||
const patchPath = await patchPromise
|
const patchPath = await patchPromise
|
||||||
|
|
||||||
@@ -121,15 +119,14 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
|
|||||||
const userArgs = core.getInput(`args`)
|
const userArgs = core.getInput(`args`)
|
||||||
const addedArgs: string[] = []
|
const addedArgs: string[] = []
|
||||||
|
|
||||||
const userArgNames = new Set<string>()
|
const userArgNames = new Set<string>(
|
||||||
userArgs
|
userArgs
|
||||||
.split(/\s/)
|
.trim()
|
||||||
|
.split(/\s+/)
|
||||||
.map((arg) => arg.split(`=`)[0])
|
.map((arg) => arg.split(`=`)[0])
|
||||||
.filter((arg) => arg.startsWith(`-`))
|
.filter((arg) => arg.startsWith(`-`))
|
||||||
.forEach((arg) => {
|
.map((arg) => arg.replace(/^-+/, ``))
|
||||||
userArgNames.add(arg.replace(`-`, ``))
|
)
|
||||||
})
|
|
||||||
|
|
||||||
if (userArgNames.has(`out-format`)) {
|
if (userArgNames.has(`out-format`)) {
|
||||||
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`)
|
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||||
"tsBuildInfoFile": ".tsbuildinfo",
|
"tsBuildInfoFile": ".tsbuildinfo",
|
||||||
"incremental": true
|
"incremental": true,
|
||||||
|
"useUnknownInCatchVariables": false
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "**/*.test.ts"]
|
"exclude": ["node_modules", "**/*.test.ts"]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user