mirror of
https://github.com/golangci/golangci-lint-action.git
synced 2025-12-16 23:48:27 +00:00
Compare commits
No commits in common. "main" and "v9.1.0" have entirely different histories.
32 changed files with 100038 additions and 95341 deletions
9
.github/workflows/codeql.yaml
vendored
9
.github/workflows/codeql.yaml
vendored
|
|
@ -11,11 +11,6 @@ on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 17 * * 5'
|
- cron: '0 17 * * 5'
|
||||||
|
|
||||||
permissions:
|
|
||||||
actions: read
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
codeQL:
|
codeQL:
|
||||||
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
|
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
|
||||||
|
|
@ -23,7 +18,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
# Must fetch at least the immediate parents so that if this is
|
# Must fetch at least the immediate parents so that if this is
|
||||||
# a pull request then we can checkout the head of the pull request.
|
# a pull request then we can checkout the head of the pull request.
|
||||||
|
|
@ -41,7 +36,7 @@ jobs:
|
||||||
uses: github/codeql-action/init@v4
|
uses: github/codeql-action/init@v4
|
||||||
# Override language selection by uncommenting this and choosing your languages
|
# Override language selection by uncommenting this and choosing your languages
|
||||||
with:
|
with:
|
||||||
languages: 'javascript-typescript'
|
language: 'javascript'
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
npm install
|
npm install
|
||||||
|
|
|
||||||
54
.github/workflows/test.yml
vendored
54
.github/workflows/test.yml
vendored
|
|
@ -1,6 +1,5 @@
|
||||||
name: "build-and-test"
|
name: "build-and-test"
|
||||||
|
on: # rebuild any PRs and main branch changes
|
||||||
on:
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
@ -8,27 +7,22 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# make sure build/ci work properly
|
build: # make sure build/ci work properly
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 24.x
|
node-version: 24.x
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v5
|
||||||
- run: |
|
- run: |
|
||||||
npm install
|
npm install
|
||||||
npm run all
|
npm run all
|
||||||
|
|
||||||
# Fail the build if there are changes.
|
# Fail the build if there is dirty change
|
||||||
- run: git diff --exit-code -- dist
|
- run: git diff --exit-code -- dist
|
||||||
|
|
||||||
# make sure the action works on a clean machine without building
|
test: # make sure the action works on a clean machine without building
|
||||||
test:
|
|
||||||
needs: [ build ]
|
needs: [ build ]
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
|
@ -40,14 +34,14 @@ jobs:
|
||||||
version:
|
version:
|
||||||
- ""
|
- ""
|
||||||
- "latest"
|
- "latest"
|
||||||
- "v2.7"
|
- "v2.5"
|
||||||
- "v2.7.2"
|
- "v2.5.0"
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
pull-requests: read
|
pull-requests: read
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 24.x
|
node-version: 24.x
|
||||||
|
|
@ -57,11 +51,10 @@ jobs:
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.version }}
|
version: ${{ matrix.version }}
|
||||||
args: --timeout=5m --issues-exit-code=0 ./fixtures/simple/...
|
args: --timeout=5m --issues-exit-code=0 ./sample/...
|
||||||
only-new-issues: true
|
only-new-issues: true
|
||||||
|
|
||||||
# make sure the action works on a clean machine without building (go-install mode)
|
test-go-install: # make sure the action works on a clean machine without building (go-install mode)
|
||||||
test-go-install:
|
|
||||||
needs: [ build ]
|
needs: [ build ]
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
|
@ -73,14 +66,14 @@ jobs:
|
||||||
version:
|
version:
|
||||||
- ""
|
- ""
|
||||||
- "latest"
|
- "latest"
|
||||||
- "v2.7.2"
|
- "v2.5.0"
|
||||||
- "655e8ede5178280b2a640e185bc4a343aed0f54e"
|
- "655e8ede5178280b2a640e185bc4a343aed0f54e"
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
pull-requests: read
|
pull-requests: read
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 24.x
|
node-version: 24.x
|
||||||
|
|
@ -90,7 +83,7 @@ jobs:
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.version }}
|
version: ${{ matrix.version }}
|
||||||
args: --timeout=5m --issues-exit-code=0 ./fixtures/simple/...
|
args: --timeout=5m --issues-exit-code=0 ./sample/...
|
||||||
only-new-issues: true
|
only-new-issues: true
|
||||||
install-mode: goinstall
|
install-mode: goinstall
|
||||||
|
|
||||||
|
|
@ -104,13 +97,13 @@ jobs:
|
||||||
- macos-latest
|
- macos-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
wd:
|
wd:
|
||||||
- fixtures/go-mod
|
- sample-go-mod
|
||||||
- fixtures/go-tool
|
- sample-go-tool
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 24.x
|
node-version: 24.x
|
||||||
|
|
@ -122,8 +115,7 @@ jobs:
|
||||||
working-directory: ${{ matrix.wd }}
|
working-directory: ${{ matrix.wd }}
|
||||||
args: --timeout=5m --issues-exit-code=0 ./...
|
args: --timeout=5m --issues-exit-code=0 ./...
|
||||||
|
|
||||||
# make sure the action works on a clean machine with plugins
|
test-plugins: # make sure the action works on a clean machine with plugins
|
||||||
test-plugins:
|
|
||||||
needs: [ build ]
|
needs: [ build ]
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
|
@ -135,14 +127,14 @@ jobs:
|
||||||
version:
|
version:
|
||||||
- ""
|
- ""
|
||||||
- "latest"
|
- "latest"
|
||||||
- "v2.7"
|
- "v2.5"
|
||||||
- "v2.7.2"
|
- "v2.5.0"
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
pull-requests: read
|
pull-requests: read
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 24.x
|
node-version: 24.x
|
||||||
|
|
@ -152,7 +144,7 @@ jobs:
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.version }}
|
version: ${{ matrix.version }}
|
||||||
working-directory: fixtures/plugins
|
working-directory: sample-plugins
|
||||||
args: --timeout=5m --issues-exit-code=0 ./...
|
args: --timeout=5m --issues-exit-code=0 ./...
|
||||||
|
|
||||||
test-monorepo:
|
test-monorepo:
|
||||||
|
|
@ -169,7 +161,7 @@ jobs:
|
||||||
contents: read
|
contents: read
|
||||||
pull-requests: read
|
pull-requests: read
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v5
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 24.x
|
node-version: 24.x
|
||||||
|
|
@ -178,6 +170,6 @@ jobs:
|
||||||
go-version: oldstable
|
go-version: oldstable
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
working-directory: fixtures/monorepo
|
working-directory: sample-monorepo
|
||||||
experimental: "automatic-module-directories"
|
experimental: "automatic-module-directories"
|
||||||
args: --timeout=5m --issues-exit-code=0 ./...
|
args: --timeout=5m --issues-exit-code=0 ./...
|
||||||
|
|
|
||||||
25
README.md
25
README.md
|
|
@ -262,9 +262,8 @@ You will also likely need to add the following `.gitattributes` file to ensure t
|
||||||
### Overview
|
### Overview
|
||||||
|
|
||||||
| Option | Description |
|
| Option | Description |
|
||||||
|---------------------------------------------------------------|-------------------------------------------------------|
|
|---------------------------------------------------------------|----------------------------------------------------|
|
||||||
| [`version`](#version) | The version of golangci-lint to use. |
|
| [`version`](#version) | The version of golangci-lint to use. |
|
||||||
| [`version-file`](#version-file) | Gets the version of golangci-lint to use from a file. |
|
|
||||||
| [`install-mode`](#install-mode) | The mode to install golangci-lint. |
|
| [`install-mode`](#install-mode) | The mode to install golangci-lint. |
|
||||||
| [`install-only`](#install-only) | Only install golangci-lint. |
|
| [`install-only`](#install-only) | Only install golangci-lint. |
|
||||||
| [`verify`](#verify) | Validates golangci-lint configuration file. |
|
| [`verify`](#verify) | Validates golangci-lint configuration file. |
|
||||||
|
|
@ -303,28 +302,6 @@ with:
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
#### `version-file`
|
|
||||||
|
|
||||||
Gets the version of golangci-lint to use from a file.
|
|
||||||
|
|
||||||
The path must be relative to the root of the project, or the `working-directory` if defined.
|
|
||||||
|
|
||||||
This parameter supports `.golangci-lint-version`, and `.tool-versions` files.
|
|
||||||
|
|
||||||
Only works with `install-mode: binary` (the default).
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Example</summary>
|
|
||||||
|
|
||||||
```yml
|
|
||||||
uses: golangci/golangci-lint-action@v9
|
|
||||||
with:
|
|
||||||
version-file: .tool-versions
|
|
||||||
# ...
|
|
||||||
```
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
#### `install-mode`
|
#### `install-mode`
|
||||||
|
|
||||||
(optional)
|
(optional)
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,6 @@ inputs:
|
||||||
- `goinstall`: the value can be v2.3.4, `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
|
||||||
version-file:
|
|
||||||
description: |
|
|
||||||
Gets the version of golangci-lint to use from a file.
|
|
||||||
The path must be relative to the root of the project, or the `working-directory` if defined.
|
|
||||||
This parameter supports `.golangci-lint-version`, and `.tool-versions` files.
|
|
||||||
Only works with `install-mode: binary` (the default).
|
|
||||||
required: false
|
|
||||||
install-mode:
|
install-mode:
|
||||||
description: "The mode to install golangci-lint. It can be 'binary', 'goinstall', or 'none'."
|
description: "The mode to install golangci-lint. It can be 'binary', 'goinstall', or 'none'."
|
||||||
default: "binary"
|
default: "binary"
|
||||||
|
|
|
||||||
96799
dist/post_run/index.js
generated
vendored
96799
dist/post_run/index.js
generated
vendored
File diff suppressed because one or more lines are too long
96799
dist/run/index.js
generated
vendored
96799
dist/run/index.js
generated
vendored
File diff suppressed because one or more lines are too long
1013
package-lock.json
generated
1013
package-lock.json
generated
File diff suppressed because it is too large
Load diff
14
package.json
14
package.json
|
|
@ -27,23 +27,23 @@
|
||||||
"node": ">=24.0.0"
|
"node": ">=24.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^5.0.1",
|
"@actions/cache": "^4.1.0",
|
||||||
"@actions/core": "^2.0.1",
|
"@actions/core": "^1.11.1",
|
||||||
"@actions/exec": "^2.0.0",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/github": "^6.0.1",
|
"@actions/github": "^6.0.1",
|
||||||
"@actions/http-client": "^3.0.0",
|
"@actions/http-client": "^3.0.0",
|
||||||
"@octokit/plugin-retry": "^6.1.0",
|
"@octokit/plugin-retry": "^6.1.0",
|
||||||
"@actions/tool-cache": "^2.0.2",
|
"@actions/tool-cache": "^2.0.2",
|
||||||
"@types/node": "^25.0.2",
|
"@types/node": "^24.10.1",
|
||||||
"@types/semver": "^7.7.1",
|
"@types/semver": "^7.7.1",
|
||||||
"@types/tmp": "^0.2.6",
|
"@types/tmp": "^0.2.6",
|
||||||
"@types/which": "^3.0.4",
|
"@types/which": "^3.0.4",
|
||||||
"tmp": "^0.2.5",
|
"tmp": "^0.2.5",
|
||||||
"which": "^6.0.0",
|
"which": "^6.0.0",
|
||||||
"yaml": "^2.8.2"
|
"yaml": "^2.8.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@typescript-eslint/eslint-plugin": "^8.49.0",
|
"@typescript-eslint/eslint-plugin": "^8.46.4",
|
||||||
"@typescript-eslint/parser": "^8.32.1",
|
"@typescript-eslint/parser": "^8.32.1",
|
||||||
"@vercel/ncc": "^0.38.4",
|
"@vercel/ncc": "^0.38.4",
|
||||||
"eslint": "^8.57.1",
|
"eslint": "^8.57.1",
|
||||||
|
|
@ -51,7 +51,7 @@
|
||||||
"eslint-plugin-import": "^2.32.0",
|
"eslint-plugin-import": "^2.32.0",
|
||||||
"eslint-plugin-prettier": "^5.5.4",
|
"eslint-plugin-prettier": "^5.5.4",
|
||||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||||
"prettier": "^3.7.4",
|
"prettier": "^3.6.2",
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
module github.com/golangci/sample
|
module sample
|
||||||
|
|
||||||
go 1.24.0
|
go 1.24.0
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
module github.com/golangci/sample
|
module sample
|
||||||
|
|
||||||
go 1.24.0
|
go 1.24.0
|
||||||
|
|
||||||
|
|
@ -67,12 +67,6 @@ const isLessVersion = (a: Version, b: Version): boolean => {
|
||||||
|
|
||||||
const getRequestedVersion = (): Version => {
|
const getRequestedVersion = (): Version => {
|
||||||
let requestedVersion = core.getInput(`version`)
|
let requestedVersion = core.getInput(`version`)
|
||||||
let versionFilePath = core.getInput(`version-file`)
|
|
||||||
|
|
||||||
if (requestedVersion && versionFilePath) {
|
|
||||||
core.warning(`Both version (${requestedVersion}) and version-file (${versionFilePath}) inputs are specified, only version will be used`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const workingDirectory = core.getInput(`working-directory`)
|
const workingDirectory = core.getInput(`working-directory`)
|
||||||
|
|
||||||
let goMod = "go.mod"
|
let goMod = "go.mod"
|
||||||
|
|
@ -89,27 +83,6 @@ const getRequestedVersion = (): Version => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requestedVersion == "" && versionFilePath) {
|
|
||||||
if (workingDirectory) {
|
|
||||||
versionFilePath = path.join(workingDirectory, versionFilePath)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fs.existsSync(versionFilePath)) {
|
|
||||||
throw new Error(`The specified golangci-lint version file at: ${versionFilePath} does not exist`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const content = fs.readFileSync(versionFilePath, "utf-8")
|
|
||||||
|
|
||||||
if (path.basename(versionFilePath) === ".tool-versions") {
|
|
||||||
// asdf/mise file.
|
|
||||||
const match = content.match(/^golangci-lint\s+([^\n#]+)/m)
|
|
||||||
requestedVersion = match ? "v" + match[1].trim().replace(/^v/gi, "") : ""
|
|
||||||
} else {
|
|
||||||
// .golangci-lint-version file.
|
|
||||||
requestedVersion = "v" + content.trim().replace(/^v/gi, "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const parsedRequestedVersion = parseVersion(requestedVersion)
|
const parsedRequestedVersion = parseVersion(requestedVersion)
|
||||||
if (parsedRequestedVersion == null) {
|
if (parsedRequestedVersion == null) {
|
||||||
return null
|
return null
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue