Compare commits

...

5 Commits

17 changed files with 262 additions and 259 deletions

View File

@ -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

View File

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

View File

@ -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
# ... # ...
@ -505,7 +506,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:
@ -513,11 +514,9 @@ 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 `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

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:

110
dist/post_run/index.js generated vendored
View File

@ -62206,7 +62206,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */ ***************************************************************************** */
/* global global, define, Symbol, Reflect, Promise, SuppressedError */ /* global global, define, Symbol, Reflect, Promise, SuppressedError, Iterator */
var __extends; var __extends;
var __assign; var __assign;
var __rest; var __rest;
@ -62238,6 +62238,7 @@ var __classPrivateFieldIn;
var __createBinding; var __createBinding;
var __addDisposableResource; var __addDisposableResource;
var __disposeResources; var __disposeResources;
var __rewriteRelativeImportExtension;
(function (factory) { (function (factory) {
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
if (typeof define === "function" && define.amd) { if (typeof define === "function" && define.amd) {
@ -62365,8 +62366,8 @@ var __disposeResources;
}; };
__generator = function (thisArg, body) { __generator = function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; } function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) { function step(op) {
if (f) throw new TypeError("Generator is already executing."); if (f) throw new TypeError("Generator is already executing.");
@ -62470,8 +62471,9 @@ var __disposeResources;
__asyncGenerator = function (thisArg, _arguments, generator) { __asyncGenerator = function (thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = []; var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); } function fulfill(value) { resume("next", value); }
@ -62504,10 +62506,19 @@ var __disposeResources;
o["default"] = v; o["default"] = v;
}; };
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
__importStar = function (mod) { __importStar = function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -62537,7 +62548,7 @@ var __disposeResources;
__addDisposableResource = function (env, value, async) { __addDisposableResource = function (env, value, async) {
if (value !== null && value !== void 0) { if (value !== null && value !== void 0) {
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
var dispose; var dispose, inner;
if (async) { if (async) {
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
dispose = value[Symbol.asyncDispose]; dispose = value[Symbol.asyncDispose];
@ -62545,8 +62556,10 @@ var __disposeResources;
if (dispose === void 0) { if (dispose === void 0) {
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
dispose = value[Symbol.dispose]; dispose = value[Symbol.dispose];
if (async) inner = dispose;
} }
if (typeof dispose !== "function") throw new TypeError("Object not disposable."); if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
env.stack.push({ value: value, dispose: dispose, async: async }); env.stack.push({ value: value, dispose: dispose, async: async });
} }
else if (async) { else if (async) {
@ -62565,22 +62578,36 @@ var __disposeResources;
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
env.hasError = true; env.hasError = true;
} }
var r, s = 0;
function next() { function next() {
while (env.stack.length) { while (r = env.stack.pop()) {
var rec = env.stack.pop();
try { try {
var result = rec.dispose && rec.dispose.call(rec.value); if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); if (r.dispose) {
var result = r.dispose.call(r.value);
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
}
else s |= 1;
} }
catch (e) { catch (e) {
fail(e); fail(e);
} }
} }
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
if (env.hasError) throw env.error; if (env.hasError) throw env.error;
} }
return next(); return next();
}; };
__rewriteRelativeImportExtension = function (path, preserveJsx) {
if (typeof path === "string" && /^\.\.?\//.test(path)) {
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
});
}
return path;
};
exporter("__extends", __extends); exporter("__extends", __extends);
exporter("__assign", __assign); exporter("__assign", __assign);
exporter("__rest", __rest); exporter("__rest", __rest);
@ -62612,8 +62639,11 @@ var __disposeResources;
exporter("__classPrivateFieldIn", __classPrivateFieldIn); exporter("__classPrivateFieldIn", __classPrivateFieldIn);
exporter("__addDisposableResource", __addDisposableResource); exporter("__addDisposableResource", __addDisposableResource);
exporter("__disposeResources", __disposeResources); exporter("__disposeResources", __disposeResources);
exporter("__rewriteRelativeImportExtension", __rewriteRelativeImportExtension);
}); });
0 && (0);
/***/ }), /***/ }),
@ -92538,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
@ -92843,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()
@ -92863,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;
@ -92890,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`:
@ -92897,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;
@ -92924,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`);
@ -93203,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]),
@ -93231,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) {
@ -93281,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})`);
@ -93297,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}` });

110
dist/run/index.js generated vendored
View File

@ -62206,7 +62206,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */ ***************************************************************************** */
/* global global, define, Symbol, Reflect, Promise, SuppressedError */ /* global global, define, Symbol, Reflect, Promise, SuppressedError, Iterator */
var __extends; var __extends;
var __assign; var __assign;
var __rest; var __rest;
@ -62238,6 +62238,7 @@ var __classPrivateFieldIn;
var __createBinding; var __createBinding;
var __addDisposableResource; var __addDisposableResource;
var __disposeResources; var __disposeResources;
var __rewriteRelativeImportExtension;
(function (factory) { (function (factory) {
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
if (typeof define === "function" && define.amd) { if (typeof define === "function" && define.amd) {
@ -62365,8 +62366,8 @@ var __disposeResources;
}; };
__generator = function (thisArg, body) { __generator = function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; } function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) { function step(op) {
if (f) throw new TypeError("Generator is already executing."); if (f) throw new TypeError("Generator is already executing.");
@ -62470,8 +62471,9 @@ var __disposeResources;
__asyncGenerator = function (thisArg, _arguments, generator) { __asyncGenerator = function (thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = []; var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); } function fulfill(value) { resume("next", value); }
@ -62504,10 +62506,19 @@ var __disposeResources;
o["default"] = v; o["default"] = v;
}; };
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
__importStar = function (mod) { __importStar = function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@ -62537,7 +62548,7 @@ var __disposeResources;
__addDisposableResource = function (env, value, async) { __addDisposableResource = function (env, value, async) {
if (value !== null && value !== void 0) { if (value !== null && value !== void 0) {
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
var dispose; var dispose, inner;
if (async) { if (async) {
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
dispose = value[Symbol.asyncDispose]; dispose = value[Symbol.asyncDispose];
@ -62545,8 +62556,10 @@ var __disposeResources;
if (dispose === void 0) { if (dispose === void 0) {
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
dispose = value[Symbol.dispose]; dispose = value[Symbol.dispose];
if (async) inner = dispose;
} }
if (typeof dispose !== "function") throw new TypeError("Object not disposable."); if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
env.stack.push({ value: value, dispose: dispose, async: async }); env.stack.push({ value: value, dispose: dispose, async: async });
} }
else if (async) { else if (async) {
@ -62565,22 +62578,36 @@ var __disposeResources;
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
env.hasError = true; env.hasError = true;
} }
var r, s = 0;
function next() { function next() {
while (env.stack.length) { while (r = env.stack.pop()) {
var rec = env.stack.pop();
try { try {
var result = rec.dispose && rec.dispose.call(rec.value); if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); if (r.dispose) {
var result = r.dispose.call(r.value);
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
}
else s |= 1;
} }
catch (e) { catch (e) {
fail(e); fail(e);
} }
} }
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
if (env.hasError) throw env.error; if (env.hasError) throw env.error;
} }
return next(); return next();
}; };
__rewriteRelativeImportExtension = function (path, preserveJsx) {
if (typeof path === "string" && /^\.\.?\//.test(path)) {
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
});
}
return path;
};
exporter("__extends", __extends); exporter("__extends", __extends);
exporter("__assign", __assign); exporter("__assign", __assign);
exporter("__rest", __rest); exporter("__rest", __rest);
@ -62612,8 +62639,11 @@ var __disposeResources;
exporter("__classPrivateFieldIn", __classPrivateFieldIn); exporter("__classPrivateFieldIn", __classPrivateFieldIn);
exporter("__addDisposableResource", __addDisposableResource); exporter("__addDisposableResource", __addDisposableResource);
exporter("__disposeResources", __disposeResources); exporter("__disposeResources", __disposeResources);
exporter("__rewriteRelativeImportExtension", __rewriteRelativeImportExtension);
}); });
0 && (0);
/***/ }), /***/ }),
@ -92538,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
@ -92843,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()
@ -92863,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;
@ -92890,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`:
@ -92897,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;
@ -92924,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`);
@ -93203,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]),
@ -93231,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) {
@ -93281,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})`);
@ -93297,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
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

