Compare commits

...

121 Commits
v6 ... v8

Author SHA1 Message Date
4afd733a84 8.0.0 2025-05-04 22:04:19 +02:00
7774f98a88 feat: use absolute paths by default when using working-directory option (#1231) 2025-05-04 22:03:30 +02:00
9fae48acfc 7.0.1 2025-05-04 21:50:29 +02:00
16ece5e01d docs: clarify that ’args: --path-mode=abs’ is needed for working-directory (#1230) 2025-05-04 21:41:49 +02:00
a3942e2497 build(deps-dev): bump the dev-dependencies group with 2 updates (#1227) 2025-04-21 13:33:46 +02:00
7ecb048b56 build(deps): bump @types/node from 22.14.0 to 22.14.1 in the dependencies group (#1225) 2025-04-14 13:18:59 +02:00
63a0d0e695 build(deps-dev): bump the dev-dependencies group with 3 updates (#1224) 2025-04-14 13:18:33 +02:00
c2427fec79 docs: update problem matchers section 2025-04-07 17:34:24 +02:00
642f8ee631 build(deps): bump @types/node from 22.13.14 to 22.14.0 in the dependencies group (#1221) 2025-04-07 12:46:39 +02:00
d84be9250b build(deps-dev): bump the dev-dependencies group with 4 updates (#1220) 2025-04-07 12:46:14 +02:00
9551b25870 docs: typos and notes 2025-04-04 05:13:59 +02:00
f51fbec16f docs: add note about github.workspace (#1218)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2025-04-04 04:18:50 +02:00
a5307c8f68 build(deps-dev): bump the dev-dependencies group with 3 updates (#1215) 2025-03-31 15:10:29 +02:00
2968cc1a32 build(deps): bump the dependencies group across 1 directory with 3 updates (#1213)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2025-03-30 00:34:56 +01:00
1481404843 7.0.0 2025-03-24 15:20:12 +01:00
dec74fa030 feat: golangci-lint v2 support (#1198) 2025-03-24 15:16:39 +01:00
1f07148fa0 build(deps-dev): bump the dev-dependencies group with 3 updates (#1207)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2025-03-24 13:11:28 +01:00
9938e103f8 docs: fix checks permissions for annotations (#1204) 2025-03-19 12:23:45 +00:00
b91d580160 docs: update annotation permissions (#1203) 2025-03-19 00:29:57 +01:00
55c2c1448f 6.5.2 2025-03-17 22:50:27 +01:00
911ec56a22 fix: update max version (#1201) 2025-03-17 22:47:30 +01:00
eb5c0cc489 build(deps-dev): bump the dev-dependencies group with 2 updates (#1199) 2025-03-17 14:00:10 +01:00
4696ba8bab 6.5.1 2025-03-12 17:11:46 +01:00
2ee514f1f3 feat: restrict action v6 on golangci-lint v1 (#1194) 2025-03-12 17:10:24 +01:00
7e7b516e44 fix: octokit retry (#1193) 2025-03-12 17:09:01 +01:00
b871b4f9de build(deps): bump @types/node from 22.13.8 to 22.13.10 in the dependencies group (#1192) 2025-03-10 13:52:35 +01:00
08ba820282 build(deps-dev): bump eslint-config-prettier from 10.0.2 to 10.1.1 in the dev-dependencies group (#1191) 2025-03-10 13:52:11 +01:00
d8648ac2ed build(deps-dev): bump the dev-dependencies group across 1 directory with 5 updates (#1190) 2025-03-06 21:03:25 +01:00
37d62ae433 build(deps): bump the dependencies group with 2 updates (#1189)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2025-03-03 11:53:20 +00:00
7b561e5ab6 build(deps): bump @octokit/plugin-paginate-rest from 9.2.1 to 9.2.2 (#1187)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2025-02-24 13:11:36 +00:00
b63dc836c2 build(deps): bump @types/node from 22.13.4 to 22.13.5 in the dependencies group (#1186) 2025-02-24 13:44:21 +01:00
e8b0a12b47 build(deps-dev): bump the dev-dependencies group with 3 updates (#1185) 2025-02-24 13:43:55 +01:00
456fc0f735 docs: update examples 2025-02-22 19:01:11 +01:00
378320cf0d build(deps): bump @octokit/request from 8.4.0 to 8.4.1 (#1181)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2025-02-19 00:38:38 +01:00
0bc16cda6e build(deps): bump the dependencies group with 2 updates (#1178)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2025-02-17 13:01:26 +00:00
0f27d1f085 build(deps-dev): bump the dev-dependencies group with 3 updates (#1177) 2025-02-17 13:43:55 +01:00
3b4f037d0e docs: improve verify option explanation (#1175) 2025-02-17 05:54:54 +01:00
fe19838e9e docs: add notes for annotation config (#1173) 2025-02-16 18:21:00 +00:00
2226d7cb06 6.5.0 2025-02-15 15:16:43 +01:00
8d744d5b7f feat: verify with the JSONSchema by default (#1171) 2025-02-15 15:02:58 +01:00
0e58f8e7ab build(deps): bump @octokit/endpoint from 9.0.5 to 9.0.6 (#1170)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2025-02-15 04:31:44 +01:00
6a3fb764d5 build(deps): bump @octokit/request-error from 5.1.0 to 5.1.1 (#1169)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2025-02-15 03:19:17 +01:00
696fa5c0e7 chore: clean workflows 2025-02-15 02:47:53 +01:00
80284ede25 chore: use ubuntu-22.04-arm
ubuntu-24.04-arm is too unstable
2025-02-14 22:19:04 +01:00
818ec4d51a 6.4.1 2025-02-14 13:57:12 +01:00
1c50240be2 fix: use config arg for verify (#1168) 2025-02-14 13:56:21 +01:00
0adbc47a59 6.4.0 2025-02-13 23:15:38 +01:00
f7463c56f6 feat: add an option to verify with the JSONSchema (#1167) 2025-02-13 23:14:24 +01:00
32f961426b chore: extract patch related code (#1166) 2025-02-13 22:16:32 +01:00
e0ebdd245e 6.3.3 2025-02-13 13:37:15 +01:00
ea34ee71d6 fix: go.mod parsing (#1165) 2025-02-13 13:35:39 +01:00
051d919338 6.3.2 2025-02-10 15:34:05 +01:00
b85ce4ff0a fix: path patch (#1162) 2025-02-10 15:33:29 +01:00
d9c129682c build(deps-dev): bump prettier from 3.4.2 to 3.5.0 in the dev-dependencies group (#1160) 2025-02-10 13:32:23 +01:00
db1c463e05 docs: move dev information into contribution guide 2025-02-09 03:07:48 +01:00
697ae3d965 docs: information about releases 2025-02-09 02:31:53 +01:00
2e788936b0 6.3.1 2025-02-09 02:26:54 +01:00
aa1e0941ed chore: update golangci-lint versions (#1159) 2025-02-09 02:22:47 +01:00
3e6beafdff fix: restrict patched version to v1 (#1158) 2025-02-09 02:03:24 +01:00
1cc4e007f0 build(deps): bump @types/node from 22.13.0 to 22.13.1 in the dependencies group (#1156) 2025-02-04 16:56:20 +01:00
bbe109d3f8 build(deps-dev): bump the dev-dependencies group with 2 updates (#1155) 2025-02-04 16:55:56 +01:00
e60da84bfa chore: update branch references 2025-02-04 15:39:52 +01:00
1dd93d052e chore: use new assets file (#1154) 2025-02-04 15:15:08 +01:00
5421a116d2 build(deps): bump @types/node from 22.10.10 to 22.13.0 in the dependencies group (#1153) 2025-02-03 12:48:00 +01:00
260e8cefdb build(deps-dev): bump the dev-dependencies group with 2 updates (#1152) 2025-02-03 12:47:31 +01:00
9665fb5353 build(deps): bump undici from 5.28.4 to 5.28.5 (#1150)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2025-01-27 12:12:42 +00:00
62530743f6 build(deps): bump @types/node from 22.10.7 to 22.10.10 in the dependencies group (#1149) 2025-01-27 12:43:58 +01:00
f71f362e47 build(deps-dev): bump the dev-dependencies group with 2 updates (#1148) 2025-01-27 12:43:11 +01:00
7ec71f69b1 build(deps): bump the dependencies group with 2 updates (#1147)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2025-01-20 18:21:27 +01:00
60c0fc4730 build(deps-dev): bump the dev-dependencies group with 4 updates (#1146) 2025-01-20 16:19:41 +01:00
a7b658d295 docs: update README options version from required to optional (#1145) 2025-01-17 12:24:51 +01:00
ec5d18412c feat: support linux arm64 public preview (#1144) 2025-01-16 21:40:47 +01:00
a0297a1378 build(deps-dev): bump the dev-dependencies group with 3 updates (#1143) 2025-01-13 12:28:21 +01:00
58eda26a51 build(deps): bump @types/node from 22.10.2 to 22.10.5 in the dependencies group (#1142) 2025-01-06 12:56:48 +01:00
44c2434506 build(deps-dev): bump the dev-dependencies group with 2 updates (#1141) 2025-01-06 12:56:21 +01:00
2f13b8027d build(deps-dev): bump the dev-dependencies group with 2 updates (#1139) 2024-12-30 16:15:31 +01:00
1ac36865a6 build(deps-dev): bump the dev-dependencies group with 2 updates (#1138) 2024-12-23 13:54:34 +01:00
9937fdf718 build(deps): bump @types/node from 22.10.1 to 22.10.2 in the dependencies group (#1137) 2024-12-16 15:55:46 +01:00
cb60b26e7a build(deps-dev): bump the dev-dependencies group with 2 updates (#1136) 2024-12-16 15:55:21 +01:00
774c35bccc build(deps): bump @actions/cache from 3.3.0 to 4.0.0 in the dependencies group (#1135)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-12-09 14:21:16 +01:00
7ce548721e build(deps-dev): bump the dev-dependencies group with 3 updates (#1134) 2024-12-09 14:06:45 +01:00
0e1fd32b0c chore: use new build tag syntax (#1133) 2024-12-04 18:03:01 +01:00
9e66d46e22 build(deps-dev): bump the dev-dependencies group across 1 directory with 4 updates (#1132)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-12-02 12:54:29 +01:00
1720a0ed2a build(deps): bump @types/node from 22.9.3 to 22.10.1 in the dependencies group (#1131) 2024-12-02 12:43:56 +01:00
eab1d2f3d7 build(deps): bump @types/node from 22.9.0 to 22.9.3 in the dependencies group (#1130) 2024-11-25 12:53:46 +01:00
160a1d779c build(deps-dev): bump the dev-dependencies group with 3 updates (#1128) 2024-11-18 14:11:50 +01:00
02ee5067dc build(deps): bump @types/node from 22.8.7 to 22.9.0 in the dependencies group (#1127) 2024-11-11 11:37:34 +01:00
311e61576a build(deps-dev): bump the dev-dependencies group with 2 updates (#1126) 2024-11-11 11:37:09 +01:00
363026db34 docs: update local development instructions (#1125)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-11-08 21:40:36 +01:00
ea0c88120e build(deps): bump the dependencies group with 2 updates (#1123)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-11-04 12:52:08 +01:00
968ad765a9 build(deps-dev): bump the dev-dependencies group with 2 updates (#1122) 2024-11-04 11:09:49 +01:00
82fb3f49c2 build(deps): bump @types/node from 22.7.7 to 22.8.1 in the dependencies group (#1120) 2024-10-28 11:02:46 +01:00
10480e9d12 build(deps-dev): bump the dev-dependencies group with 2 updates (#1119) 2024-10-28 11:02:23 +01:00
523baec228 build(deps): bump @types/node from 22.7.5 to 22.7.7 in the dependencies group (#1118) 2024-10-21 13:35:58 +02:00
8e06968c92 build(deps-dev): bump the dev-dependencies group with 2 updates (#1117) 2024-10-21 13:35:36 +02:00
79a180da27 build(deps): bump @types/node from 22.7.4 to 22.7.5 in the dependencies group (#1115) 2024-10-14 13:18:25 +02:00
b92645ea9c build(deps-dev): bump the dev-dependencies group with 3 updates (#1114) 2024-10-14 13:18:08 +02:00
3d4174dbf5 build(deps): bump the dependencies group with 2 updates (#1113)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-10-07 17:31:44 +02:00
0ddaf3ca3f build(deps-dev): bump the dev-dependencies group with 3 updates (#1112) 2024-10-07 16:09:16 +02:00
971e284b60 build(deps-dev): bump the dev-dependencies group with 3 updates (#1108)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-09-30 15:40:11 +02:00
bbe7eb52aa build(deps): bump @types/node from 22.5.5 to 22.7.4 in the dependencies group (#1109) 2024-09-30 14:07:00 +02:00
ebae5cee81 build(deps-dev): bump the dev-dependencies group with 3 updates (#1105) 2024-09-23 13:24:35 +02:00
06c3f3a551 build(deps): bump @types/node from 22.5.4 to 22.5.5 in the dependencies group (#1104) 2024-09-16 13:51:57 +02:00
56689d8f71 build(deps-dev): bump the dev-dependencies group with 3 updates (#1103) 2024-09-16 13:51:34 +02:00
c7bab6f874 fix: clean go install output (#1102) 2024-09-13 00:04:49 +02:00
33f56cc1ef build(deps-dev): bump the dev-dependencies group with 3 updates (#1099) 2024-09-09 14:48:59 +02:00
e9542245b2 build(deps): bump @types/node from 22.5.2 to 22.5.4 in the dependencies group (#1100) 2024-09-09 14:48:37 +02:00
68de804037 build(deps): bump @types/node from 22.5.1 to 22.5.2 in the dependencies group (#1098) 2024-09-02 14:02:11 +02:00
22a37566e1 build(deps-dev): bump the dev-dependencies group with 2 updates (#1097) 2024-09-02 14:01:40 +02:00
cb36b7b064 build(deps): bump the dependencies group across 1 directory with 2 updates (#1096)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-08-29 21:53:11 +02:00
acfc9fc846 build(deps): bump the dependencies group with 2 updates (#1089)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2024-08-29 20:33:04 +02:00
1b319a7ae6 build(deps-dev): bump the dev-dependencies group with 2 updates (#1093) 2024-08-29 20:32:40 +02:00
0ad4b72404 build(deps-dev): bump the dev-dependencies group with 2 updates (#1088) 2024-08-19 13:50:59 +02:00
de8531069f docs: update README.md to use golangci-lint v1.60 (#1087) 2024-08-18 15:31:41 +00:00
2af9b8ff01 tests: update test files 2024-08-18 17:23:19 +02:00
8cae750416 chore: update golangci-lint test versions 2024-08-18 17:18:43 +02:00
656a8d69e8 chore: update golangci-lint test versions 2024-08-18 17:16:15 +02:00
a3d68bc6f4 build(deps): bump @types/node from 22.1.0 to 22.2.0 in the dependencies group (#1085) 2024-08-12 17:51:05 +02:00
806a9afa81 build(deps-dev): bump the dev-dependencies group with 2 updates (#1084) 2024-08-12 17:50:46 +02:00
e135904846 build(deps): bump @types/node from 22.0.0 to 22.1.0 in the dependencies group (#1083) 2024-08-05 16:31:47 +02:00
931e87202e build(deps-dev): bump the dev-dependencies group with 2 updates (#1082) 2024-08-05 16:31:23 +02:00
24 changed files with 22970 additions and 6405 deletions

View File

@ -2,10 +2,12 @@ name: "Code Scanning - Action"
on: on:
push: push:
branches: [ master ] branches:
- main
pull_request: pull_request:
# The branches below must be a subset of the branches above # The branches below must be a subset of the branches above
branches: [ master ] branches:
- main
schedule: schedule:
- cron: '0 17 * * 5' - cron: '0 17 * * 5'

View File

@ -1,10 +1,11 @@
name: "build-and-test" name: "build-and-test"
on: # rebuild any PRs and main branch changes on: # rebuild any PRs and main branch changes
pull_request: pull_request:
branches:
- main
push: push:
branches: branches:
- master - main
- "releases/*"
jobs: jobs:
build: # make sure build/ci work properly build: # make sure build/ci work properly
@ -47,13 +48,14 @@ jobs:
matrix: matrix:
os: os:
- ubuntu-latest - ubuntu-latest
- ubuntu-22.04-arm
- macos-latest - macos-latest
- windows-latest - windows-latest
version: version:
- "" - ""
- "latest" - "latest"
- "v1.58" - "v2.1"
- "v1.58.0" - "v2.1.0"
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
permissions: permissions:
contents: read contents: read
@ -75,13 +77,14 @@ jobs:
matrix: matrix:
os: os:
- ubuntu-latest - ubuntu-latest
- ubuntu-22.04-arm
- macos-latest - macos-latest
- windows-latest - windows-latest
version: version:
- "" - ""
- "latest" - "latest"
- "v1.58.0" - "v2.1.0"
- "4bf574a12bb61234e28e3d6172be6ed95b0e8baf" - "f6c2e6c999dfae444d1fe7f1b0d49becdae44547"
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
permissions: permissions:
contents: read contents: read
@ -98,14 +101,18 @@ jobs:
only-new-issues: true only-new-issues: true
install-mode: goinstall install-mode: goinstall
test-go-mod-version: test-go-mod:
needs: [ build ] needs: [ build ]
strategy: strategy:
matrix: matrix:
os: os:
- ubuntu-latest - ubuntu-latest
- ubuntu-22.04-arm
- macos-latest - macos-latest
- windows-latest - windows-latest
wd:
- sample-go-mod
- sample-go-tool
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
permissions: permissions:
contents: read contents: read
@ -116,5 +123,5 @@ jobs:
go-version: oldstable go-version: oldstable
- uses: ./ - uses: ./
with: with:
working-directory: sample-go-mod working-directory: ${{ matrix.wd }}
args: --timeout=5m --issues-exit-code=0 ./... args: --timeout=5m --issues-exit-code=0 ./...

2
.gitignore vendored
View File

@ -6,7 +6,7 @@ __tests__/runner/*
node_modules/ node_modules/
lib/ lib/
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore # Rest pulled from https://github.com/github/gitignore/blob/HEAD/Node.gitignore
# Logs # Logs
logs logs
*.log *.log

7
.golangci.yml Normal file
View File

@ -0,0 +1,7 @@
version: "2"
output:
show-stats: true
sort-order:
- file
- linter

View File

@ -23,3 +23,21 @@
* Ensure the PR description clearly describes the problem and solution. * Ensure the PR description clearly describes the problem and solution.
Include the relevant issue number if applicable. Include the relevant issue number if applicable.
## Development of this action
1. Install [act](https://github.com/nektos/act#installation)
2. Make a symlink for `act` to work properly: `ln -s . golangci-lint-action`
3. Install dependencies: `npm install`
4. Build: `npm run build`
5. Run `npm run local` after any change to test it
### Releases
```bash
npm version <major | minor | patch> -m "Upgrade to %s"
```
- https://docs.npmjs.com/cli/v11/commands/npm-version
The "major tag" (ex: `v6`) should be deleted and then recreated manually.

130
README.md
View File

@ -12,13 +12,13 @@ The action runs [golangci-lint](https://github.com/golangci/golangci-lint) and r
## Supporting Us ## Supporting Us
<!-- [![GitHub Sponsors](https://img.shields.io/badge/GitHub-Donate-blue?logo=github&style=for-the-badge)](https://github.com/sponsors/golangci) --> [![GitHub Sponsors](https://img.shields.io/badge/GitHub-Donate-blue?logo=github&style=for-the-badge)](https://github.com/sponsors/golangci)
[![Open Collective backers and sponsors](https://img.shields.io/badge/OpenCollective-Donate-blue?logo=opencollective&style=for-the-badge)](https://opencollective.com/golangci-lint) [![Open Collective backers and sponsors](https://img.shields.io/badge/OpenCollective-Donate-blue?logo=opencollective&style=for-the-badge)](https://opencollective.com/golangci-lint)
[![Linter Authors](https://img.shields.io/badge/Linter_Authors-Donate-blue?style=for-the-badge)](https://golangci-lint.run/product/thanks/) [![Linter Authors](https://img.shields.io/badge/Linter_Authors-Donate-blue?style=for-the-badge)](https://golangci-lint.run/product/thanks/)
`golangci-lint` is a free and open-source project built by volunteers. `golangci-lint` is a free and open-source project built by volunteers.
If you value it, consider supporting us, we appreciate it! :heart: If you value it, consider supporting us; we appreciate it! :heart:
## How to use ## How to use
@ -54,9 +54,9 @@ jobs:
with: with:
go-version: stable go-version: stable
- name: golangci-lint - name: golangci-lint
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v8
with: with:
version: v1.59 version: v2.1
``` ```
</details> </details>
@ -92,9 +92,9 @@ jobs:
with: with:
go-version: ${{ matrix.go }} go-version: ${{ matrix.go }}
- name: golangci-lint - name: golangci-lint
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v8
with: with:
version: v1.59 version: v2.1
``` ```
You will also likely need to add the following `.gitattributes` file to ensure that line endings for Windows builds are properly formatted: You will also likely need to add the following `.gitattributes` file to ensure that line endings for Windows builds are properly formatted:
@ -115,12 +115,12 @@ on:
pull_request: pull_request:
push: push:
branches: branches:
- "main" - main
- "master" - master
env: env:
GO_VERSION: stable GO_VERSION: stable
GOLANGCI_LINT_VERSION: v1.59 GOLANGCI_LINT_VERSION: v2.1
jobs: jobs:
detect-modules: detect-modules:
@ -147,7 +147,7 @@ jobs:
with: with:
go-version: ${{ env.GO_VERSION }} go-version: ${{ env.GO_VERSION }}
- name: golangci-lint ${{ matrix.modules }} - name: golangci-lint ${{ matrix.modules }}
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v8
with: with:
version: ${{ env.GOLANGCI_LINT_VERSION }} version: ${{ env.GOLANGCI_LINT_VERSION }}
working-directory: ${{ matrix.modules }} working-directory: ${{ matrix.modules }}
@ -166,8 +166,8 @@ on:
pull_request: pull_request:
push: push:
branches: branches:
- "main" - main
- "master" - master
jobs: jobs:
golangci-lint: golangci-lint:
@ -179,7 +179,7 @@ jobs:
with: with:
os: ${{ matrix.os }} os: ${{ matrix.os }}
go-version: ${{ matrix.go-version }} go-version: ${{ matrix.go-version }}
golangci-lint-version: v1.59 golangci-lint-version: v2.1
``` ```
```yaml ```yaml
@ -201,7 +201,7 @@ on:
golangci-lint-version: golangci-lint-version:
description: 'Golangci-lint version' description: 'Golangci-lint version'
type: string type: string
default: 'v1.59.1' default: 'v2.1'
jobs: jobs:
detect-modules: detect-modules:
@ -229,7 +229,7 @@ jobs:
with: with:
go-version: ${{ inputs.go-version }} go-version: ${{ inputs.go-version }}
- name: golangci-lint ${{ matrix.modules }} - name: golangci-lint ${{ matrix.modules }}
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v8
with: with:
version: ${{ inputs.golangci-lint-version }} version: ${{ inputs.golangci-lint-version }}
working-directory: ${{ matrix.modules }} working-directory: ${{ matrix.modules }}
@ -245,34 +245,36 @@ You will also likely need to add the following `.gitattributes` file to ensure t
## Compatibility ## Compatibility
* `v8.0.0` works with `golangci-lint` version >= `v2.1.0`
* `v7.0.0` supports golangci-lint v2 only.
* `v6.0.0+` removes `annotations` option, removes the default output format (`github-actions`). * `v6.0.0+` removes `annotations` option, removes the default output format (`github-actions`).
* `v5.0.0+` removes `skip-pkg-cache` and `skip-build-cache` because the cache related to Go itself is already handled by `actions/setup-go`. * `v5.0.0+` removes `skip-pkg-cache` and `skip-build-cache` because the cache related to Go itself is already handled by `actions/setup-go`.
* `v4.0.0+` requires an explicit `actions/setup-go` installation step before using this action: `uses: actions/setup-go@v5`. * `v4.0.0+` requires an explicit `actions/setup-go` installation step before using this action: `uses: actions/setup-go@v5`.
The `skip-go-installation` option has been removed. 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 because 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))
## Options ## Options
### `version` ### `version`
(required) (optional)
The version of golangci-lint to use. The version of golangci-lint to use.
When `install-mode` is: When `install-mode` is:
* `binary` (default): the value can be v1.2 or v1.2.3 or `latest` to use the latest version. * `binary` (default): the value can be v2.3 or v2.3.4 or `latest` to use the latest version.
* `goinstall`: the value can be v1.2.3, `latest`, or the hash of a commit. * `goinstall`: the value can be v2.3.4, `latest`, or the hash of a commit.
* `none`: the value is ignored. * `none`: the value is ignored.
<details> <details>
<summary>Example</summary> <summary>Example</summary>
```yml ```yml
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v8
with: with:
version: v1.58 version: v2.1
# ... # ...
``` ```
@ -290,7 +292,7 @@ The default value is `binary`.
<summary>Example</summary> <summary>Example</summary>
```yml ```yml
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v8
with: with:
install-mode: "goinstall" install-mode: "goinstall"
# ... # ...
@ -310,7 +312,7 @@ By default, it uses the `github.token` from the action.
<summary>Example</summary> <summary>Example</summary>
```yml ```yml
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v8
with: with:
github-token: xxx github-token: xxx
# ... # ...
@ -318,6 +320,29 @@ with:
</details> </details>
### `verify`
(optional)
This option is `true` by default.
If the GitHub Action detects a configuration file, the validation will be performed unless this option is set to `false`.
If there is no configuration file, the validation is skipped.
The JSON Schema used to validate the configuration depends on the version of golangci-lint you are using.
<details>
<summary>Example</summary>
```yml
uses: golangci/golangci-lint-action@v8
with:
verify: false
# ...
```
</details>
### `only-new-issues` ### `only-new-issues`
(optional) (optional)
@ -326,8 +351,8 @@ Show only new issues.
The default value is `false`. The default value is `false`.
* `pull_request` and `pull_request_target`: the action gets the diff of the PR content from the [GitHub API](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request) and use it with `--new-from-patch`. * `pull_request` and `pull_request_target`: the action gets the diff of the PR content from the [GitHub API](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request) and uses it with `--new-from-patch`.
* `push`: the action gets the diff of the push content (difference between commits before and after the push) from the [GitHub API](https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#compare-two-commits) and use it with `--new-from-patch`. * `push`: the action gets the diff of the push content (difference between commits before and after the push) from the [GitHub API](https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#compare-two-commits) and uses it with `--new-from-patch`.
* `merge_group`: the action gets the diff by using `--new-from-rev` option (relies on git). * `merge_group`: the action gets the diff by using `--new-from-rev` option (relies on git).
You should add the option `fetch-depth: 0` to `actions/checkout` step. You should add the option `fetch-depth: 0` to `actions/checkout` step.
@ -335,7 +360,7 @@ The default value is `false`.
<summary>Example</summary> <summary>Example</summary>
```yml ```yml
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v8
with: with:
only-new-issues: true only-new-issues: true
# ... # ...
@ -353,7 +378,7 @@ Working directory, useful for monorepos.
<summary>Example</summary> <summary>Example</summary>
```yml ```yml
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v8
with: with:
working-directory: somedir working-directory: somedir
# ... # ...
@ -367,16 +392,22 @@ with:
golangci-lint command line arguments. golangci-lint command line arguments.
Note: By default, the `.golangci.yml` file should be at the root of the repository. > [!NOTE]
The location of the configuration file can be changed by using `--config=` > By default, the `.golangci.yml` file should be at the root of the repository.
> The location of the configuration file can be changed by using `--config=`.
> [!IMPORTANT]
> Adding a `=` between the flag name and its value is important because the action parses the arguments on spaces.
<details> <details>
<summary>Example</summary> <summary>Example</summary>
```yml ```yml
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v8
with: with:
args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0 # In some rare cases,
# you could have to use `${{ github.workspace }}` as base directory to reference your configuration file.
args: --config=/my/path/.golangci.yml --issues-exit-code=0
# ... # ...
``` ```
@ -388,9 +419,9 @@ with:
Force the usage of the embedded problem matchers. Force the usage of the embedded problem matchers.
By default, the [problem matcher of Go (`actions/setup-go`)](https://github.com/actions/setup-go/blob/main/matchers.json) already handles the golangci-lint output (`colored-line-number`). By default, the [problem matcher of Go (`actions/setup-go`)](https://github.com/actions/setup-go/blob/main/matchers.json) already handles the default golangci-lint output (`text`).
Works only with `colored-line-number` (the golangci-lint default). Works only with `text` format (the golangci-lint default).
https://golangci-lint.run/usage/configuration/#output-configuration https://golangci-lint.run/usage/configuration/#output-configuration
@ -400,7 +431,7 @@ The default value is `false`.
<summary>Example</summary> <summary>Example</summary>
```yml ```yml
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v8
with: with:
problem-matchers: true problem-matchers: true
# ... # ...
@ -421,7 +452,7 @@ The default value is `false`.
<summary>Example</summary> <summary>Example</summary>
```yml ```yml
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v8
with: with:
skip-cache: true skip-cache: true
# ... # ...
@ -433,7 +464,7 @@ with:
(optional) (optional)
If set to `true`, caches will not be saved, but they may still be restored, required `skip-cache: false`. If set to `true`, caches will not be saved, but they may still be restored, requiring `skip-cache: false`.
The default value is `false`. The default value is `false`.
@ -441,7 +472,7 @@ The default value is `false`.
<summary>Example</summary> <summary>Example</summary>
```yml ```yml
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v8
with: with:
skip-save-cache: true skip-save-cache: true
# ... # ...
@ -457,13 +488,13 @@ Periodically invalidate the cache every `cache-invalidation-interval` days to en
The default value is `7`. The default value is `7`.
If set the number is `<= 0`, the cache will be always invalidate (Not recommended). If the number is `<= 0`, the cache will always be invalidated (Not recommended).
<details> <details>
<summary>Example</summary> <summary>Example</summary>
```yml ```yml
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v8
with: with:
cache-invalidation-interval: 15 cache-invalidation-interval: 15
# ... # ...
@ -482,7 +513,7 @@ The restrictions of annotations are the following:
If you would like to have comments - please, up-vote [the issue](https://github.com/golangci/golangci-lint-action/issues/5). If you would like to have comments - please, up-vote [the issue](https://github.com/golangci/golangci-lint-action/issues/5).
3. The number of annotations is [limited](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md#limitations). 3. The number of annotations is [limited](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md#limitations).
To enable annotations, you need to add the `checks` permission to your action. Permissions required:
```yaml annotate ```yaml annotate
permissions: permissions:
@ -490,15 +521,15 @@ permissions:
contents: read contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option. # Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read pull-requests: read
# Optional: allow write access to checks to allow the action to annotate code in the PR.
checks: write
``` ```
For annotations to work, use the default format output (`text`) and either use `actions/setup-go` in the job or enable the internal [problem matchers](#problem-matchers).
## Performance ## Performance
The action was implemented with performance in mind: The action was implemented with performance in mind:
1. We cache data from golangci-lint analysis between builds by using [@actions/cache](https://github.com/actions/toolkit/tree/master/packages/cache). 1. We cache data from golangci-lint analysis between builds by using [@actions/cache](https://github.com/actions/toolkit/tree/HEAD/packages/cache).
2. We don't use Docker because image pulling is slow. 2. We don't use Docker because image pulling is slow.
3. We do as much as we can in parallel, e.g. we download cache, and golangci-lint binary in parallel. 3. We do as much as we can in parallel, e.g. we download cache, and golangci-lint binary in parallel.
@ -514,7 +545,7 @@ We use JavaScript-based action.
We don't use Docker-based action because: We don't use Docker-based action because:
1. Docker pulling is slow currently 1. Docker pulling is slow currently
2. it's easier to use caching from [@actions/cache](https://github.com/actions/toolkit/tree/master/packages/cache) 2. it's easier to use caching from [@actions/cache](https://github.com/actions/toolkit/tree/HEAD/packages/cache)
We support different platforms, such as `ubuntu`, `macos`, and `windows` with `x32` and `x64` archs. We support different platforms, such as `ubuntu`, `macos`, and `windows` with `x32` and `x64` archs.
@ -522,9 +553,9 @@ Inside our action, we perform 3 steps:
1. Setup environment running in parallel: 1. Setup environment running in parallel:
* restore [cache](https://github.com/actions/cache) of previous analyses * restore [cache](https://github.com/actions/cache) of previous analyses
* 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 * fetch [action config](https://github.com/golangci/golangci-lint/blob/HEAD/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`). (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) After that install [golangci-lint](https://github.com/golangci/golangci-lint) using [@actions/tool-cache](https://github.com/actions/toolkit/tree/HEAD/packages/tool-cache)
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
@ -539,10 +570,3 @@ Inside our action, we perform 3 steps:
GitHub matches keys by prefix if we have no exact match for the primary cache. GitHub matches keys by prefix if we have no exact match for the primary cache.
This scheme is basic and needs improvements. Pull requests and ideas are welcome. This scheme is basic and needs improvements. Pull requests and ideas are welcome.
## Development of this action
1. Install [act](https://github.com/nektos/act#installation)
2. Make a symlink for `act` to work properly: `ln -s . golangci-lint-action`
3. Prepare deps once: `npm run prepare-deps`
4. Run `npm run local` after any change to test it

View File

@ -7,8 +7,8 @@ inputs:
description: | description: |
The version of golangci-lint to use. The version of golangci-lint to use.
When `install-mode` is: When `install-mode` is:
- `binary` (default): the value can be v1.2 or v1.2.3 or `latest` to use the latest version. - `binary` (default): the value can be v2.3 or v2.3.4 or `latest` to use the latest version.
- `goinstall`: the value can be v1.2.3, `latest`, or the hash of a commit. - `goinstall`: the value can be v2.3.4, `latest`, or the hash of a commit.
- `none`: the value is ignored. - `none`: the value is ignored.
required: false required: false
install-mode: install-mode:
@ -22,6 +22,10 @@ inputs:
description: "the token is used for fetching patch of a pull request to show only new issues" description: "the token is used for fetching patch of a pull request to show only new issues"
default: ${{ github.token }} default: ${{ github.token }}
required: false required: false
verify:
description: "if set to true and the action verify the configuration file against the JSONSchema"
default: 'true'
required: false
only-new-issues: only-new-issues:
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'

12815
dist/post_run/index.js generated vendored

File diff suppressed because one or more lines are too long

12815
dist/run/index.js generated vendored

File diff suppressed because one or more lines are too long

2
go.mod
View File

@ -1,3 +1,3 @@
module github.com/golangci/golangci-lint-action module github.com/golangci/golangci-lint-action
go 1.14 go 1.23

652
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "golanci-lint-action", "name": "golanci-lint-action",
"version": "3.1.0", "version": "8.0.0",
"private": true, "private": true,
"description": "golangci-lint github action", "description": "golangci-lint github action",
"main": "dist/main.js", "main": "dist/main.js",
@ -24,29 +24,30 @@
"author": "golangci", "author": "golangci",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^3.2.4", "@actions/cache": "^4.0.3",
"@actions/core": "^1.10.1", "@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/github": "^6.0.0", "@actions/github": "^6.0.0",
"@actions/http-client": "^2.2.1", "@actions/http-client": "^2.2.3",
"@actions/tool-cache": "^2.0.1", "@octokit/plugin-retry": "^6.1.0",
"@types/node": "^22.0.0", "@actions/tool-cache": "^2.0.2",
"@types/semver": "^7.5.8", "@types/node": "^22.14.1",
"@types/semver": "^7.7.0",
"@types/tmp": "^0.2.6", "@types/tmp": "^0.2.6",
"@types/which": "^3.0.4", "@types/which": "^3.0.4",
"tmp": "^0.2.3", "tmp": "^0.2.3",
"which": "^4.0.0" "which": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^7.17.0", "@typescript-eslint/eslint-plugin": "^8.30.1",
"@typescript-eslint/parser": "^7.17.0", "@typescript-eslint/parser": "^8.30.1",
"@vercel/ncc": "^0.38.1", "@vercel/ncc": "^0.38.3",
"eslint": "^8.57.0", "eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^10.1.2",
"eslint-plugin-import": "^2.29.1", "eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.1", "eslint-plugin-prettier": "^5.2.6",
"eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-simple-import-sort": "^12.1.1",
"prettier": "^3.3.3", "prettier": "^3.5.3",
"typescript": "^5.5.4" "typescript": "^5.8.3"
} }
} }

View File

@ -0,0 +1,7 @@
version: "2"
output:
show-stats: true
sort-order:
- file
- linter

View File

@ -1,179 +1,205 @@
module sample module sample
go 1.19 go 1.23.0
require github.com/golangci/golangci-lint v1.51.2 require github.com/golangci/golangci-lint/v2 v2.1.5
require ( require (
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect 4d63.com/gocheckcompilerdirectives v1.3.0 // indirect
4d63.com/gochecknoglobals v0.2.1 // indirect 4d63.com/gochecknoglobals v0.2.2 // indirect
github.com/Abirdcfly/dupword v0.0.9 // indirect github.com/4meepo/tagalign v1.4.2 // indirect
github.com/Antonboom/errname v0.1.7 // indirect github.com/Abirdcfly/dupword v0.1.3 // indirect
github.com/Antonboom/nilnil v0.1.1 // indirect github.com/Antonboom/errname v1.1.0 // indirect
github.com/BurntSushi/toml v1.2.1 // indirect github.com/Antonboom/nilnil v1.1.0 // indirect
github.com/Antonboom/testifylint v1.6.1 // indirect
github.com/BurntSushi/toml v1.5.0 // indirect
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0 // indirect github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect github.com/Masterminds/semver/v3 v3.3.1 // indirect
github.com/OpenPeeDeeP/depguard v1.1.1 // indirect github.com/OpenPeeDeeP/depguard/v2 v2.2.1 // indirect
github.com/alecthomas/chroma/v2 v2.16.0 // indirect
github.com/alecthomas/go-check-sumtype v0.3.1 // indirect
github.com/alexkohler/nakedret/v2 v2.0.6 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect github.com/alexkohler/prealloc v1.0.0 // indirect
github.com/alingse/asasalint v0.0.11 // indirect github.com/alingse/asasalint v0.0.11 // indirect
github.com/ashanbrown/forbidigo v1.4.0 // indirect github.com/alingse/nilnesserr v0.2.0 // indirect
github.com/ashanbrown/makezero v1.1.1 // indirect github.com/ashanbrown/forbidigo v1.6.0 // indirect
github.com/ashanbrown/makezero v1.2.0 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect github.com/beorn7/perks v1.0.1 // indirect
github.com/bkielbasa/cyclop v1.2.0 // indirect github.com/bkielbasa/cyclop v1.2.3 // indirect
github.com/blizzy78/varnamelen v0.8.0 // indirect github.com/blizzy78/varnamelen v0.8.0 // indirect
github.com/bombsimon/wsl/v3 v3.4.0 // indirect github.com/bombsimon/wsl/v4 v4.7.0 // indirect
github.com/breml/bidichk v0.2.3 // indirect github.com/breml/bidichk v0.3.3 // indirect
github.com/breml/errchkjson v0.3.0 // indirect github.com/breml/errchkjson v0.4.1 // indirect
github.com/butuzov/ireturn v0.1.1 // indirect github.com/butuzov/ireturn v0.4.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/butuzov/mirror v1.3.0 // indirect
github.com/charithe/durationcheck v0.0.9 // indirect github.com/catenacyber/perfsprint v0.9.1 // indirect
github.com/chavacava/garif v0.0.0-20221024190013-b3ef35877348 // indirect github.com/ccojocar/zxcvbn-go v1.0.2 // indirect
github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/daixiang0/gci v0.9.1 // indirect github.com/charithe/durationcheck v0.0.10 // indirect
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
github.com/charmbracelet/lipgloss v1.1.0 // indirect
github.com/charmbracelet/x/ansi v0.8.0 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/chavacava/garif v0.1.0 // indirect
github.com/ckaznocha/intrange v0.3.1 // indirect
github.com/curioswitch/go-reassign v0.3.0 // indirect
github.com/daixiang0/gci v0.13.6 // indirect
github.com/dave/dst v0.27.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/denis-tingaikin/go-header v0.4.3 // indirect github.com/denis-tingaikin/go-header v0.5.0 // indirect
github.com/esimonov/ifshort v1.0.4 // indirect github.com/dlclark/regexp2 v1.11.5 // indirect
github.com/ettle/strcase v0.1.1 // indirect github.com/ettle/strcase v0.2.0 // indirect
github.com/fatih/color v1.14.1 // indirect github.com/fatih/color v1.18.0 // indirect
github.com/fatih/structtag v1.2.0 // indirect github.com/fatih/structtag v1.2.0 // indirect
github.com/firefart/nonamedreturns v1.0.4 // indirect github.com/firefart/nonamedreturns v1.0.6 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/fzipp/gocyclo v0.6.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect
github.com/go-critic/go-critic v0.6.7 // indirect github.com/ghostiam/protogetter v0.3.15 // indirect
github.com/go-critic/go-critic v0.13.0 // indirect
github.com/go-toolsmith/astcast v1.1.0 // indirect github.com/go-toolsmith/astcast v1.1.0 // indirect
github.com/go-toolsmith/astcopy v1.0.3 // indirect github.com/go-toolsmith/astcopy v1.1.0 // indirect
github.com/go-toolsmith/astequal v1.1.0 // indirect github.com/go-toolsmith/astequal v1.2.0 // indirect
github.com/go-toolsmith/astfmt v1.1.0 // indirect github.com/go-toolsmith/astfmt v1.1.0 // indirect
github.com/go-toolsmith/astp v1.1.0 // indirect github.com/go-toolsmith/astp v1.1.0 // indirect
github.com/go-toolsmith/strparse v1.1.0 // indirect github.com/go-toolsmith/strparse v1.1.0 // indirect
github.com/go-toolsmith/typep v1.1.0 // indirect github.com/go-toolsmith/typep v1.1.0 // indirect
github.com/go-xmlfmt/xmlfmt v1.1.2 // indirect github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect
github.com/gobwas/glob v0.2.3 // indirect github.com/gobwas/glob v0.2.3 // indirect
github.com/gofrs/flock v0.8.1 // indirect github.com/gofrs/flock v0.12.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect github.com/golang/protobuf v1.5.3 // indirect
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 // indirect
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect github.com/golangci/go-printf-func-name v0.1.0 // indirect
github.com/golangci/go-misc v0.0.0-20220329215616-d24fe342adfe // indirect github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect
github.com/golangci/gofmt v0.0.0-20220901101216-f2edd75033f2 // indirect github.com/golangci/golines v0.0.0-20250217134842-442fd0091d95 // indirect
github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0 // indirect github.com/golangci/misspell v0.6.0 // indirect
github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca // indirect github.com/golangci/plugin-module-register v0.1.1 // indirect
github.com/golangci/misspell v0.4.0 // indirect github.com/golangci/revgrep v0.8.0 // indirect
github.com/golangci/revgrep v0.0.0-20220804021717-745bb2f7c2e6 // indirect github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e // indirect
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect github.com/google/go-cmp v0.7.0 // indirect
github.com/google/go-cmp v0.5.9 // indirect github.com/gordonklaus/ineffassign v0.1.0 // indirect
github.com/gordonklaus/ineffassign v0.0.0-20230107090616-13ace0543b28 // indirect
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
github.com/gostaticanalysis/comment v1.4.2 // indirect github.com/gostaticanalysis/comment v1.5.0 // indirect
github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect github.com/gostaticanalysis/forcetypeassert v0.2.0 // indirect
github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/gostaticanalysis/nilerr v0.1.1 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hexops/gotextdiff v1.0.3 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jgautheron/goconst v1.5.1 // indirect github.com/jgautheron/goconst v1.8.1 // indirect
github.com/jingyugao/rowserrcheck v1.1.1 // indirect github.com/jingyugao/rowserrcheck v1.1.1 // indirect
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect github.com/jjti/go-spancheck v0.6.4 // indirect
github.com/julz/importas v0.1.0 // indirect github.com/julz/importas v0.2.0 // indirect
github.com/junk1tm/musttag v0.4.5 // indirect github.com/karamaru-alpha/copyloopvar v1.2.1 // indirect
github.com/kisielk/errcheck v1.6.3 // indirect github.com/kisielk/errcheck v1.9.0 // indirect
github.com/kisielk/gotool v1.0.0 // indirect github.com/kkHAIKE/contextcheck v1.1.6 // indirect
github.com/kkHAIKE/contextcheck v1.1.3 // indirect
github.com/kulti/thelper v0.6.3 // indirect github.com/kulti/thelper v0.6.3 // indirect
github.com/kunwardeep/paralleltest v1.0.6 // indirect github.com/kunwardeep/paralleltest v1.0.14 // indirect
github.com/kyoh86/exportloopref v0.1.11 // indirect github.com/lasiar/canonicalheader v1.1.2 // indirect
github.com/ldez/gomoddirectives v0.2.3 // indirect github.com/ldez/exptostd v0.4.3 // indirect
github.com/ldez/tagliatelle v0.4.0 // indirect github.com/ldez/gomoddirectives v0.6.1 // indirect
github.com/leonklingele/grouper v1.1.1 // indirect github.com/ldez/grignotin v0.9.0 // indirect
github.com/lufeee/execinquery v1.2.1 // indirect github.com/ldez/tagliatelle v0.7.1 // indirect
github.com/ldez/usetesting v0.4.3 // indirect
github.com/leonklingele/grouper v1.1.2 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/macabu/inamedparam v0.2.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect github.com/magiconair/properties v1.8.6 // indirect
github.com/manuelarte/funcorder v0.2.1 // indirect
github.com/maratori/testableexamples v1.0.0 // indirect github.com/maratori/testableexamples v1.0.0 // indirect
github.com/maratori/testpackage v1.1.0 // indirect github.com/maratori/testpackage v1.1.1 // indirect
github.com/matoous/godox v0.0.0-20210227103229-6504466cf951 // indirect github.com/matoous/godox v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mbilski/exhaustivestruct v1.2.0 // indirect github.com/mgechev/revive v1.9.0 // indirect
github.com/mgechev/revive v1.2.5 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moricho/tparallel v0.2.1 // indirect github.com/moricho/tparallel v0.3.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/nakabonne/nestif v0.3.1 // indirect github.com/nakabonne/nestif v0.3.1 // indirect
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 // indirect github.com/nishanths/exhaustive v0.12.0 // indirect
github.com/nishanths/exhaustive v0.9.5 // indirect
github.com/nishanths/predeclared v0.2.2 // indirect github.com/nishanths/predeclared v0.2.2 // indirect
github.com/nunnatsa/ginkgolinter v0.8.1 // indirect github.com/nunnatsa/ginkgolinter v0.19.1 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v1.1.0 // indirect github.com/polyfloyd/go-errorlint v1.8.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect github.com/prometheus/procfs v0.7.3 // indirect
github.com/quasilyte/go-ruleguard v0.3.19 // indirect github.com/quasilyte/go-ruleguard v0.4.4 // indirect
github.com/quasilyte/go-ruleguard/dsl v0.3.22 // indirect
github.com/quasilyte/gogrep v0.5.0 // indirect github.com/quasilyte/gogrep v0.5.0 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
github.com/ryancurrah/gomodguard v1.3.0 // indirect github.com/raeperd/recvcheck v0.2.0 // indirect
github.com/ryanrolds/sqlclosecheck v0.4.0 // indirect github.com/rivo/uniseg v0.4.7 // indirect
github.com/sanposhiho/wastedassign/v2 v2.0.7 // indirect github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/ryancurrah/gomodguard v1.4.1 // indirect
github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
github.com/sanposhiho/wastedassign/v2 v2.1.0 // indirect
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
github.com/sashamelentyev/usestdlibvars v1.23.0 // indirect github.com/sashamelentyev/usestdlibvars v1.28.0 // indirect
github.com/securego/gosec/v2 v2.15.0 // indirect github.com/securego/gosec/v2 v2.22.3 // indirect
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect github.com/sivchari/containedctx v1.0.3 // indirect
github.com/sivchari/containedctx v1.0.2 // indirect github.com/sonatard/noctx v0.1.0 // indirect
github.com/sivchari/nosnakecase v1.7.0 // indirect
github.com/sivchari/tenv v1.7.1 // indirect
github.com/sonatard/noctx v0.0.1 // indirect
github.com/sourcegraph/go-diff v0.7.0 // indirect github.com/sourcegraph/go-diff v0.7.0 // indirect
github.com/spf13/afero v1.8.2 // indirect github.com/spf13/afero v1.14.0 // indirect
github.com/spf13/cast v1.5.0 // indirect github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.6.1 // indirect github.com/spf13/cobra v1.9.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.6 // indirect
github.com/spf13/viper v1.12.0 // indirect github.com/spf13/viper v1.12.0 // indirect
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect github.com/stbenjam/no-sprintf-host-port v0.2.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.8.1 // indirect github.com/stretchr/testify v1.10.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect github.com/subosito/gotenv v1.4.1 // indirect
github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect github.com/tdakkota/asciicheck v0.4.1 // indirect
github.com/tdakkota/asciicheck v0.1.1 // indirect github.com/tetafro/godot v1.5.0 // indirect
github.com/tetafro/godot v1.4.11 // indirect github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 // indirect
github.com/timakin/bodyclose v0.0.0-20221125081123-e39cf3fc478e // indirect github.com/timonwong/loggercheck v0.11.0 // indirect
github.com/timonwong/loggercheck v0.9.3 // indirect github.com/tomarrell/wrapcheck/v2 v2.11.0 // indirect
github.com/tomarrell/wrapcheck/v2 v2.8.0 // indirect
github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
github.com/ultraware/funlen v0.0.3 // indirect github.com/ultraware/funlen v0.2.0 // indirect
github.com/ultraware/whitespace v0.0.5 // indirect github.com/ultraware/whitespace v0.2.0 // indirect
github.com/uudashr/gocognit v1.0.6 // indirect github.com/uudashr/gocognit v1.2.0 // indirect
github.com/uudashr/iface v1.3.1 // indirect
github.com/xen0n/gosmopolitan v1.3.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yagipy/maintidx v1.0.0 // indirect github.com/yagipy/maintidx v1.0.0 // indirect
github.com/yeya24/promlinter v0.2.0 // indirect github.com/yeya24/promlinter v0.3.0 // indirect
gitlab.com/bosi/decorder v0.2.3 // indirect github.com/ykadowak/zerologlint v0.1.5 // indirect
gitlab.com/bosi/decorder v0.4.2 // indirect
go-simpler.org/musttag v0.13.0 // indirect
go-simpler.org/sloglint v0.11.0 // indirect
go.augendre.info/fatcontext v0.8.0 // indirect
go.uber.org/atomic v1.7.0 // indirect go.uber.org/atomic v1.7.0 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.uber.org/multierr v1.6.0 // indirect go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect go.uber.org/zap v1.24.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect
golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9 // indirect golang.org/x/mod v0.24.0 // indirect
golang.org/x/mod v0.8.0 // indirect golang.org/x/sync v0.13.0 // indirect
golang.org/x/sync v0.1.0 // indirect golang.org/x/sys v0.32.0 // indirect
golang.org/x/sys v0.5.0 // indirect golang.org/x/text v0.24.0 // indirect
golang.org/x/text v0.6.0 // indirect golang.org/x/tools v0.32.0 // indirect
golang.org/x/tools v0.6.0 // indirect google.golang.org/protobuf v1.36.6 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.4.2 // indirect honnef.co/go/tools v0.6.1 // indirect
mvdan.cc/gofumpt v0.4.0 // indirect mvdan.cc/gofumpt v0.8.0 // indirect
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect mvdan.cc/unparam v0.0.0-20250301125049-0df0534333a4 // indirect
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
mvdan.cc/unparam v0.0.0-20221223090309-7455f1af531d // indirect
) )

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
// +build tools //go:build tools
package main package main
import ( import (
_ "github.com/golangci/golangci-lint/cmd/golangci-lint" _ "github.com/golangci/golangci-lint/v2/cmd/golangci-lint"
) )

View File

@ -0,0 +1,7 @@
version: "2"
output:
show-stats: true
sort-order:
- file
- linter

210
sample-go-tool/go.mod Normal file
View File

@ -0,0 +1,210 @@
module sample
go 1.24
toolchain go1.24.0
tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint
require (
4d63.com/gocheckcompilerdirectives v1.3.0 // indirect
4d63.com/gochecknoglobals v0.2.2 // indirect
github.com/4meepo/tagalign v1.4.2 // indirect
github.com/Abirdcfly/dupword v0.1.3 // indirect
github.com/Antonboom/errname v1.1.0 // indirect
github.com/Antonboom/nilnil v1.1.0 // indirect
github.com/Antonboom/testifylint v1.6.1 // indirect
github.com/BurntSushi/toml v1.5.0 // indirect
github.com/Crocmagnon/fatcontext v0.7.1 // indirect
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.1 // indirect
github.com/Masterminds/semver/v3 v3.3.1 // indirect
github.com/OpenPeeDeeP/depguard/v2 v2.2.1 // indirect
github.com/alecthomas/chroma/v2 v2.17.2 // indirect
github.com/alecthomas/go-check-sumtype v0.3.1 // indirect
github.com/alexkohler/nakedret/v2 v2.0.6 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect
github.com/alingse/asasalint v0.0.11 // indirect
github.com/alingse/nilnesserr v0.2.0 // indirect
github.com/ashanbrown/forbidigo v1.6.0 // indirect
github.com/ashanbrown/makezero v1.2.0 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bkielbasa/cyclop v1.2.3 // indirect
github.com/blizzy78/varnamelen v0.8.0 // indirect
github.com/bombsimon/wsl/v4 v4.7.0 // indirect
github.com/breml/bidichk v0.3.3 // indirect
github.com/breml/errchkjson v0.4.1 // indirect
github.com/butuzov/ireturn v0.4.0 // indirect
github.com/butuzov/mirror v1.3.0 // indirect
github.com/catenacyber/perfsprint v0.9.1 // indirect
github.com/ccojocar/zxcvbn-go v1.0.2 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/charithe/durationcheck v0.0.10 // indirect
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
github.com/charmbracelet/lipgloss v1.1.0 // indirect
github.com/charmbracelet/x/ansi v0.8.0 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/chavacava/garif v0.1.0 // indirect
github.com/ckaznocha/intrange v0.3.1 // indirect
github.com/curioswitch/go-reassign v0.3.0 // indirect
github.com/daixiang0/gci v0.13.6 // indirect
github.com/dave/dst v0.27.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/denis-tingaikin/go-header v0.5.0 // indirect
github.com/dlclark/regexp2 v1.11.5 // indirect
github.com/ettle/strcase v0.2.0 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/firefart/nonamedreturns v1.0.6 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/fzipp/gocyclo v0.6.0 // indirect
github.com/ghostiam/protogetter v0.3.15 // indirect
github.com/go-critic/go-critic v0.13.0 // indirect
github.com/go-toolsmith/astcast v1.1.0 // indirect
github.com/go-toolsmith/astcopy v1.1.0 // indirect
github.com/go-toolsmith/astequal v1.2.0 // indirect
github.com/go-toolsmith/astfmt v1.1.0 // indirect
github.com/go-toolsmith/astp v1.1.0 // indirect
github.com/go-toolsmith/strparse v1.1.0 // indirect
github.com/go-toolsmith/typep v1.1.0 // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gofrs/flock v0.12.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 // indirect
github.com/golangci/go-printf-func-name v0.1.0 // indirect
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect
github.com/golangci/golangci-lint/v2 v2.1.6 // indirect
github.com/golangci/golines v0.0.0-20250217134842-442fd0091d95 // indirect
github.com/golangci/misspell v0.6.0 // indirect
github.com/golangci/plugin-module-register v0.1.1 // indirect
github.com/golangci/revgrep v0.8.0 // indirect
github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/gordonklaus/ineffassign v0.1.0 // indirect
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
github.com/gostaticanalysis/comment v1.5.0 // indirect
github.com/gostaticanalysis/forcetypeassert v0.2.0 // indirect
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jgautheron/goconst v1.8.1 // indirect
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
github.com/jjti/go-spancheck v0.6.4 // indirect
github.com/julz/importas v0.2.0 // indirect
github.com/karamaru-alpha/copyloopvar v1.2.1 // indirect
github.com/kisielk/errcheck v1.9.0 // indirect
github.com/kkHAIKE/contextcheck v1.1.6 // indirect
github.com/kulti/thelper v0.6.3 // indirect
github.com/kunwardeep/paralleltest v1.0.14 // indirect
github.com/lasiar/canonicalheader v1.1.2 // indirect
github.com/ldez/exptostd v0.4.3 // indirect
github.com/ldez/gomoddirectives v0.6.1 // indirect
github.com/ldez/grignotin v0.9.0 // indirect
github.com/ldez/tagliatelle v0.7.1 // indirect
github.com/ldez/usetesting v0.4.3 // indirect
github.com/leonklingele/grouper v1.1.2 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/macabu/inamedparam v0.2.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/manuelarte/funcorder v0.2.1 // indirect
github.com/maratori/testableexamples v1.0.0 // indirect
github.com/maratori/testpackage v1.1.1 // indirect
github.com/matoous/godox v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mgechev/revive v1.9.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moricho/tparallel v0.3.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/nakabonne/nestif v0.3.1 // indirect
github.com/nishanths/exhaustive v0.12.0 // indirect
github.com/nishanths/predeclared v0.2.2 // indirect
github.com/nunnatsa/ginkgolinter v0.19.1 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v1.8.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/quasilyte/go-ruleguard v0.4.4 // indirect
github.com/quasilyte/go-ruleguard/dsl v0.3.22 // indirect
github.com/quasilyte/gogrep v0.5.0 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
github.com/raeperd/recvcheck v0.2.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/ryancurrah/gomodguard v1.4.1 // indirect
github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
github.com/sanposhiho/wastedassign/v2 v2.1.0 // indirect
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
github.com/sashamelentyev/usestdlibvars v1.28.0 // indirect
github.com/securego/gosec/v2 v2.22.3 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sivchari/containedctx v1.0.3 // indirect
github.com/sivchari/tenv v1.12.1 // indirect
github.com/sonatard/noctx v0.1.0 // indirect
github.com/sourcegraph/go-diff v0.7.0 // indirect
github.com/spf13/afero v1.14.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.9.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/spf13/viper v1.12.0 // indirect
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
github.com/stbenjam/no-sprintf-host-port v0.2.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.10.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/tdakkota/asciicheck v0.4.1 // indirect
github.com/tetafro/godot v1.5.1 // indirect
github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 // indirect
github.com/timonwong/loggercheck v0.11.0 // indirect
github.com/tomarrell/wrapcheck/v2 v2.11.0 // indirect
github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
github.com/ultraware/funlen v0.2.0 // indirect
github.com/ultraware/whitespace v0.2.0 // indirect
github.com/uudashr/gocognit v1.2.0 // indirect
github.com/uudashr/iface v1.3.1 // indirect
github.com/xen0n/gosmopolitan v1.3.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yagipy/maintidx v1.0.0 // indirect
github.com/yeya24/promlinter v0.3.0 // indirect
github.com/ykadowak/zerologlint v0.1.5 // indirect
gitlab.com/bosi/decorder v0.4.2 // indirect
go-simpler.org/musttag v0.13.1 // indirect
go-simpler.org/sloglint v0.11.0 // indirect
go.augendre.info/fatcontext v0.8.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect
golang.org/x/mod v0.24.0 // indirect
golang.org/x/sync v0.13.0 // indirect
golang.org/x/sys v0.32.0 // indirect
golang.org/x/text v0.24.0 // indirect
golang.org/x/tools v0.32.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.6.1 // indirect
mvdan.cc/gofumpt v0.8.0 // indirect
mvdan.cc/unparam v0.0.0-20250301125049-0df0534333a4 // indirect
)

1079
sample-go-tool/go.sum Normal file

File diff suppressed because it is too large Load Diff

26
sample-go-tool/sample.go Normal file
View File

@ -0,0 +1,26 @@
// Package main is used as test input for golangci action.
package main
import (
"crypto/md5"
"encoding/hex"
"errors"
)
// Hash~
func Hash(data string) string {
retError()
retError2()
h := md5.New()
h.Write([]byte(data))
return hex.EncodeToString(h.Sum(nil))
}
func retError() error {
return errors.New("err")
}
func retError2() error {
return errors.New("err2")
}

View File

@ -4,37 +4,12 @@ import { exec, ExecOptions } from "child_process"
import os from "os" import os from "os"
import path from "path" import path from "path"
import { promisify } from "util" import { promisify } from "util"
import which from "which"
import { VersionConfig } from "./version" import { getVersion, VersionInfo } from "./version"
const execShellCommand = promisify(exec) const execShellCommand = promisify(exec)
const downloadURL = "https://github.com/golangci/golangci-lint/releases/download"
const getAssetURL = (versionConfig: VersionConfig): string => {
let ext = "tar.gz"
let platform = os.platform().toString()
switch (platform) {
case "win32":
platform = "windows"
ext = "zip"
break
}
let arch = os.arch()
switch (arch) {
case "x64":
arch = "amd64"
break
case "x32":
case "ia32":
arch = "386"
break
}
const noPrefix = versionConfig.TargetVersion.slice(1)
return `${downloadURL}/${versionConfig.TargetVersion}/golangci-lint-${noPrefix}-${platform}-${arch}.${ext}`
}
export enum InstallMode { export enum InstallMode {
Binary = "binary", Binary = "binary",
GoInstall = "goinstall", GoInstall = "goinstall",
@ -58,68 +33,94 @@ const printOutput = (res: ExecRes): void => {
/** /**
* Install golangci-lint. * Install golangci-lint.
* *
* @param versionConfig information about version to install. * @returns path to installed binary of golangci-lint.
*/
export async function install(): Promise<string> {
const mode = core.getInput("install-mode").toLowerCase()
if (mode === InstallMode.None) {
const binPath = await which("golangci-lint", { nothrow: true })
if (!binPath) {
throw new Error("golangci-lint binary not found in the PATH")
}
return binPath
}
const versionInfo = await getVersion(<InstallMode>mode)
return await installBinary(versionInfo, <InstallMode>mode)
}
/**
* Install golangci-lint.
*
* @param versionInfo information about version to install.
* @param mode installation mode. * @param mode installation mode.
* @returns path to installed binary of golangci-lint. * @returns path to installed binary of golangci-lint.
*/ */
export async function installLint(versionConfig: VersionConfig, mode: InstallMode): Promise<string> { export async function installBinary(versionInfo: VersionInfo, mode: InstallMode): Promise<string> {
core.info(`Installation mode: ${mode}`) core.info(`Installation mode: ${mode}`)
switch (mode) { switch (mode) {
case InstallMode.Binary: case InstallMode.Binary:
return installBin(versionConfig) return installBin(versionInfo)
case InstallMode.GoInstall: case InstallMode.GoInstall:
return goInstall(versionConfig) return goInstall(versionInfo)
default: default:
return installBin(versionConfig) return installBin(versionInfo)
} }
} }
/** /**
* Install golangci-lint via `go install`. * Install golangci-lint via `go install`.
* *
* @param versionConfig information about version to install. * @param versionInfo information about version to install.
* @returns path to installed binary of golangci-lint. * @returns path to installed binary of golangci-lint.
*/ */
export async function goInstall(versionConfig: VersionConfig): Promise<string> { async function goInstall(versionInfo: VersionInfo): Promise<string> {
core.info(`Installing golangci-lint ${versionConfig.TargetVersion}...`) core.info(`Installing golangci-lint ${versionInfo.TargetVersion}...`)
const startedAt = Date.now() const startedAt = Date.now()
const options: ExecOptions = { env: { ...process.env, CGO_ENABLED: "1" } } const options: ExecOptions = { env: { ...process.env, CGO_ENABLED: "1" } }
const exres = await execShellCommand( const exres = await execShellCommand(
`go install github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`, `go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${versionInfo.TargetVersion}`,
options options
) )
printOutput(exres) printOutput(exres)
const res = await execShellCommand( const res = await execShellCommand(
`go install -n github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`, `go install -n github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${versionInfo.TargetVersion}`,
options options
) )
printOutput(res) printOutput(res)
// The output of `go install -n` when the binary is already installed is `touch <path_to_the_binary>`. // The output of `go install -n` when the binary is already installed is `touch <path_to_the_binary>`.
const lintPath = res.stderr.trimStart().trimEnd().split(` `, 2)[1] const binPath = res.stderr
.split(/\r?\n/)
.map((v) => v.trimStart().trimEnd())
.filter((v) => v.startsWith("touch "))
.reduce((a, b) => a + b, "")
.split(` `, 2)[1]
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`) core.info(`Installed golangci-lint into ${binPath} in ${Date.now() - startedAt}ms`)
return lintPath return binPath
} }
/** /**
* Install golangci-lint via the precompiled binary. * Install golangci-lint via the precompiled binary.
* *
* @param versionConfig information about version to install. * @param versionInfo information about version to install.
* @returns path to installed binary of golangci-lint. * @returns path to installed binary of golangci-lint.
*/ */
export async function installBin(versionConfig: VersionConfig): Promise<string> { async function installBin(versionInfo: VersionInfo): Promise<string> {
core.info(`Installing golangci-lint binary ${versionConfig.TargetVersion}...`) core.info(`Installing golangci-lint binary ${versionInfo.TargetVersion}...`)
const startedAt = Date.now() const startedAt = Date.now()
const assetURL = getAssetURL(versionConfig) const assetURL = getAssetURL(versionInfo)
core.info(`Downloading binary ${assetURL} ...`) core.info(`Downloading binary ${assetURL} ...`)
@ -141,9 +142,39 @@ export async function installBin(versionConfig: VersionConfig): Promise<string>
const urlParts = assetURL.split(`/`) const urlParts = assetURL.split(`/`)
const dirName = urlParts[urlParts.length - 1].replace(repl, ``) const dirName = urlParts[urlParts.length - 1].replace(repl, ``)
const lintPath = path.join(extractedDir, dirName, `golangci-lint`) const binPath = path.join(extractedDir, dirName, `golangci-lint`)
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`) core.info(`Installed golangci-lint into ${binPath} in ${Date.now() - startedAt}ms`)
return lintPath return binPath
}
function getAssetURL(versionInfo: VersionInfo): string {
let ext = "tar.gz"
let platform = os.platform().toString()
switch (platform) {
case "win32":
platform = "windows"
ext = "zip"
break
}
let arch = os.arch()
switch (arch) {
case "arm64":
arch = "arm64"
break
case "x64":
arch = "amd64"
break
case "x32":
case "ia32":
arch = "386"
break
}
const noPrefix = versionInfo.TargetVersion.slice(1)
return `https://github.com/golangci/golangci-lint/releases/download/${versionInfo.TargetVersion}/golangci-lint-${noPrefix}-${platform}-${arch}.${ext}`
} }

120
src/patch.ts Normal file
View File

@ -0,0 +1,120 @@
import * as core from "@actions/core"
import * as github from "@actions/github"
import { Context } from "@actions/github/lib/context"
import * as pluginRetry from "@octokit/plugin-retry"
import fs from "fs"
import path from "path"
import { dir } from "tmp"
import { promisify } from "util"
import { alterDiffPatch } from "./utils/diffUtils"
const writeFile = promisify(fs.writeFile)
const createTempDir = promisify(dir)
export function isOnlyNewIssues(): boolean {
return core.getBooleanInput(`only-new-issues`, { required: true })
}
export async function fetchPatch(): Promise<string> {
if (!isOnlyNewIssues()) {
return ``
}
const ctx = github.context
switch (ctx.eventName) {
case `pull_request`:
case `pull_request_target`:
return await fetchPullRequestPatch(ctx)
case `push`:
return await fetchPushPatch(ctx)
case `merge_group`:
return ``
default:
core.info(`Not fetching patch for showing only new issues because it's not a pull request context: event name is ${ctx.eventName}`)
return ``
}
}
async function fetchPullRequestPatch(ctx: Context): Promise<string> {
const pr = ctx.payload.pull_request
if (!pr) {
core.warning(`No pull request in context`)
return ``
}
const octokit = github.getOctokit(core.getInput(`github-token`, { required: true }), {}, pluginRetry.retry)
let patch: string
try {
const patchResp = await octokit.rest.pulls.get({
owner: ctx.repo.owner,
repo: ctx.repo.repo,
[`pull_number`]: pr.number,
mediaType: {
format: `diff`,
},
})
if (patchResp.status !== 200) {
core.warning(`failed to fetch pull request patch: response status is ${patchResp.status}`)
return `` // don't fail the action, but analyze without patch
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
patch = patchResp.data as any
} catch (err) {
console.warn(`failed to fetch pull request patch:`, err)
return `` // don't fail the action, but analyze without patch
}
try {
const tempDir = await createTempDir()
const patchPath = path.join(tempDir, "pull.patch")
core.info(`Writing patch to ${patchPath}`)
await writeFile(patchPath, alterDiffPatch(patch))
return patchPath
} catch (err) {
console.warn(`failed to save pull request patch:`, err)
return `` // don't fail the action, but analyze without patch
}
}
async function fetchPushPatch(ctx: Context): Promise<string> {
const octokit = github.getOctokit(core.getInput(`github-token`, { required: true }), {}, pluginRetry.retry)
let patch: string
try {
const patchResp = await octokit.rest.repos.compareCommitsWithBasehead({
owner: ctx.repo.owner,
repo: ctx.repo.repo,
basehead: `${ctx.payload.before}...${ctx.payload.after}`,
mediaType: {
format: `diff`,
},
})
if (patchResp.status !== 200) {
core.warning(`failed to fetch push patch: response status is ${patchResp.status}`)
return `` // don't fail the action, but analyze without patch
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
patch = patchResp.data as any
} catch (err) {
console.warn(`failed to fetch push patch:`, err)
return `` // don't fail the action, but analyze without patch
}
try {
const tempDir = await createTempDir()
const patchPath = path.join(tempDir, "push.patch")
core.info(`Writing patch to ${patchPath}`)
await writeFile(patchPath, alterDiffPatch(patch))
return patchPath
} catch (err) {
console.warn(`failed to save pull request patch:`, err)
return `` // don't fail the action, but analyze without patch
}
}

View File

@ -1,147 +1,18 @@
import * as core from "@actions/core" import * as core from "@actions/core"
import * as github from "@actions/github" import * as github from "@actions/github"
import { Context } from "@actions/github/lib/context"
import { exec, ExecOptions } from "child_process" import { exec, ExecOptions } from "child_process"
import * as fs from "fs" import * as fs from "fs"
import * as path from "path" import * as path from "path"
import { dir } from "tmp"
import { promisify } from "util" import { promisify } from "util"
import which from "which"
import { restoreCache, saveCache } from "./cache" import { restoreCache, saveCache } from "./cache"
import { installLint, InstallMode } from "./install" import { install } from "./install"
import { alterDiffPatch } from "./utils/diffUtils" import { fetchPatch, isOnlyNewIssues } from "./patch"
import { findLintVersion } from "./version"
const execShellCommand = promisify(exec) const execShellCommand = promisify(exec)
const writeFile = promisify(fs.writeFile)
const createTempDir = promisify(dir)
function isOnlyNewIssues(): boolean {
return core.getBooleanInput(`only-new-issues`, { required: true })
}
async function prepareLint(): Promise<string> {
const mode = core.getInput("install-mode").toLowerCase()
if (mode === InstallMode.None) {
const bin = await which("golangci-lint", { nothrow: true })
if (!bin) {
throw new Error("golangci-lint binary not found in the PATH")
}
return bin
}
const versionConfig = await findLintVersion(<InstallMode>mode)
return await installLint(versionConfig, <InstallMode>mode)
}
async function fetchPatch(): Promise<string> {
if (!isOnlyNewIssues()) {
return ``
}
const ctx = github.context
switch (ctx.eventName) {
case `pull_request`:
case `pull_request_target`:
return await fetchPullRequestPatch(ctx)
case `push`:
return await fetchPushPatch(ctx)
case `merge_group`:
return ``
default:
core.info(`Not fetching patch for showing only new issues because it's not a pull request context: event name is ${ctx.eventName}`)
return ``
}
}
async function fetchPullRequestPatch(ctx: Context): Promise<string> {
const pr = ctx.payload.pull_request
if (!pr) {
core.warning(`No pull request in context`)
return ``
}
const octokit = github.getOctokit(core.getInput(`github-token`, { required: true }))
let patch: string
try {
const patchResp = await octokit.rest.pulls.get({
owner: ctx.repo.owner,
repo: ctx.repo.repo,
[`pull_number`]: pr.number,
mediaType: {
format: `diff`,
},
})
if (patchResp.status !== 200) {
core.warning(`failed to fetch pull request patch: response status is ${patchResp.status}`)
return `` // don't fail the action, but analyze without patch
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
patch = patchResp.data as any
} catch (err) {
console.warn(`failed to fetch pull request patch:`, err)
return `` // don't fail the action, but analyze without patch
}
try {
const tempDir = await createTempDir()
const patchPath = path.join(tempDir, "pull.patch")
core.info(`Writing patch to ${patchPath}`)
await writeFile(patchPath, alterDiffPatch(patch))
return patchPath
} catch (err) {
console.warn(`failed to save pull request patch:`, err)
return `` // don't fail the action, but analyze without patch
}
}
async function fetchPushPatch(ctx: Context): Promise<string> {
const octokit = github.getOctokit(core.getInput(`github-token`, { required: true }))
let patch: string
try {
const patchResp = await octokit.rest.repos.compareCommitsWithBasehead({
owner: ctx.repo.owner,
repo: ctx.repo.repo,
basehead: `${ctx.payload.before}...${ctx.payload.after}`,
mediaType: {
format: `diff`,
},
})
if (patchResp.status !== 200) {
core.warning(`failed to fetch push patch: response status is ${patchResp.status}`)
return `` // don't fail the action, but analyze without patch
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
patch = patchResp.data as any
} catch (err) {
console.warn(`failed to fetch push patch:`, err)
return `` // don't fail the action, but analyze without patch
}
try {
const tempDir = await createTempDir()
const patchPath = path.join(tempDir, "push.patch")
core.info(`Writing patch to ${patchPath}`)
await writeFile(patchPath, alterDiffPatch(patch))
return patchPath
} catch (err) {
console.warn(`failed to save pull request patch:`, err)
return `` // don't fail the action, but analyze without patch
}
}
type Env = { type Env = {
lintPath: string binPath: string
patchPath: string patchPath: string
} }
@ -151,12 +22,12 @@ async function prepareEnv(): Promise<Env> {
// Prepare cache, lint and go in parallel. // Prepare cache, lint and go in parallel.
await restoreCache() await restoreCache()
const lintPath = await prepareLint() const binPath = await install()
const patchPath = await fetchPatch() const patchPath = await fetchPatch()
core.info(`Prepared env in ${Date.now() - startedAt}ms`) core.info(`Prepared env in ${Date.now() - startedAt}ms`)
return { lintPath, patchPath } return { binPath, patchPath }
} }
type ExecRes = { type ExecRes = {
@ -173,14 +44,14 @@ const printOutput = (res: ExecRes): void => {
} }
} }
async function runLint(lintPath: string, patchPath: string): Promise<void> { async function runLint(binPath: string, patchPath: string): Promise<void> {
const debug = core.getInput(`debug`) const debug = core.getInput(`debug`)
if (debug.split(`,`).includes(`cache`)) { if (debug.split(`,`).includes(`cache`)) {
const res = await execShellCommand(`${lintPath} cache status`) const res = await execShellCommand(`${binPath} cache status`)
printOutput(res) printOutput(res)
} }
let userArgs = core.getInput(`args`) const userArgs = core.getInput(`args`)
const addedArgs: string[] = [] const addedArgs: string[] = []
const userArgsList = userArgs const userArgsList = userArgs
@ -205,23 +76,13 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
} }
} }
const formats = (userArgsMap.get("out-format") || "")
.trim()
.split(",")
.filter((f) => f.length > 0)
.filter((f) => !f.startsWith(`github-actions`)) // Removes `github-actions` format.
.join(",")
if (formats) {
// Adds formats but without `github-actions` format.
addedArgs.push(`--out-format=${formats}`)
}
// Removes `--out-format` from the user flags because it's already inside `addedArgs`.
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim()
if (isOnlyNewIssues()) { if (isOnlyNewIssues()) {
if (userArgNames.has(`new`) || userArgNames.has(`new-from-rev`) || userArgNames.has(`new-from-patch`)) { if (
userArgNames.has(`new`) ||
userArgNames.has(`new-from-rev`) ||
userArgNames.has(`new-from-patch`) ||
userArgNames.has(`new-from-merge-base`)
) {
throw new Error(`please, don't specify manually --new* args when requesting only new issues`) throw new Error(`please, don't specify manually --new* args when requesting only new issues`)
} }
@ -239,6 +100,7 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
// Override config values. // Override config values.
addedArgs.push(`--new=false`) addedArgs.push(`--new=false`)
addedArgs.push(`--new-from-rev=`) addedArgs.push(`--new-from-rev=`)
addedArgs.push(`--new-from-merge-base=`)
} }
break break
case `merge_group`: case `merge_group`:
@ -247,6 +109,7 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
// Override config values. // Override config values.
addedArgs.push(`--new=false`) addedArgs.push(`--new=false`)
addedArgs.push(`--new-from-patch=`) addedArgs.push(`--new-from-patch=`)
addedArgs.push(`--new-from-merge-base=`)
break break
default: default:
break break
@ -260,13 +123,17 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) { if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
throw new Error(`working-directory (${workingDirectory}) was not a path`) throw new Error(`working-directory (${workingDirectory}) was not a path`)
} }
if (!userArgNames.has(`path-prefix`)) {
addedArgs.push(`--path-prefix=${workingDirectory}`) if (!userArgNames.has(`path-prefix`) && !userArgNames.has(`path-mode`)) {
addedArgs.push(`--path-mode=abs`)
} }
cmdArgs.cwd = path.resolve(workingDirectory) cmdArgs.cwd = path.resolve(workingDirectory)
} }
const cmd = `${lintPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd() await runVerify(binPath, userArgsMap, cmdArgs)
const cmd = `${binPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd()
core.info(`Running [${cmd}] in [${cmdArgs.cwd || process.cwd()}] ...`) core.info(`Running [${cmd}] in [${cmdArgs.cwd || process.cwd()}] ...`)
@ -277,7 +144,6 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
core.info(`golangci-lint found no issues`) core.info(`golangci-lint found no issues`)
} catch (exc) { } catch (exc) {
// This logging passes issues to GitHub annotations but comments can be more convenient for some users. // This logging passes issues to GitHub annotations but comments can be more convenient for some users.
// TODO: support reviewdog or leaving comments by GitHub API.
printOutput(exc) printOutput(exc)
if (exc.code === 1) { if (exc.code === 1) {
@ -290,11 +156,49 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
core.info(`Ran golangci-lint in ${Date.now() - startedAt}ms`) core.info(`Ran golangci-lint in ${Date.now() - startedAt}ms`)
} }
async function runVerify(binPath: string, userArgsMap: Map<string, string>, cmdArgs: ExecOptions): Promise<void> {
const verify = core.getBooleanInput(`verify`, { required: true })
if (!verify) {
return
}
const cfgPath = await getConfigPath(binPath, userArgsMap, cmdArgs)
if (!cfgPath) {
return
}
let cmdVerify = `${binPath} config verify`
if (userArgsMap.get("config")) {
cmdVerify += ` --config=${userArgsMap.get("config")}`
}
core.info(`Running [${cmdVerify}] in [${cmdArgs.cwd || process.cwd()}] ...`)
const res = await execShellCommand(cmdVerify, cmdArgs)
printOutput(res)
}
async function getConfigPath(binPath: string, userArgsMap: Map<string, string>, cmdArgs: ExecOptions): Promise<string> {
let cmdConfigPath = `${binPath} config path`
if (userArgsMap.get("config")) {
cmdConfigPath += ` --config=${userArgsMap.get("config")}`
}
core.info(`Running [${cmdConfigPath}] in [${cmdArgs.cwd || process.cwd()}] ...`)
try {
const resPath = await execShellCommand(cmdConfigPath, cmdArgs)
return resPath.stderr.trim()
} catch {
return ``
}
}
export async function run(): Promise<void> { export async function run(): Promise<void> {
try { try {
const { lintPath, patchPath } = await core.group(`prepare environment`, prepareEnv) const { binPath, patchPath } = await core.group(`prepare environment`, prepareEnv)
core.addPath(path.dirname(lintPath)) core.addPath(path.dirname(binPath))
await core.group(`run golangci-lint`, () => runLint(lintPath, patchPath)) await core.group(`run golangci-lint`, () => runLint(binPath, patchPath))
} catch (error) { } catch (error) {
core.error(`Failed to run: ${error}, ${error.stack}`) core.error(`Failed to run: ${error}, ${error.stack}`)
core.setFailed(error.message) core.setFailed(error.message)

View File

@ -13,7 +13,7 @@ export type Version = {
} | null } | null
const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/ const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/
const modVersionRe = /github.com\/golangci\/golangci-lint\s(v.+)/ const modVersionRe = /github.com\/golangci\/golangci-lint\/v2\s(v\S+)/
const parseVersion = (s: string): Version => { const parseVersion = (s: string): Version => {
if (s == "latest" || s == "") { if (s == "latest" || s == "") {
@ -25,6 +25,10 @@ const parseVersion = (s: string): Version => {
throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`) throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`)
} }
if (parseInt(match[1]) !== 2) {
throw new Error(`invalid version string '${s}', golangci-lint v${match[1]} is not supported by golangci-lint-action >= v7.`)
}
return { return {
major: parseInt(match[1]), major: parseInt(match[1]),
minor: parseInt(match[2]), minor: parseInt(match[2]),
@ -40,9 +44,9 @@ export const stringifyVersion = (v: Version): string => {
} }
const minVersion = { const minVersion = {
major: 1, major: 2,
minor: 28, minor: 1,
patch: 3, patch: 0,
} }
const isLessVersion = (a: Version, b: Version): boolean => { const isLessVersion = (a: Version, b: Version): boolean => {
@ -56,13 +60,13 @@ const isLessVersion = (a: Version, b: Version): boolean => {
return a.major < b.major return a.major < b.major
} }
// Do not compare patch parts because if the min version has a non zero value // Do not compare patch parts because if the min version has a non-zero value
// then it returns false, since the patch version of requested is always zero // then it returns false, since the patch version of requested is always zero
return a.minor < b.minor return a.minor < b.minor
} }
const getRequestedLintVersion = (): Version => { const getRequestedVersion = (): Version => {
let requestedLintVersion = core.getInput(`version`) let requestedVersion = core.getInput(`version`)
const workingDirectory = core.getInput(`working-directory`) const workingDirectory = core.getInput(`working-directory`)
let goMod = "go.mod" let goMod = "go.mod"
@ -70,50 +74,49 @@ const getRequestedLintVersion = (): Version => {
goMod = path.join(workingDirectory, goMod) goMod = path.join(workingDirectory, goMod)
} }
if (requestedLintVersion == "" && fs.existsSync(goMod)) { if (requestedVersion == "" && fs.existsSync(goMod)) {
const content = fs.readFileSync(goMod, "utf-8") const content = fs.readFileSync(goMod, "utf-8")
const match = content.match(modVersionRe) const match = content.match(modVersionRe)
if (match) { if (match) {
requestedLintVersion = match[1] requestedVersion = match[1]
core.info(`Found golangci-lint version '${requestedLintVersion}' in '${goMod}' file`) core.info(`Found golangci-lint version '${requestedVersion}' in '${goMod}' file`)
} }
} }
const parsedRequestedLintVersion = parseVersion(requestedLintVersion) const parsedRequestedVersion = parseVersion(requestedVersion)
if (parsedRequestedLintVersion == null) { if (parsedRequestedVersion == null) {
return null return null
} }
if (isLessVersion(parsedRequestedLintVersion, minVersion)) { if (isLessVersion(parsedRequestedVersion, minVersion)) {
throw new Error( throw new Error(
`requested golangci-lint version '${requestedLintVersion}' isn't supported: we support only ${stringifyVersion( `requested golangci-lint version '${requestedVersion}' isn't supported: we support only ${stringifyVersion(
minVersion minVersion
)} and later versions` )} and later versions`
) )
} }
return parsedRequestedLintVersion return parsedRequestedVersion
} }
export type VersionConfig = { export type VersionInfo = {
Error?: string Error?: string
TargetVersion: string TargetVersion: string
AssetURL: string
} }
type Config = { type VersionMapping = {
MinorVersionToConfig: { MinorVersionToConfig: {
[minorVersion: string]: VersionConfig [minorVersion: string]: VersionInfo
} }
} }
const getConfig = async (): Promise<Config> => { const fetchVersionMapping = async (): Promise<VersionMapping> => {
const http = new httpm.HttpClient(`golangci/golangci-lint-action`, [], { const http = new httpm.HttpClient(`golangci/golangci-lint-action`, [], {
allowRetries: true, allowRetries: true,
maxRetries: 5, maxRetries: 5,
}) })
try { try {
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/master/assets/github-action-config.json` const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v2.json`
const response: httpm.HttpClientResponse = await http.get(url) const response: httpm.HttpClientResponse = await http.get(url)
if (response.message.statusCode !== 200) { if (response.message.statusCode !== 200) {
throw new Error(`failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`) throw new Error(`failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`)
@ -126,49 +129,47 @@ const getConfig = async (): Promise<Config> => {
} }
} }
export async function findLintVersion(mode: InstallMode): Promise<VersionConfig> { export async function getVersion(mode: InstallMode): Promise<VersionInfo> {
core.info(`Finding needed golangci-lint version...`) core.info(`Finding needed golangci-lint version...`)
if (mode == InstallMode.GoInstall) { if (mode == InstallMode.GoInstall) {
const v: string = core.getInput(`version`) const v: string = core.getInput(`version`)
return { TargetVersion: v ? v : "latest", AssetURL: "github.com/golangci/golangci-lint" }
return { TargetVersion: v ? v : "latest" }
} }
const reqLintVersion = getRequestedLintVersion() const reqVersion = getRequestedVersion()
// if the patched version is passed, just use it // if the patched version is passed, just use it
if (reqLintVersion?.major !== null && reqLintVersion?.minor != null && reqLintVersion?.patch !== null) { if (reqVersion?.major === 2 && reqVersion?.minor != null && reqVersion?.patch !== null) {
return new Promise((resolve) => { return new Promise((resolve) => {
const versionWithoutV = `${reqLintVersion.major}.${reqLintVersion.minor}.${reqLintVersion.patch}` const versionWithoutV = `${reqVersion.major}.${reqVersion.minor}.${reqVersion.patch}`
resolve({ resolve({ TargetVersion: `v${versionWithoutV}` })
TargetVersion: `v${versionWithoutV}`,
AssetURL: `https://github.com/golangci/golangci-lint/releases/download/v${versionWithoutV}/golangci-lint-${versionWithoutV}-linux-amd64.tar.gz`,
})
}) })
} }
const startedAt = Date.now() const startedAt = Date.now()
const config = await getConfig() const mapping = await fetchVersionMapping()
if (!config.MinorVersionToConfig) { if (!mapping.MinorVersionToConfig) {
core.warning(JSON.stringify(config)) core.warning(JSON.stringify(mapping))
throw new Error(`invalid config: no MinorVersionToConfig field`) throw new Error(`invalid config: no MinorVersionToConfig field`)
} }
const versionConfig = config.MinorVersionToConfig[stringifyVersion(reqLintVersion)] const versionInfo = mapping.MinorVersionToConfig[stringifyVersion(reqVersion)]
if (!versionConfig) { if (!versionInfo) {
throw new Error(`requested golangci-lint version '${stringifyVersion(reqLintVersion)}' doesn't exist`) throw new Error(`requested golangci-lint version '${stringifyVersion(reqVersion)}' doesn't exist`)
} }
if (versionConfig.Error) { if (versionInfo.Error) {
throw new Error(`failed to use requested golangci-lint version '${stringifyVersion(reqLintVersion)}': ${versionConfig.Error}`) throw new Error(`failed to use requested golangci-lint version '${stringifyVersion(reqVersion)}': ${versionInfo.Error}`)
} }
core.info( core.info(
`Requested golangci-lint '${stringifyVersion(reqLintVersion)}', using '${versionConfig.TargetVersion}', calculation took ${ `Requested golangci-lint '${stringifyVersion(reqVersion)}', using '${versionInfo.TargetVersion}', calculation took ${
Date.now() - startedAt Date.now() - startedAt
}ms` }ms`
) )
return versionConfig return versionInfo
} }