feat: golangci-lint v2 support (#1198)
This commit is contained in:
committed by
GitHub
parent
1f07148fa0
commit
dec74fa030
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
@ -54,8 +54,8 @@ jobs:
|
|||||||
version:
|
version:
|
||||||
- ""
|
- ""
|
||||||
- "latest"
|
- "latest"
|
||||||
- "v1.63" # TODO(ldez): it should be updated for v2.
|
- "v2.0"
|
||||||
- "v1.63.4" # TODO(ldez): it should be updated for v2.
|
- "v2.0.0"
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@ -83,8 +83,8 @@ jobs:
|
|||||||
version:
|
version:
|
||||||
- ""
|
- ""
|
||||||
- "latest"
|
- "latest"
|
||||||
- "v1.63.4" # TODO(ldez): it should be updated for v2.
|
- "v2.0.0"
|
||||||
- "95c39ac1fbaf66475705c06c16259ffd9d6bf9a2" # TODO(ldez): it should be updated for v2.
|
- "1f032fbc4b117e4247b19ff606cc847ab5383bc9"
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
version: "2"
|
||||||
|
|
||||||
output:
|
output:
|
||||||
show-stats: true
|
show-stats: true
|
||||||
sort-results: true
|
|
||||||
sort-order:
|
sort-order:
|
||||||
|
- file
|
||||||
- linter
|
- linter
|
||||||
- file
|
|
53
README.md
53
README.md
@ -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@v7
|
||||||
with:
|
with:
|
||||||
version: v1.64
|
version: v2.0
|
||||||
```
|
```
|
||||||
|
|
||||||
</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@v7
|
||||||
with:
|
with:
|
||||||
version: v1.64
|
version: v2.0
|
||||||
```
|
```
|
||||||
|
|
||||||
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:
|
||||||
@ -120,7 +120,7 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
GO_VERSION: stable
|
GO_VERSION: stable
|
||||||
GOLANGCI_LINT_VERSION: v1.64
|
GOLANGCI_LINT_VERSION: v2.0
|
||||||
|
|
||||||
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@v7
|
||||||
with:
|
with:
|
||||||
version: ${{ env.GOLANGCI_LINT_VERSION }}
|
version: ${{ env.GOLANGCI_LINT_VERSION }}
|
||||||
working-directory: ${{ matrix.modules }}
|
working-directory: ${{ matrix.modules }}
|
||||||
@ -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.64
|
golangci-lint-version: v2.0
|
||||||
```
|
```
|
||||||
|
|
||||||
```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.64'
|
default: 'v2.0'
|
||||||
|
|
||||||
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@v7
|
||||||
with:
|
with:
|
||||||
version: ${{ inputs.golangci-lint-version }}
|
version: ${{ inputs.golangci-lint-version }}
|
||||||
working-directory: ${{ matrix.modules }}
|
working-directory: ${{ matrix.modules }}
|
||||||
@ -245,6 +245,7 @@ You will also likely need to add the following `.gitattributes` file to ensure t
|
|||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
|
* `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`.
|
||||||
@ -262,17 +263,17 @@ You will also likely need to add the following `.gitattributes` file to ensure t
|
|||||||
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@v7
|
||||||
with:
|
with:
|
||||||
version: v1.58
|
version: v2.0
|
||||||
# ...
|
# ...
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -290,7 +291,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@v7
|
||||||
with:
|
with:
|
||||||
install-mode: "goinstall"
|
install-mode: "goinstall"
|
||||||
# ...
|
# ...
|
||||||
@ -310,7 +311,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@v7
|
||||||
with:
|
with:
|
||||||
github-token: xxx
|
github-token: xxx
|
||||||
# ...
|
# ...
|
||||||
@ -333,7 +334,7 @@ The JSONSchema used to validate the configuration depends on the version of gola
|
|||||||
<summary>Example</summary>
|
<summary>Example</summary>
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: golangci/golangci-lint-action@v6
|
uses: golangci/golangci-lint-action@v7
|
||||||
with:
|
with:
|
||||||
verify: false
|
verify: false
|
||||||
# ...
|
# ...
|
||||||
@ -358,7 +359,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@v7
|
||||||
with:
|
with:
|
||||||
only-new-issues: true
|
only-new-issues: true
|
||||||
# ...
|
# ...
|
||||||
@ -376,7 +377,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@v7
|
||||||
with:
|
with:
|
||||||
working-directory: somedir
|
working-directory: somedir
|
||||||
# ...
|
# ...
|
||||||
@ -397,9 +398,9 @@ The location of the configuration file can be changed by using `--config=`
|
|||||||
<summary>Example</summary>
|
<summary>Example</summary>
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: golangci/golangci-lint-action@v6
|
uses: golangci/golangci-lint-action@v7
|
||||||
with:
|
with:
|
||||||
args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
|
args: --config=/my/path/.golangci.yml --issues-exit-code=0
|
||||||
# ...
|
# ...
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -411,7 +412,7 @@ 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 `colored-line-number` (the golangci-lint default).
|
||||||
|
|
||||||
@ -423,7 +424,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@v7
|
||||||
with:
|
with:
|
||||||
problem-matchers: true
|
problem-matchers: true
|
||||||
# ...
|
# ...
|
||||||
@ -444,7 +445,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@v7
|
||||||
with:
|
with:
|
||||||
skip-cache: true
|
skip-cache: true
|
||||||
# ...
|
# ...
|
||||||
@ -464,7 +465,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@v7
|
||||||
with:
|
with:
|
||||||
skip-save-cache: true
|
skip-save-cache: true
|
||||||
# ...
|
# ...
|
||||||
@ -486,7 +487,7 @@ If set the number is `<= 0`, the cache will be always invalidate (Not recommende
|
|||||||
<summary>Example</summary>
|
<summary>Example</summary>
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
uses: golangci/golangci-lint-action@v6
|
uses: golangci/golangci-lint-action@v7
|
||||||
with:
|
with:
|
||||||
cache-invalidation-interval: 15
|
cache-invalidation-interval: 15
|
||||||
# ...
|
# ...
|
||||||
@ -515,7 +516,7 @@ permissions:
|
|||||||
pull-requests: read
|
pull-requests: read
|
||||||
```
|
```
|
||||||
|
|
||||||
For annotations to work use the default `colored-line-number` output and either use `actions/setup-go` in the job or enable the internal [problem matchers](#problem-matchers).
|
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
|
||||||
|
|
||||||
|
@ -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:
|
||||||
|
58
dist/post_run/index.js
generated
vendored
58
dist/post_run/index.js
generated
vendored
@ -92568,11 +92568,9 @@ async function goInstall(versionInfo) {
|
|||||||
core.info(`Installing golangci-lint ${versionInfo.TargetVersion}...`);
|
core.info(`Installing golangci-lint ${versionInfo.TargetVersion}...`);
|
||||||
const startedAt = Date.now();
|
const startedAt = Date.now();
|
||||||
const options = { env: { ...process.env, CGO_ENABLED: "1" } };
|
const options = { env: { ...process.env, CGO_ENABLED: "1" } };
|
||||||
// TODO(ldez): it should be updated for v2.
|
const exres = await execShellCommand(`go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${versionInfo.TargetVersion}`, options);
|
||||||
const exres = await execShellCommand(`go install github.com/golangci/golangci-lint/cmd/golangci-lint@${versionInfo.TargetVersion}`, options);
|
|
||||||
printOutput(exres);
|
printOutput(exres);
|
||||||
// TODO(ldez): it should be updated for v2.
|
const res = await execShellCommand(`go install -n github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${versionInfo.TargetVersion}`, options);
|
||||||
const res = await execShellCommand(`go install -n github.com/golangci/golangci-lint/cmd/golangci-lint@${versionInfo.TargetVersion}`, 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 binPath = res.stderr
|
const binPath = res.stderr
|
||||||
@ -92873,7 +92871,7 @@ async function runLint(binPath, patchPath) {
|
|||||||
const res = await execShellCommand(`${binPath} 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 = [];
|
const addedArgs = [];
|
||||||
const userArgsList = userArgs
|
const userArgsList = userArgs
|
||||||
.trim()
|
.trim()
|
||||||
@ -92893,20 +92891,11 @@ async function runLint(binPath, patchPath) {
|
|||||||
core.info(`##[add-matcher]${matchersPath}`);
|
core.info(`##[add-matcher]${matchersPath}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 ((0, patch_1.isOnlyNewIssues)()) {
|
if ((0, patch_1.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`);
|
||||||
}
|
}
|
||||||
const ctx = github.context;
|
const ctx = github.context;
|
||||||
@ -92920,6 +92909,7 @@ async function runLint(binPath, patchPath) {
|
|||||||
// 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`:
|
||||||
@ -92927,6 +92917,7 @@ async function runLint(binPath, patchPath) {
|
|||||||
// 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;
|
||||||
@ -92954,7 +92945,6 @@ async function runLint(binPath, patchPath) {
|
|||||||
}
|
}
|
||||||
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) {
|
||||||
core.setFailed(`issues found`);
|
core.setFailed(`issues found`);
|
||||||
@ -93233,20 +93223,17 @@ const fs = __importStar(__nccwpck_require__(9896));
|
|||||||
const path_1 = __importDefault(__nccwpck_require__(6928));
|
const path_1 = __importDefault(__nccwpck_require__(6928));
|
||||||
const install_1 = __nccwpck_require__(232);
|
const install_1 = __nccwpck_require__(232);
|
||||||
const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/;
|
const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/;
|
||||||
// TODO(ldez): it should be updated to match v2 module name.
|
const modVersionRe = /github.com\/golangci\/golangci-lint\/v2\s(v\S+)/;
|
||||||
const modVersionRe = /github.com\/golangci\/golangci-lint\s(v\S+)/;
|
|
||||||
const parseVersion = (s) => {
|
const parseVersion = (s) => {
|
||||||
if (s == "latest" || s == "") {
|
if (s == "latest" || s == "") {
|
||||||
// TODO(ldez): v2: it should be replaced with "return null"
|
return null;
|
||||||
return { major: 1, minor: 64, patch: 8 };
|
|
||||||
}
|
}
|
||||||
const match = s.match(versionRe);
|
const match = s.match(versionRe);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
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`);
|
||||||
}
|
}
|
||||||
// TODO(ldez): v2: to remove.
|
if (parseInt(match[1]) !== 2) {
|
||||||
if (parseInt(match[1]) > 1) {
|
throw new Error(`invalid version string '${s}', golangci-lint v${match[1]} is not supported by golangci-lint-action v7.`);
|
||||||
throw new Error(`invalid version string '${s}', golangci-lint v2 is not supported by golangci-lint-action v6, you must update to golangci-lint-action v7.`);
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
major: parseInt(match[1]),
|
major: parseInt(match[1]),
|
||||||
@ -93261,11 +93248,10 @@ const stringifyVersion = (v) => {
|
|||||||
return `v${v.major}.${v.minor}${v.patch !== null ? `.${v.patch}` : ``}`;
|
return `v${v.major}.${v.minor}${v.patch !== null ? `.${v.patch}` : ``}`;
|
||||||
};
|
};
|
||||||
exports.stringifyVersion = stringifyVersion;
|
exports.stringifyVersion = stringifyVersion;
|
||||||
// TODO(ldez): it should be updated to v2.0.0.
|
|
||||||
const minVersion = {
|
const minVersion = {
|
||||||
major: 1,
|
major: 2,
|
||||||
minor: 28,
|
minor: 0,
|
||||||
patch: 3,
|
patch: 0,
|
||||||
};
|
};
|
||||||
const isLessVersion = (a, b) => {
|
const isLessVersion = (a, b) => {
|
||||||
if (a == null) {
|
if (a == null) {
|
||||||
@ -93311,7 +93297,7 @@ const fetchVersionMapping = async () => {
|
|||||||
maxRetries: 5,
|
maxRetries: 5,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v1.json`;
|
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v2.json`;
|
||||||
const response = await http.get(url);
|
const response = 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})`);
|
||||||
@ -93327,17 +93313,11 @@ async function getVersion(mode) {
|
|||||||
core.info(`Finding needed golangci-lint version...`);
|
core.info(`Finding needed golangci-lint version...`);
|
||||||
if (mode == install_1.InstallMode.GoInstall) {
|
if (mode == install_1.InstallMode.GoInstall) {
|
||||||
const v = core.getInput(`version`);
|
const v = core.getInput(`version`);
|
||||||
// TODO(ldez): v2: to remove.
|
return { TargetVersion: v ? v : "latest" };
|
||||||
if (v == "latest") {
|
|
||||||
return { TargetVersion: "v1.64.8" };
|
|
||||||
}
|
|
||||||
// TODO(ldez): v2: "v1.64.8" should be replaced with "latest".
|
|
||||||
return { TargetVersion: v ? v : "v1.64.8" };
|
|
||||||
}
|
}
|
||||||
const reqVersion = getRequestedVersion();
|
const reqVersion = getRequestedVersion();
|
||||||
// if the patched version is passed, just use it
|
// if the patched version is passed, just use it
|
||||||
// TODO(ldez): should be updated to `reqVersion?.major === 2`.
|
if (reqVersion?.major === 2 && reqVersion?.minor != null && reqVersion?.patch !== null) {
|
||||||
if (reqVersion?.major === 1 && reqVersion?.minor != null && reqVersion?.patch !== null) {
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const versionWithoutV = `${reqVersion.major}.${reqVersion.minor}.${reqVersion.patch}`;
|
const versionWithoutV = `${reqVersion.major}.${reqVersion.minor}.${reqVersion.patch}`;
|
||||||
resolve({ TargetVersion: `v${versionWithoutV}` });
|
resolve({ TargetVersion: `v${versionWithoutV}` });
|
||||||
|
58
dist/run/index.js
generated
vendored
58
dist/run/index.js
generated
vendored
@ -92568,11 +92568,9 @@ async function goInstall(versionInfo) {
|
|||||||
core.info(`Installing golangci-lint ${versionInfo.TargetVersion}...`);
|
core.info(`Installing golangci-lint ${versionInfo.TargetVersion}...`);
|
||||||
const startedAt = Date.now();
|
const startedAt = Date.now();
|
||||||
const options = { env: { ...process.env, CGO_ENABLED: "1" } };
|
const options = { env: { ...process.env, CGO_ENABLED: "1" } };
|
||||||
// TODO(ldez): it should be updated for v2.
|
const exres = await execShellCommand(`go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${versionInfo.TargetVersion}`, options);
|
||||||
const exres = await execShellCommand(`go install github.com/golangci/golangci-lint/cmd/golangci-lint@${versionInfo.TargetVersion}`, options);
|
|
||||||
printOutput(exres);
|
printOutput(exres);
|
||||||
// TODO(ldez): it should be updated for v2.
|
const res = await execShellCommand(`go install -n github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${versionInfo.TargetVersion}`, options);
|
||||||
const res = await execShellCommand(`go install -n github.com/golangci/golangci-lint/cmd/golangci-lint@${versionInfo.TargetVersion}`, 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 binPath = res.stderr
|
const binPath = res.stderr
|
||||||
@ -92873,7 +92871,7 @@ async function runLint(binPath, patchPath) {
|
|||||||
const res = await execShellCommand(`${binPath} 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 = [];
|
const addedArgs = [];
|
||||||
const userArgsList = userArgs
|
const userArgsList = userArgs
|
||||||
.trim()
|
.trim()
|
||||||
@ -92893,20 +92891,11 @@ async function runLint(binPath, patchPath) {
|
|||||||
core.info(`##[add-matcher]${matchersPath}`);
|
core.info(`##[add-matcher]${matchersPath}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 ((0, patch_1.isOnlyNewIssues)()) {
|
if ((0, patch_1.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`);
|
||||||
}
|
}
|
||||||
const ctx = github.context;
|
const ctx = github.context;
|
||||||
@ -92920,6 +92909,7 @@ async function runLint(binPath, patchPath) {
|
|||||||
// 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`:
|
||||||
@ -92927,6 +92917,7 @@ async function runLint(binPath, patchPath) {
|
|||||||
// 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;
|
||||||
@ -92954,7 +92945,6 @@ async function runLint(binPath, patchPath) {
|
|||||||
}
|
}
|
||||||
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) {
|
||||||
core.setFailed(`issues found`);
|
core.setFailed(`issues found`);
|
||||||
@ -93233,20 +93223,17 @@ const fs = __importStar(__nccwpck_require__(9896));
|
|||||||
const path_1 = __importDefault(__nccwpck_require__(6928));
|
const path_1 = __importDefault(__nccwpck_require__(6928));
|
||||||
const install_1 = __nccwpck_require__(232);
|
const install_1 = __nccwpck_require__(232);
|
||||||
const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/;
|
const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/;
|
||||||
// TODO(ldez): it should be updated to match v2 module name.
|
const modVersionRe = /github.com\/golangci\/golangci-lint\/v2\s(v\S+)/;
|
||||||
const modVersionRe = /github.com\/golangci\/golangci-lint\s(v\S+)/;
|
|
||||||
const parseVersion = (s) => {
|
const parseVersion = (s) => {
|
||||||
if (s == "latest" || s == "") {
|
if (s == "latest" || s == "") {
|
||||||
// TODO(ldez): v2: it should be replaced with "return null"
|
return null;
|
||||||
return { major: 1, minor: 64, patch: 8 };
|
|
||||||
}
|
}
|
||||||
const match = s.match(versionRe);
|
const match = s.match(versionRe);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
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`);
|
||||||
}
|
}
|
||||||
// TODO(ldez): v2: to remove.
|
if (parseInt(match[1]) !== 2) {
|
||||||
if (parseInt(match[1]) > 1) {
|
throw new Error(`invalid version string '${s}', golangci-lint v${match[1]} is not supported by golangci-lint-action v7.`);
|
||||||
throw new Error(`invalid version string '${s}', golangci-lint v2 is not supported by golangci-lint-action v6, you must update to golangci-lint-action v7.`);
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
major: parseInt(match[1]),
|
major: parseInt(match[1]),
|
||||||
@ -93261,11 +93248,10 @@ const stringifyVersion = (v) => {
|
|||||||
return `v${v.major}.${v.minor}${v.patch !== null ? `.${v.patch}` : ``}`;
|
return `v${v.major}.${v.minor}${v.patch !== null ? `.${v.patch}` : ``}`;
|
||||||
};
|
};
|
||||||
exports.stringifyVersion = stringifyVersion;
|
exports.stringifyVersion = stringifyVersion;
|
||||||
// TODO(ldez): it should be updated to v2.0.0.
|
|
||||||
const minVersion = {
|
const minVersion = {
|
||||||
major: 1,
|
major: 2,
|
||||||
minor: 28,
|
minor: 0,
|
||||||
patch: 3,
|
patch: 0,
|
||||||
};
|
};
|
||||||
const isLessVersion = (a, b) => {
|
const isLessVersion = (a, b) => {
|
||||||
if (a == null) {
|
if (a == null) {
|
||||||
@ -93311,7 +93297,7 @@ const fetchVersionMapping = async () => {
|
|||||||
maxRetries: 5,
|
maxRetries: 5,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v1.json`;
|
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v2.json`;
|
||||||
const response = await http.get(url);
|
const response = 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})`);
|
||||||
@ -93327,17 +93313,11 @@ async function getVersion(mode) {
|
|||||||
core.info(`Finding needed golangci-lint version...`);
|
core.info(`Finding needed golangci-lint version...`);
|
||||||
if (mode == install_1.InstallMode.GoInstall) {
|
if (mode == install_1.InstallMode.GoInstall) {
|
||||||
const v = core.getInput(`version`);
|
const v = core.getInput(`version`);
|
||||||
// TODO(ldez): v2: to remove.
|
return { TargetVersion: v ? v : "latest" };
|
||||||
if (v == "latest") {
|
|
||||||
return { TargetVersion: "v1.64.8" };
|
|
||||||
}
|
|
||||||
// TODO(ldez): v2: "v1.64.8" should be replaced with "latest".
|
|
||||||
return { TargetVersion: v ? v : "v1.64.8" };
|
|
||||||
}
|
}
|
||||||
const reqVersion = getRequestedVersion();
|
const reqVersion = getRequestedVersion();
|
||||||
// if the patched version is passed, just use it
|
// if the patched version is passed, just use it
|
||||||
// TODO(ldez): should be updated to `reqVersion?.major === 2`.
|
if (reqVersion?.major === 2 && reqVersion?.minor != null && reqVersion?.patch !== null) {
|
||||||
if (reqVersion?.major === 1 && reqVersion?.minor != null && reqVersion?.patch !== null) {
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const versionWithoutV = `${reqVersion.major}.${reqVersion.minor}.${reqVersion.patch}`;
|
const versionWithoutV = `${reqVersion.major}.${reqVersion.minor}.${reqVersion.patch}`;
|
||||||
resolve({ TargetVersion: `v${versionWithoutV}` });
|
resolve({ TargetVersion: `v${versionWithoutV}` });
|
||||||
|
2
go.mod
2
go.mod
@ -1,3 +1,3 @@
|
|||||||
module github.com/golangci/golangci-lint-action
|
module github.com/golangci/golangci-lint-action
|
||||||
|
|
||||||
go 1.14
|
go 1.23
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
version: "2"
|
||||||
|
|
||||||
output:
|
output:
|
||||||
show-stats: true
|
show-stats: true
|
||||||
sort-results: true
|
|
||||||
sort-order:
|
sort-order:
|
||||||
|
- file
|
||||||
- linter
|
- linter
|
||||||
- file
|
|
@ -2,7 +2,7 @@ module sample
|
|||||||
|
|
||||||
go 1.22.1
|
go 1.22.1
|
||||||
|
|
||||||
require github.com/golangci/golangci-lint v1.60.1
|
require github.com/golangci/golangci-lint/v2 v2.0.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
|
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
|
||||||
|
@ -3,5 +3,5 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
|
_ "github.com/golangci/golangci-lint/v2/cmd/golangci-lint"
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
version: "2"
|
||||||
|
|
||||||
output:
|
output:
|
||||||
show-stats: true
|
show-stats: true
|
||||||
sort-results: true
|
|
||||||
sort-order:
|
sort-order:
|
||||||
|
- file
|
||||||
- linter
|
- linter
|
||||||
- file
|
|
@ -4,7 +4,7 @@ go 1.24
|
|||||||
|
|
||||||
toolchain go1.24.0
|
toolchain go1.24.0
|
||||||
|
|
||||||
tool github.com/golangci/golangci-lint/cmd/golangci-lint
|
tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint
|
||||||
|
|
||||||
require (
|
require (
|
||||||
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
|
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
|
||||||
@ -68,7 +68,7 @@ require (
|
|||||||
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // 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-printf-func-name v0.1.0 // indirect
|
||||||
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect
|
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect
|
||||||
github.com/golangci/golangci-lint v1.64.4 // indirect
|
github.com/golangci/golangci-lint/v2 v2.0.0 // indirect
|
||||||
github.com/golangci/misspell v0.6.0 // indirect
|
github.com/golangci/misspell v0.6.0 // indirect
|
||||||
github.com/golangci/plugin-module-register v0.1.1 // indirect
|
github.com/golangci/plugin-module-register v0.1.1 // indirect
|
||||||
github.com/golangci/revgrep v0.8.0 // indirect
|
github.com/golangci/revgrep v0.8.0 // indirect
|
||||||
|
@ -84,16 +84,14 @@ async function goInstall(versionInfo: VersionInfo): Promise<string> {
|
|||||||
|
|
||||||
const options: ExecOptions = { env: { ...process.env, CGO_ENABLED: "1" } }
|
const options: ExecOptions = { env: { ...process.env, CGO_ENABLED: "1" } }
|
||||||
|
|
||||||
// TODO(ldez): it should be updated for v2.
|
|
||||||
const exres = await execShellCommand(
|
const exres = await execShellCommand(
|
||||||
`go install github.com/golangci/golangci-lint/cmd/golangci-lint@${versionInfo.TargetVersion}`,
|
`go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${versionInfo.TargetVersion}`,
|
||||||
options
|
options
|
||||||
)
|
)
|
||||||
printOutput(exres)
|
printOutput(exres)
|
||||||
|
|
||||||
// TODO(ldez): it should be updated for v2.
|
|
||||||
const res = await execShellCommand(
|
const res = await execShellCommand(
|
||||||
`go install -n github.com/golangci/golangci-lint/cmd/golangci-lint@${versionInfo.TargetVersion}`,
|
`go install -n github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${versionInfo.TargetVersion}`,
|
||||||
options
|
options
|
||||||
)
|
)
|
||||||
printOutput(res)
|
printOutput(res)
|
||||||
|
27
src/run.ts
27
src/run.ts
@ -51,7 +51,7 @@ async function runLint(binPath: string, patchPath: string): Promise<void> {
|
|||||||
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
|
||||||
@ -76,23 +76,13 @@ async function runLint(binPath: 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`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,6 +100,7 @@ async function runLint(binPath: 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`:
|
||||||
@ -118,6 +109,7 @@ async function runLint(binPath: 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
|
||||||
@ -150,7 +142,6 @@ async function runLint(binPath: 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) {
|
||||||
|
@ -13,13 +13,11 @@ export type Version = {
|
|||||||
} | null
|
} | null
|
||||||
|
|
||||||
const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/
|
const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/
|
||||||
// TODO(ldez): it should be updated to match v2 module name.
|
const modVersionRe = /github.com\/golangci\/golangci-lint\/v2\s(v\S+)/
|
||||||
const modVersionRe = /github.com\/golangci\/golangci-lint\s(v\S+)/
|
|
||||||
|
|
||||||
const parseVersion = (s: string): Version => {
|
const parseVersion = (s: string): Version => {
|
||||||
if (s == "latest" || s == "") {
|
if (s == "latest" || s == "") {
|
||||||
// TODO(ldez): v2: it should be replaced with "return null"
|
return null
|
||||||
return { major: 1, minor: 64, patch: 8 }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const match = s.match(versionRe)
|
const match = s.match(versionRe)
|
||||||
@ -27,11 +25,8 @@ 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`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(ldez): v2: to remove.
|
if (parseInt(match[1]) !== 2) {
|
||||||
if (parseInt(match[1]) > 1) {
|
throw new Error(`invalid version string '${s}', golangci-lint v${match[1]} is not supported by golangci-lint-action v7.`)
|
||||||
throw new Error(
|
|
||||||
`invalid version string '${s}', golangci-lint v2 is not supported by golangci-lint-action v6, you must update to golangci-lint-action v7.`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -48,11 +43,10 @@ export const stringifyVersion = (v: Version): string => {
|
|||||||
return `v${v.major}.${v.minor}${v.patch !== null ? `.${v.patch}` : ``}`
|
return `v${v.major}.${v.minor}${v.patch !== null ? `.${v.patch}` : ``}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(ldez): it should be updated to v2.0.0.
|
|
||||||
const minVersion = {
|
const minVersion = {
|
||||||
major: 1,
|
major: 2,
|
||||||
minor: 28,
|
minor: 0,
|
||||||
patch: 3,
|
patch: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
const isLessVersion = (a: Version, b: Version): boolean => {
|
const isLessVersion = (a: Version, b: Version): boolean => {
|
||||||
@ -122,7 +116,7 @@ const fetchVersionMapping = async (): Promise<VersionMapping> => {
|
|||||||
maxRetries: 5,
|
maxRetries: 5,
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v1.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})`)
|
||||||
@ -140,20 +134,14 @@ export async function getVersion(mode: InstallMode): Promise<VersionInfo> {
|
|||||||
|
|
||||||
if (mode == InstallMode.GoInstall) {
|
if (mode == InstallMode.GoInstall) {
|
||||||
const v: string = core.getInput(`version`)
|
const v: string = core.getInput(`version`)
|
||||||
// TODO(ldez): v2: to remove.
|
|
||||||
if (v == "latest") {
|
|
||||||
return { TargetVersion: "v1.64.8" }
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(ldez): v2: "v1.64.8" should be replaced with "latest".
|
return { TargetVersion: v ? v : "latest" }
|
||||||
return { TargetVersion: v ? v : "v1.64.8" }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const reqVersion = getRequestedVersion()
|
const reqVersion = getRequestedVersion()
|
||||||
|
|
||||||
// if the patched version is passed, just use it
|
// if the patched version is passed, just use it
|
||||||
// TODO(ldez): should be updated to `reqVersion?.major === 2`.
|
if (reqVersion?.major === 2 && reqVersion?.minor != null && reqVersion?.patch !== null) {
|
||||||
if (reqVersion?.major === 1 && reqVersion?.minor != null && reqVersion?.patch !== null) {
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const versionWithoutV = `${reqVersion.major}.${reqVersion.minor}.${reqVersion.patch}`
|
const versionWithoutV = `${reqVersion.major}.${reqVersion.minor}.${reqVersion.patch}`
|
||||||
resolve({ TargetVersion: `v${versionWithoutV}` })
|
resolve({ TargetVersion: `v${versionWithoutV}` })
|
||||||
|
Reference in New Issue
Block a user