128
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "golanci-lint-action", "name": "golanci-lint-action",
"version": "6.5.2", "version": "7.0.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "golanci-lint-action", "name": "golanci-lint-action",
"version": "6.5.2", "version": "7.0.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^4.0.2", "@actions/cache": "^4.0.2",
@ -24,13 +24,13 @@
"which": "^5.0.0" "which": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^8.26.1", "@typescript-eslint/eslint-plugin": "^8.27.0",
"@typescript-eslint/parser": "^8.26.1", "@typescript-eslint/parser": "^8.27.0",
"@vercel/ncc": "^0.38.3", "@vercel/ncc": "^0.38.3",
"eslint": "^8.57.1", "eslint": "^8.57.1",
"eslint-config-prettier": "^10.1.1", "eslint-config-prettier": "^10.1.1",
"eslint-plugin-import": "^2.31.0", "eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.3", "eslint-plugin-prettier": "^5.2.4",
"eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-simple-import-sort": "^12.1.1",
"prettier": "^3.5.3", "prettier": "^3.5.3",
"typescript": "^5.8.2" "typescript": "^5.8.2"
@ -634,10 +634,11 @@
} }
}, },
"node_modules/@pkgr/core": { "node_modules/@pkgr/core": {
"version": "0.1.1", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.2.0.tgz",
"integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==", "integrity": "sha512-vsJDAkYR6qCPu+ioGScGiMYR7LvZYIXh/dlQeviqoTWNCVfKTLYD/LkNWH4Mxsv2a5vpIRc77FN5DnmK1eBggQ==",
"dev": true, "dev": true,
"license": "MIT",
"engines": { "engines": {
"node": "^12.20.0 || ^14.18.0 || >=16.0.0" "node": "^12.20.0 || ^14.18.0 || >=16.0.0"
}, },
@ -789,17 +790,17 @@
"integrity": "sha512-liyfuo/106JdlgSchJzXEQCVArk0CvevqPote8F8HgWgJ3dRCcTHgJIsLDuee0kxk/mhbInzIZk3QWSZJ8R+2w==" "integrity": "sha512-liyfuo/106JdlgSchJzXEQCVArk0CvevqPote8F8HgWgJ3dRCcTHgJIsLDuee0kxk/mhbInzIZk3QWSZJ8R+2w=="
}, },
"node_modules/@typescript-eslint/eslint-plugin": { "node_modules/@typescript-eslint/eslint-plugin": {
"version": "8.26.1", "version": "8.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.26.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.27.0.tgz",
"integrity": "sha512-2X3mwqsj9Bd3Ciz508ZUtoQQYpOhU/kWoUqIf49H8Z0+Vbh6UF/y0OEYp0Q0axOGzaBGs7QxRwq0knSQ8khQNA==", "integrity": "sha512-4henw4zkePi5p252c8ncBLzLce52SEUz2Ebj8faDnuUXz2UuHEONYcJ+G0oaCF+bYCWVZtrGzq3FD7YXetmnSA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@eslint-community/regexpp": "^4.10.0", "@eslint-community/regexpp": "^4.10.0",
"@typescript-eslint/scope-manager": "8.26.1", "@typescript-eslint/scope-manager": "8.27.0",
"@typescript-eslint/type-utils": "8.26.1", "@typescript-eslint/type-utils": "8.27.0",
"@typescript-eslint/utils": "8.26.1", "@typescript-eslint/utils": "8.27.0",
"@typescript-eslint/visitor-keys": "8.26.1", "@typescript-eslint/visitor-keys": "8.27.0",
"graphemer": "^1.4.0", "graphemer": "^1.4.0",
"ignore": "^5.3.1", "ignore": "^5.3.1",
"natural-compare": "^1.4.0", "natural-compare": "^1.4.0",
@ -819,16 +820,16 @@
} }
}, },
"node_modules/@typescript-eslint/parser": { "node_modules/@typescript-eslint/parser": {
"version": "8.26.1", "version": "8.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.26.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.27.0.tgz",
"integrity": "sha512-w6HZUV4NWxqd8BdeFf81t07d7/YV9s7TCWrQQbG5uhuvGUAW+fq1usZ1Hmz9UPNLniFnD8GLSsDpjP0hm1S4lQ==", "integrity": "sha512-XGwIabPallYipmcOk45DpsBSgLC64A0yvdAkrwEzwZ2viqGqRUJ8eEYoPz0CWnutgAFbNMPdsGGvzjSmcWVlEA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/scope-manager": "8.26.1", "@typescript-eslint/scope-manager": "8.27.0",
"@typescript-eslint/types": "8.26.1", "@typescript-eslint/types": "8.27.0",
"@typescript-eslint/typescript-estree": "8.26.1", "@typescript-eslint/typescript-estree": "8.27.0",
"@typescript-eslint/visitor-keys": "8.26.1", "@typescript-eslint/visitor-keys": "8.27.0",
"debug": "^4.3.4" "debug": "^4.3.4"
}, },
"engines": { "engines": {
@ -844,14 +845,14 @@
} }
}, },
"node_modules/@typescript-eslint/scope-manager": { "node_modules/@typescript-eslint/scope-manager": {
"version": "8.26.1", "version": "8.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.26.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.27.0.tgz",
"integrity": "sha512-6EIvbE5cNER8sqBu6V7+KeMZIC1664d2Yjt+B9EWUXrsyWpxx4lEZrmvxgSKRC6gX+efDL/UY9OpPZ267io3mg==", "integrity": "sha512-8oI9GwPMQmBryaaxG1tOZdxXVeMDte6NyJA4i7/TWa4fBwgnAXYlIQP+uYOeqAaLJ2JRxlG9CAyL+C+YE9Xknw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/types": "8.26.1", "@typescript-eslint/types": "8.27.0",
"@typescript-eslint/visitor-keys": "8.26.1" "@typescript-eslint/visitor-keys": "8.27.0"
}, },
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@ -862,14 +863,14 @@
} }
}, },
"node_modules/@typescript-eslint/type-utils": { "node_modules/@typescript-eslint/type-utils": {
"version": "8.26.1", "version": "8.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.26.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.27.0.tgz",
"integrity": "sha512-Kcj/TagJLwoY/5w9JGEFV0dclQdyqw9+VMndxOJKtoFSjfZhLXhYjzsQEeyza03rwHx2vFEGvrJWJBXKleRvZg==", "integrity": "sha512-wVArTVcz1oJOIEJxui/nRhV0TXzD/zMSOYi/ggCfNq78EIszddXcJb7r4RCp/oBrjt8n9A0BSxRMKxHftpDxDA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/typescript-estree": "8.26.1", "@typescript-eslint/typescript-estree": "8.27.0",
"@typescript-eslint/utils": "8.26.1", "@typescript-eslint/utils": "8.27.0",
"debug": "^4.3.4", "debug": "^4.3.4",
"ts-api-utils": "^2.0.1" "ts-api-utils": "^2.0.1"
}, },
@ -886,9 +887,9 @@
} }
}, },
"node_modules/@typescript-eslint/types": { "node_modules/@typescript-eslint/types": {
"version": "8.26.1", "version": "8.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.26.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.27.0.tgz",
"integrity": "sha512-n4THUQW27VmQMx+3P+B0Yptl7ydfceUj4ON/AQILAASwgYdZ/2dhfymRMh5egRUrvK5lSmaOm77Ry+lmXPOgBQ==", "integrity": "sha512-/6cp9yL72yUHAYq9g6DsAU+vVfvQmd1a8KyA81uvfDE21O2DwQ/qxlM4AR8TSdAu+kJLBDrEHKC5/W2/nxsY0A==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
@ -900,14 +901,14 @@
} }
}, },
"node_modules/@typescript-eslint/typescript-estree": { "node_modules/@typescript-eslint/typescript-estree": {
"version": "8.26.1", "version": "8.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.26.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.27.0.tgz",
"integrity": "sha512-yUwPpUHDgdrv1QJ7YQal3cMVBGWfnuCdKbXw1yyjArax3353rEJP1ZA+4F8nOlQ3RfS2hUN/wze3nlY+ZOhvoA==", "integrity": "sha512-BnKq8cqPVoMw71O38a1tEb6iebEgGA80icSxW7g+kndx0o6ot6696HjG7NdgfuAVmVEtwXUr3L8R9ZuVjoQL6A==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/types": "8.26.1", "@typescript-eslint/types": "8.27.0",
"@typescript-eslint/visitor-keys": "8.26.1", "@typescript-eslint/visitor-keys": "8.27.0",
"debug": "^4.3.4", "debug": "^4.3.4",
"fast-glob": "^3.3.2", "fast-glob": "^3.3.2",
"is-glob": "^4.0.3", "is-glob": "^4.0.3",
@ -966,16 +967,16 @@
} }
}, },
"node_modules/@typescript-eslint/utils": { "node_modules/@typescript-eslint/utils": {
"version": "8.26.1", "version": "8.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.26.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.27.0.tgz",
"integrity": "sha512-V4Urxa/XtSUroUrnI7q6yUTD3hDtfJ2jzVfeT3VK0ciizfK2q/zGC0iDh1lFMUZR8cImRrep6/q0xd/1ZGPQpg==", "integrity": "sha512-njkodcwH1yvmo31YWgRHNb/x1Xhhq4/m81PhtvmRngD8iHPehxffz1SNCO+kwaePhATC+kOa/ggmvPoPza5i0Q==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.4.0", "@eslint-community/eslint-utils": "^4.4.0",
"@typescript-eslint/scope-manager": "8.26.1", "@typescript-eslint/scope-manager": "8.27.0",
"@typescript-eslint/types": "8.26.1", "@typescript-eslint/types": "8.27.0",
"@typescript-eslint/typescript-estree": "8.26.1" "@typescript-eslint/typescript-estree": "8.27.0"
}, },
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@ -990,13 +991,13 @@
} }
}, },
"node_modules/@typescript-eslint/visitor-keys": { "node_modules/@typescript-eslint/visitor-keys": {
"version": "8.26.1", "version": "8.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.26.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.27.0.tgz",
"integrity": "sha512-AjOC3zfnxd6S4Eiy3jwktJPclqhFHNyd8L6Gycf9WUPoKZpgM5PjkxY1X7uSy61xVpiJDhhk7XT2NVsN3ALTWg==", "integrity": "sha512-WsXQwMkILJvffP6z4U3FYJPlbf/j07HIxmDjZpbNvBJkMfvwXj5ACRkkHwBDvLBbDbtX5TdU64/rcvKJ/vuInQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/types": "8.26.1", "@typescript-eslint/types": "8.27.0",
"eslint-visitor-keys": "^4.2.0" "eslint-visitor-keys": "^4.2.0"
}, },
"engines": { "engines": {
@ -1844,13 +1845,14 @@
} }
}, },
"node_modules/eslint-plugin-prettier": { "node_modules/eslint-plugin-prettier": {
"version": "5.2.3", "version": "5.2.4",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.3.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.4.tgz",
"integrity": "sha512-qJ+y0FfCp/mQYQ/vWQ3s7eUlFEL4PyKfAJxsnYTJ4YT73nsJBWqmEpFryxV9OeUiqmsTsYJ5Y+KDNaeP31wrRw==", "integrity": "sha512-SFtuYmnhwYCtuCDTKPoK+CEzCnEgKTU2qTLwoCxvrC0MFBTIXo1i6hDYOI4cwHaE5GZtlWmTN3YfucYi7KJwPw==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"prettier-linter-helpers": "^1.0.0", "prettier-linter-helpers": "^1.0.0",
"synckit": "^0.9.1" "synckit": "^0.10.2"
}, },
"engines": { "engines": {
"node": "^14.18.0 || >=16.0.0" "node": "^14.18.0 || >=16.0.0"
@ -3477,13 +3479,14 @@
} }
}, },
"node_modules/synckit": { "node_modules/synckit": {
"version": "0.9.1", "version": "0.10.3",
"resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.1.tgz", "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.10.3.tgz",
"integrity": "sha512-7gr8p9TQP6RAHusBOSLs46F4564ZrjV8xFmw5zCmgmhGUcw2hxsShhJ6CEiHQMgPDwAQ1fWHPM0ypc4RMAig4A==", "integrity": "sha512-R1urvuyiTaWfeCggqEvpDJwAlDVdsT9NM+IP//Tk2x7qHCkSvBk/fwFgw/TLAHzZlrAnnazMcRw0ZD8HlYFTEQ==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"@pkgr/core": "^0.1.0", "@pkgr/core": "^0.2.0",
"tslib": "^2.6.2" "tslib": "^2.8.1"
}, },
"engines": { "engines": {
"node": "^14.18.0 || >=16.0.0" "node": "^14.18.0 || >=16.0.0"
@ -3549,9 +3552,10 @@
} }
}, },
"node_modules/tslib": { "node_modules/tslib": {
"version": "2.6.2", "version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"license": "0BSD"
}, },
"node_modules/tunnel": { "node_modules/tunnel": {
"version": "0.0.6", "version": "0.0.6",

View File

@ -1,6 +1,6 @@
{ {
"name": "golanci-lint-action", "name": "golanci-lint-action",
"version": "6.5.2", "version": "7.0.0",
"private": true, "private": true,
"description": "golangci-lint github action", "description": "golangci-lint github action",
"main": "dist/main.js", "main": "dist/main.js",
@ -39,13 +39,13 @@
"which": "^5.0.0" "which": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^8.26.1", "@typescript-eslint/eslint-plugin": "^8.27.0",
"@typescript-eslint/parser": "^8.26.1", "@typescript-eslint/parser": "^8.27.0",
"@vercel/ncc": "^0.38.3", "@vercel/ncc": "^0.38.3",
"eslint": "^8.57.1", "eslint": "^8.57.1",
"eslint-config-prettier": "^10.1.1", "eslint-config-prettier": "^10.1.1",
"eslint-plugin-import": "^2.31.0", "eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.3", "eslint-plugin-prettier": "^5.2.4",
"eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-simple-import-sort": "^12.1.1",
"prettier": "^3.5.3", "prettier": "^3.5.3",
"typescript": "^5.8.2" "typescript": "^5.8.2"

View File

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

View 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

View File

@ -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"
) )

View File

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

View 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

View File

@ -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)

View File

@ -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) {

View File

@ -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}` })