Compare commits

..

15 Commits

Author SHA1 Message Date
Fernandez Ludovic
2e788936b0 6.3.1 2025-02-09 02:26:54 +01:00
Ludovic Fernandez
aa1e0941ed chore: update golangci-lint versions (#1159) 2025-02-09 02:22:47 +01:00
Ludovic Fernandez
3e6beafdff fix: restrict patched version to v1 (#1158) 2025-02-09 02:03:24 +01:00
dependabot[bot]
1cc4e007f0 build(deps): bump @types/node from 22.13.0 to 22.13.1 in the dependencies group (#1156) 2025-02-04 16:56:20 +01:00
dependabot[bot]
bbe109d3f8 build(deps-dev): bump the dev-dependencies group with 2 updates (#1155) 2025-02-04 16:55:56 +01:00
Fernandez Ludovic
e60da84bfa chore: update branch references 2025-02-04 15:39:52 +01:00
Ludovic Fernandez
1dd93d052e chore: use new assets file (#1154) 2025-02-04 15:15:08 +01:00
dependabot[bot]
5421a116d2 build(deps): bump @types/node from 22.10.10 to 22.13.0 in the dependencies group (#1153) 2025-02-03 12:48:00 +01:00
dependabot[bot]
260e8cefdb build(deps-dev): bump the dev-dependencies group with 2 updates (#1152) 2025-02-03 12:47:31 +01:00
dependabot[bot]
9665fb5353 build(deps): bump undici from 5.28.4 to 5.28.5 (#1150)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2025-01-27 12:12:42 +00:00
dependabot[bot]
62530743f6 build(deps): bump @types/node from 22.10.7 to 22.10.10 in the dependencies group (#1149) 2025-01-27 12:43:58 +01:00
dependabot[bot]
f71f362e47 build(deps-dev): bump the dev-dependencies group with 2 updates (#1148) 2025-01-27 12:43:11 +01:00
dependabot[bot]
7ec71f69b1 build(deps): bump the dependencies group with 2 updates (#1147)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2025-01-20 18:21:27 +01:00
dependabot[bot]
60c0fc4730 build(deps-dev): bump the dev-dependencies group with 4 updates (#1146) 2025-01-20 16:19:41 +01:00
Kotaro Otaka
a7b658d295 docs: update README options version from required to optional (#1145) 2025-01-17 12:24:51 +01:00
11 changed files with 454 additions and 566 deletions

View File

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

View File

@@ -1,9 +1,13 @@
name: "build-and-test" name: "build-and-test"
on: # rebuild any PRs and main branch changes on: # rebuild any PRs and main branch changes
pull_request: pull_request:
branches:
- master
- main
push: push:
branches: branches:
- master - master
- main
- "releases/*" - "releases/*"
jobs: jobs:
@@ -53,8 +57,8 @@ jobs:
version: version:
- "" - ""
- "latest" - "latest"
- "v1.60" - "v1.63" # TODO(ldez): it should be updated for v2.
- "v1.60.1" - "v1.63.4" # TODO(ldez): it should be updated for v2.
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
permissions: permissions:
contents: read contents: read
@@ -82,8 +86,8 @@ jobs:
version: version:
- "" - ""
- "latest" - "latest"
- "v1.60.1" - "v1.63.4" # TODO(ldez): it should be updated for v2.
- "adbdfdb288e939a175182b7a12b7555215ce98b2" - "95c39ac1fbaf66475705c06c16259ffd9d6bf9a2" # TODO(ldez): it should be updated for v2.
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
permissions: permissions:
contents: read contents: read

2
.gitignore vendored
View File

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

View File

@@ -115,8 +115,8 @@ on:
pull_request: pull_request:
push: push:
branches: branches:
- "main" - main
- "master" - master
env: env:
GO_VERSION: stable GO_VERSION: stable
@@ -166,8 +166,8 @@ on:
pull_request: pull_request:
push: push:
branches: branches:
- "main" - main
- "master" - master
jobs: jobs:
golangci-lint: golangci-lint:
@@ -257,7 +257,7 @@ You will also likely need to add the following `.gitattributes` file to ensure t
### `version` ### `version`
(required) (optional)
The version of golangci-lint to use. The version of golangci-lint to use.
@@ -498,7 +498,7 @@ permissions:
The action was implemented with performance in mind: The action was implemented with performance in mind:
1. We cache data from golangci-lint analysis between builds by using [@actions/cache](https://github.com/actions/toolkit/tree/master/packages/cache). 1. We cache data from golangci-lint analysis between builds by using [@actions/cache](https://github.com/actions/toolkit/tree/HEAD/packages/cache).
2. We don't use Docker because image pulling is slow. 2. We don't use Docker because image pulling is slow.
3. We do as much as we can in parallel, e.g. we download cache, and golangci-lint binary in parallel. 3. We do as much as we can in parallel, e.g. we download cache, and golangci-lint binary in parallel.
@@ -514,7 +514,7 @@ We use JavaScript-based action.
We don't use Docker-based action because: We don't use Docker-based action because:
1. Docker pulling is slow currently 1. Docker pulling is slow currently
2. it's easier to use caching from [@actions/cache](https://github.com/actions/toolkit/tree/master/packages/cache) 2. it's easier to use caching from [@actions/cache](https://github.com/actions/toolkit/tree/HEAD/packages/cache)
We support different platforms, such as `ubuntu`, `macos`, and `windows` with `x32` and `x64` archs. We support different platforms, such as `ubuntu`, `macos`, and `windows` with `x32` and `x64` archs.
@@ -522,9 +522,9 @@ Inside our action, we perform 3 steps:
1. Setup environment running in parallel: 1. Setup environment running in parallel:
* restore [cache](https://github.com/actions/cache) of previous analyses * restore [cache](https://github.com/actions/cache) of previous analyses
* fetch [action config](https://github.com/golangci/golangci-lint/blob/master/assets/github-action-config.json) and find the latest `golangci-lint` patch version for needed version * fetch [action config](https://github.com/golangci/golangci-lint/blob/HEAD/assets/github-action-config.json) and find the latest `golangci-lint` patch version for needed version
(users of this action can specify only minor version of `golangci-lint`). (users of this action can specify only minor version of `golangci-lint`).
After that install [golangci-lint](https://github.com/golangci/golangci-lint) using [@actions/tool-cache](https://github.com/actions/toolkit/tree/master/packages/tool-cache) After that install [golangci-lint](https://github.com/golangci/golangci-lint) using [@actions/tool-cache](https://github.com/actions/toolkit/tree/HEAD/packages/tool-cache)
2. Run `golangci-lint` with specified by user `args` 2. Run `golangci-lint` with specified by user `args`
3. Save cache for later builds 3. Save cache for later builds

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

@@ -8662,7 +8662,11 @@ function copyFile(srcFile, destFile, force) {
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -8675,7 +8679,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -8705,11 +8709,11 @@ function _findMatch(versionSpec, stable, candidates, archFilter) {
let file; let file;
for (const candidate of candidates) { for (const candidate of candidates) {
const version = candidate.version; const version = candidate.version;
core_1.debug(`check ${version} satisfies ${versionSpec}`); (0, core_1.debug)(`check ${version} satisfies ${versionSpec}`);
if (semver.satisfies(version, versionSpec) && if (semver.satisfies(version, versionSpec) &&
(!stable || candidate.stable === stable)) { (!stable || candidate.stable === stable)) {
file = candidate.files.find(item => { file = candidate.files.find(item => {
core_1.debug(`${item.arch}===${archFilter} && ${item.platform}===${platFilter}`); (0, core_1.debug)(`${item.arch}===${archFilter} && ${item.platform}===${platFilter}`);
let chk = item.arch === archFilter && item.platform === platFilter; let chk = item.arch === archFilter && item.platform === platFilter;
if (chk && item.platform_version) { if (chk && item.platform_version) {
const osVersion = module.exports._getOsVersion(); const osVersion = module.exports._getOsVersion();
@@ -8723,7 +8727,7 @@ function _findMatch(versionSpec, stable, candidates, archFilter) {
return chk; return chk;
}); });
if (file) { if (file) {
core_1.debug(`matched ${candidate.version}`); (0, core_1.debug)(`matched ${candidate.version}`);
match = candidate; match = candidate;
break; break;
} }
@@ -8761,10 +8765,7 @@ function _getOsVersion() {
if (parts.length === 2 && if (parts.length === 2 &&
(parts[0].trim() === 'VERSION_ID' || (parts[0].trim() === 'VERSION_ID' ||
parts[0].trim() === 'DISTRIB_RELEASE')) { parts[0].trim() === 'DISTRIB_RELEASE')) {
version = parts[1] version = parts[1].trim().replace(/^"/, '').replace(/"$/, '');
.trim()
.replace(/^"/, '')
.replace(/"$/, '');
break; break;
} }
} }
@@ -8797,7 +8798,11 @@ exports._readLinuxVersionFile = _readLinuxVersionFile;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -8810,7 +8815,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -8887,7 +8892,11 @@ exports.RetryHelper = RetryHelper;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -8900,7 +8909,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -8913,13 +8922,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.evaluateVersions = exports.isExplicitVersion = exports.findFromManifest = exports.getManifestFromRepo = exports.findAllVersions = exports.find = exports.cacheFile = exports.cacheDir = exports.extractZip = exports.extractXar = exports.extractTar = exports.extract7z = exports.downloadTool = exports.HTTPError = void 0; exports.evaluateVersions = exports.isExplicitVersion = exports.findFromManifest = exports.getManifestFromRepo = exports.findAllVersions = exports.find = exports.cacheFile = exports.cacheDir = exports.extractZip = exports.extractXar = exports.extractTar = exports.extract7z = exports.downloadTool = exports.HTTPError = void 0;
const core = __importStar(__nccwpck_require__(7484)); const core = __importStar(__nccwpck_require__(7484));
const io = __importStar(__nccwpck_require__(4994)); const io = __importStar(__nccwpck_require__(4994));
const crypto = __importStar(__nccwpck_require__(6982));
const fs = __importStar(__nccwpck_require__(9896)); const fs = __importStar(__nccwpck_require__(9896));
const mm = __importStar(__nccwpck_require__(8036)); const mm = __importStar(__nccwpck_require__(8036));
const os = __importStar(__nccwpck_require__(857)); const os = __importStar(__nccwpck_require__(857));
@@ -8929,7 +8936,6 @@ const semver = __importStar(__nccwpck_require__(9318));
const stream = __importStar(__nccwpck_require__(2203)); const stream = __importStar(__nccwpck_require__(2203));
const util = __importStar(__nccwpck_require__(9023)); const util = __importStar(__nccwpck_require__(9023));
const assert_1 = __nccwpck_require__(2613); const assert_1 = __nccwpck_require__(2613);
const v4_1 = __importDefault(__nccwpck_require__(9021));
const exec_1 = __nccwpck_require__(5236); const exec_1 = __nccwpck_require__(5236);
const retry_helper_1 = __nccwpck_require__(7380); const retry_helper_1 = __nccwpck_require__(7380);
class HTTPError extends Error { class HTTPError extends Error {
@@ -8954,7 +8960,7 @@ const userAgent = 'actions/tool-cache';
*/ */
function downloadTool(url, dest, auth, headers) { function downloadTool(url, dest, auth, headers) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
dest = dest || path.join(_getTempDirectory(), v4_1.default()); dest = dest || path.join(_getTempDirectory(), crypto.randomUUID());
yield io.mkdirP(path.dirname(dest)); yield io.mkdirP(path.dirname(dest));
core.debug(`Downloading ${url}`); core.debug(`Downloading ${url}`);
core.debug(`Destination ${dest}`); core.debug(`Destination ${dest}`);
@@ -9043,8 +9049,8 @@ function downloadToolAttempt(url, dest, auth, headers) {
*/ */
function extract7z(file, dest, _7zPath) { function extract7z(file, dest, _7zPath) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS'); (0, assert_1.ok)(IS_WINDOWS, 'extract7z() not supported on current OS');
assert_1.ok(file, 'parameter "file" is required'); (0, assert_1.ok)(file, 'parameter "file" is required');
dest = yield _createExtractFolder(dest); dest = yield _createExtractFolder(dest);
const originalCwd = process.cwd(); const originalCwd = process.cwd();
process.chdir(dest); process.chdir(dest);
@@ -9061,7 +9067,7 @@ function extract7z(file, dest, _7zPath) {
const options = { const options = {
silent: true silent: true
}; };
yield exec_1.exec(`"${_7zPath}"`, args, options); yield (0, exec_1.exec)(`"${_7zPath}"`, args, options);
} }
finally { finally {
process.chdir(originalCwd); process.chdir(originalCwd);
@@ -9090,7 +9096,7 @@ function extract7z(file, dest, _7zPath) {
}; };
try { try {
const powershellPath = yield io.which('powershell', true); const powershellPath = yield io.which('powershell', true);
yield exec_1.exec(`"${powershellPath}"`, args, options); yield (0, exec_1.exec)(`"${powershellPath}"`, args, options);
} }
finally { finally {
process.chdir(originalCwd); process.chdir(originalCwd);
@@ -9118,7 +9124,7 @@ function extractTar(file, dest, flags = 'xz') {
// Determine whether GNU tar // Determine whether GNU tar
core.debug('Checking tar --version'); core.debug('Checking tar --version');
let versionOutput = ''; let versionOutput = '';
yield exec_1.exec('tar --version', [], { yield (0, exec_1.exec)('tar --version', [], {
ignoreReturnCode: true, ignoreReturnCode: true,
silent: true, silent: true,
listeners: { listeners: {
@@ -9154,7 +9160,7 @@ function extractTar(file, dest, flags = 'xz') {
args.push('--overwrite'); args.push('--overwrite');
} }
args.push('-C', destArg, '-f', fileArg); args.push('-C', destArg, '-f', fileArg);
yield exec_1.exec(`tar`, args); yield (0, exec_1.exec)(`tar`, args);
return dest; return dest;
}); });
} }
@@ -9169,8 +9175,8 @@ exports.extractTar = extractTar;
*/ */
function extractXar(file, dest, flags = []) { function extractXar(file, dest, flags = []) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
assert_1.ok(IS_MAC, 'extractXar() not supported on current OS'); (0, assert_1.ok)(IS_MAC, 'extractXar() not supported on current OS');
assert_1.ok(file, 'parameter "file" is required'); (0, assert_1.ok)(file, 'parameter "file" is required');
dest = yield _createExtractFolder(dest); dest = yield _createExtractFolder(dest);
let args; let args;
if (flags instanceof Array) { if (flags instanceof Array) {
@@ -9184,7 +9190,7 @@ function extractXar(file, dest, flags = []) {
args.push('-v'); args.push('-v');
} }
const xarPath = yield io.which('xar', true); const xarPath = yield io.which('xar', true);
yield exec_1.exec(`"${xarPath}"`, _unique(args)); yield (0, exec_1.exec)(`"${xarPath}"`, _unique(args));
return dest; return dest;
}); });
} }
@@ -9238,7 +9244,7 @@ function extractZipWin(file, dest) {
pwshCommand pwshCommand
]; ];
core.debug(`Using pwsh at path: ${pwshPath}`); core.debug(`Using pwsh at path: ${pwshPath}`);
yield exec_1.exec(`"${pwshPath}"`, args); yield (0, exec_1.exec)(`"${pwshPath}"`, args);
} }
else { else {
const powershellCommand = [ const powershellCommand = [
@@ -9259,7 +9265,7 @@ function extractZipWin(file, dest) {
]; ];
const powershellPath = yield io.which('powershell', true); const powershellPath = yield io.which('powershell', true);
core.debug(`Using powershell at path: ${powershellPath}`); core.debug(`Using powershell at path: ${powershellPath}`);
yield exec_1.exec(`"${powershellPath}"`, args); yield (0, exec_1.exec)(`"${powershellPath}"`, args);
} }
}); });
} }
@@ -9271,7 +9277,7 @@ function extractZipNix(file, dest) {
args.unshift('-q'); args.unshift('-q');
} }
args.unshift('-o'); //overwrite with -o, otherwise a prompt is shown which freezes the run args.unshift('-o'); //overwrite with -o, otherwise a prompt is shown which freezes the run
yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest }); yield (0, exec_1.exec)(`"${unzipPath}"`, args, { cwd: dest });
}); });
} }
/** /**
@@ -9448,7 +9454,7 @@ function _createExtractFolder(dest) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (!dest) { if (!dest) {
// create a temp dir // create a temp dir
dest = path.join(_getTempDirectory(), v4_1.default()); dest = path.join(_getTempDirectory(), crypto.randomUUID());
} }
yield io.mkdirP(dest); yield io.mkdirP(dest);
return dest; return dest;
@@ -9521,7 +9527,7 @@ exports.evaluateVersions = evaluateVersions;
*/ */
function _getCacheDirectory() { function _getCacheDirectory() {
const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || ''; const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || '';
assert_1.ok(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined'); (0, assert_1.ok)(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined');
return cacheDirectory; return cacheDirectory;
} }
/** /**
@@ -9529,7 +9535,7 @@ function _getCacheDirectory() {
*/ */
function _getTempDirectory() { function _getTempDirectory() {
const tempDirectory = process.env['RUNNER_TEMP'] || ''; const tempDirectory = process.env['RUNNER_TEMP'] || '';
assert_1.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined'); (0, assert_1.ok)(tempDirectory, 'Expected RUNNER_TEMP to be defined');
return tempDirectory; return tempDirectory;
} }
/** /**
@@ -72162,6 +72168,14 @@ const { isUint8Array, isArrayBuffer } = __nccwpck_require__(8253)
const { File: UndiciFile } = __nccwpck_require__(3041) const { File: UndiciFile } = __nccwpck_require__(3041)
const { parseMIMEType, serializeAMimeType } = __nccwpck_require__(4322) const { parseMIMEType, serializeAMimeType } = __nccwpck_require__(4322)
let random
try {
const crypto = __nccwpck_require__(7598)
random = (max) => crypto.randomInt(0, max)
} catch {
random = (max) => Math.floor(Math.random(max))
}
let ReadableStream = globalThis.ReadableStream let ReadableStream = globalThis.ReadableStream
/** @type {globalThis['File']} */ /** @type {globalThis['File']} */
@@ -72247,7 +72261,7 @@ function extractBody (object, keepalive = false) {
// Set source to a copy of the bytes held by object. // Set source to a copy of the bytes held by object.
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength)) source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
} else if (util.isFormDataLike(object)) { } else if (util.isFormDataLike(object)) {
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, '0')}` const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, '0')}`
const prefix = `--${boundary}\r\nContent-Disposition: form-data` const prefix = `--${boundary}\r\nContent-Disposition: form-data`
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */ /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
@@ -86286,90 +86300,6 @@ exports.getUserAgent = getUserAgent;
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map
/***/ }),
/***/ 8682:
/***/ ((module) => {
/**
* Convert array of 16 byte values to UUID string format of the form:
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
*/
var byteToHex = [];
for (var i = 0; i < 256; ++i) {
byteToHex[i] = (i + 0x100).toString(16).substr(1);
}
function bytesToUuid(buf, offset) {
var i = offset || 0;
var bth = byteToHex;
// join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
return ([
bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]]
]).join('');
}
module.exports = bytesToUuid;
/***/ }),
/***/ 1694:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
// Unique ID creation requires a high quality random # generator. In node.js
// this is pretty straight-forward - we use the crypto API.
var crypto = __nccwpck_require__(6982);
module.exports = function nodeRNG() {
return crypto.randomBytes(16);
};
/***/ }),
/***/ 9021:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
var rng = __nccwpck_require__(1694);
var bytesToUuid = __nccwpck_require__(8682);
function v4(options, buf, offset) {
var i = buf && offset || 0;
if (typeof(options) == 'string') {
buf = options === 'binary' ? new Array(16) : null;
options = null;
}
options = options || {};
var rnds = options.random || (options.rng || rng)();
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
rnds[6] = (rnds[6] & 0x0f) | 0x40;
rnds[8] = (rnds[8] & 0x3f) | 0x80;
// Copy bytes to buffer, if provided
if (buf) {
for (var ii = 0; ii < 16; ++ii) {
buf[i + ii] = rnds[ii];
}
}
return buf || bytesToUuid(rnds);
}
module.exports = v4;
/***/ }), /***/ }),
/***/ 7125: /***/ 7125:
@@ -93759,8 +93689,7 @@ const os_1 = __importDefault(__nccwpck_require__(857));
const path_1 = __importDefault(__nccwpck_require__(6928)); const path_1 = __importDefault(__nccwpck_require__(6928));
const util_1 = __nccwpck_require__(9023); const util_1 = __nccwpck_require__(9023);
const execShellCommand = (0, util_1.promisify)(child_process_1.exec); const execShellCommand = (0, util_1.promisify)(child_process_1.exec);
const downloadURL = "https://github.com/golangci/golangci-lint/releases/download"; const getAssetURL = (versionInfo) => {
const getAssetURL = (versionConfig) => {
let ext = "tar.gz"; let ext = "tar.gz";
let platform = os_1.default.platform().toString(); let platform = os_1.default.platform().toString();
switch (platform) { switch (platform) {
@@ -93782,8 +93711,8 @@ const getAssetURL = (versionConfig) => {
arch = "386"; arch = "386";
break; break;
} }
const noPrefix = versionConfig.TargetVersion.slice(1); const noPrefix = versionInfo.TargetVersion.slice(1);
return `${downloadURL}/${versionConfig.TargetVersion}/golangci-lint-${noPrefix}-${platform}-${arch}.${ext}`; return `https://github.com/golangci/golangci-lint/releases/download/${versionInfo.TargetVersion}/golangci-lint-${noPrefix}-${platform}-${arch}.${ext}`;
}; };
var InstallMode; var InstallMode;
(function (InstallMode) { (function (InstallMode) {
@@ -93802,55 +93731,57 @@ const printOutput = (res) => {
/** /**
* Install golangci-lint. * Install golangci-lint.
* *
* @param versionConfig information about version to install. * @param versionInfo information about version to install.
* @param mode installation mode. * @param mode installation mode.
* @returns path to installed binary of golangci-lint. * @returns path to installed binary of golangci-lint.
*/ */
async function installLint(versionConfig, mode) { async function installLint(versionInfo, mode) {
core.info(`Installation mode: ${mode}`); core.info(`Installation mode: ${mode}`);
switch (mode) { switch (mode) {
case InstallMode.Binary: case InstallMode.Binary:
return installBin(versionConfig); return installBin(versionInfo);
case InstallMode.GoInstall: case InstallMode.GoInstall:
return goInstall(versionConfig); return goInstall(versionInfo);
default: default:
return installBin(versionConfig); return installBin(versionInfo);
} }
} }
/** /**
* Install golangci-lint via `go install`. * Install golangci-lint via `go install`.
* *
* @param versionConfig information about version to install. * @param versionInfo information about version to install.
* @returns path to installed binary of golangci-lint. * @returns path to installed binary of golangci-lint.
*/ */
async function goInstall(versionConfig) { async function goInstall(versionInfo) {
core.info(`Installing golangci-lint ${versionConfig.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" } };
const exres = await execShellCommand(`go install github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`, options); // TODO(ldez): it should be updated for v2.
const exres = await execShellCommand(`go install github.com/golangci/golangci-lint/cmd/golangci-lint@${versionInfo.TargetVersion}`, options);
printOutput(exres); printOutput(exres);
const res = await execShellCommand(`go install -n github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`, options); // TODO(ldez): it should be updated for v2.
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 lintPath = res.stderr const binPath = res.stderr
.split(/\r?\n/) .split(/\r?\n/)
.map((v) => v.trimStart().trimEnd()) .map((v) => v.trimStart().trimEnd())
.filter((v) => v.startsWith("touch ")) .filter((v) => v.startsWith("touch "))
.reduce((a, b) => a + b, "") .reduce((a, b) => a + b, "")
.split(` `, 2)[1]; .split(` `, 2)[1];
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`); core.info(`Installed golangci-lint into ${binPath} in ${Date.now() - startedAt}ms`);
return lintPath; return binPath;
} }
/** /**
* Install golangci-lint via the precompiled binary. * Install golangci-lint via the precompiled binary.
* *
* @param versionConfig information about version to install. * @param versionInfo information about version to install.
* @returns path to installed binary of golangci-lint. * @returns path to installed binary of golangci-lint.
*/ */
async function installBin(versionConfig) { async function installBin(versionInfo) {
core.info(`Installing golangci-lint binary ${versionConfig.TargetVersion}...`); core.info(`Installing golangci-lint binary ${versionInfo.TargetVersion}...`);
const startedAt = Date.now(); const startedAt = Date.now();
const assetURL = getAssetURL(versionConfig); const assetURL = getAssetURL(versionInfo);
core.info(`Downloading binary ${assetURL} ...`); core.info(`Downloading binary ${assetURL} ...`);
const archivePath = await tc.downloadTool(assetURL); const archivePath = await tc.downloadTool(assetURL);
let extractedDir = ""; let extractedDir = "";
@@ -93869,9 +93800,9 @@ async function installBin(versionConfig) {
} }
const urlParts = assetURL.split(`/`); const urlParts = assetURL.split(`/`);
const dirName = urlParts[urlParts.length - 1].replace(repl, ``); const dirName = urlParts[urlParts.length - 1].replace(repl, ``);
const lintPath = path_1.default.join(extractedDir, dirName, `golangci-lint`); const binPath = path_1.default.join(extractedDir, dirName, `golangci-lint`);
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`); core.info(`Installed golangci-lint into ${binPath} in ${Date.now() - startedAt}ms`);
return lintPath; return binPath;
} }
@@ -93942,14 +93873,14 @@ function isOnlyNewIssues() {
async function prepareLint() { async function prepareLint() {
const mode = core.getInput("install-mode").toLowerCase(); const mode = core.getInput("install-mode").toLowerCase();
if (mode === install_1.InstallMode.None) { if (mode === install_1.InstallMode.None) {
const bin = await (0, which_1.default)("golangci-lint", { nothrow: true }); const binPath = await (0, which_1.default)("golangci-lint", { nothrow: true });
if (!bin) { if (!binPath) {
throw new Error("golangci-lint binary not found in the PATH"); throw new Error("golangci-lint binary not found in the PATH");
} }
return bin; return binPath;
} }
const versionConfig = await (0, version_1.findLintVersion)(mode); const versionInfo = await (0, version_1.getVersion)(mode);
return await (0, install_1.installLint)(versionConfig, mode); return await (0, install_1.installLint)(versionInfo, mode);
} }
async function fetchPatch() { async function fetchPatch() {
if (!isOnlyNewIssues()) { if (!isOnlyNewIssues()) {
@@ -94048,10 +93979,10 @@ async function prepareEnv() {
const startedAt = Date.now(); const startedAt = Date.now();
// Prepare cache, lint and go in parallel. // Prepare cache, lint and go in parallel.
await (0, cache_1.restoreCache)(); await (0, cache_1.restoreCache)();
const lintPath = await prepareLint(); const binPath = await prepareLint();
const patchPath = await fetchPatch(); const patchPath = await fetchPatch();
core.info(`Prepared env in ${Date.now() - startedAt}ms`); core.info(`Prepared env in ${Date.now() - startedAt}ms`);
return { lintPath, patchPath }; return { binPath: binPath, patchPath };
} }
const printOutput = (res) => { const printOutput = (res) => {
if (res.stdout) { if (res.stdout) {
@@ -94160,9 +94091,9 @@ async function runLint(lintPath, patchPath) {
} }
async function run() { async function run() {
try { try {
const { lintPath, patchPath } = await core.group(`prepare environment`, prepareEnv); const { binPath, patchPath } = await core.group(`prepare environment`, prepareEnv);
core.addPath(path.dirname(lintPath)); core.addPath(path.dirname(binPath));
await core.group(`run golangci-lint`, () => runLint(lintPath, patchPath)); await core.group(`run golangci-lint`, () => runLint(binPath, patchPath));
} }
catch (error) { catch (error) {
core.error(`Failed to run: ${error}, ${error.stack}`); core.error(`Failed to run: ${error}, ${error.stack}`);
@@ -94388,17 +94319,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.stringifyVersion = void 0; exports.stringifyVersion = void 0;
exports.findLintVersion = findLintVersion; exports.getVersion = getVersion;
const core = __importStar(__nccwpck_require__(7484)); const core = __importStar(__nccwpck_require__(7484));
const httpm = __importStar(__nccwpck_require__(4844)); const httpm = __importStar(__nccwpck_require__(4844));
const fs = __importStar(__nccwpck_require__(9896)); const fs = __importStar(__nccwpck_require__(9896));
const os_1 = __importDefault(__nccwpck_require__(857));
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\s(v.+)/; const modVersionRe = /github.com\/golangci\/golangci-lint\s(v.+)/;
const parseVersion = (s) => { const parseVersion = (s) => {
if (s == "latest" || s == "") { if (s == "latest" || s == "") {
// TODO(ldez): it should be replaced with an explicit version (ex: v1.64.0)
return null; return null;
} }
const match = s.match(versionRe); const match = s.match(versionRe);
@@ -94418,6 +94350,7 @@ 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: 1,
minor: 28, minor: 28,
@@ -94437,37 +94370,38 @@ const isLessVersion = (a, b) => {
// then it returns false, since the patch version of requested is always zero // then it returns false, since the patch version of requested is always zero
return a.minor < b.minor; return a.minor < b.minor;
}; };
const getRequestedLintVersion = () => { const getRequestedVersion = () => {
let requestedLintVersion = core.getInput(`version`); let requestedVersion = core.getInput(`version`);
const workingDirectory = core.getInput(`working-directory`); const workingDirectory = core.getInput(`working-directory`);
let goMod = "go.mod"; let goMod = "go.mod";
if (workingDirectory) { if (workingDirectory) {
goMod = path_1.default.join(workingDirectory, goMod); goMod = path_1.default.join(workingDirectory, goMod);
} }
if (requestedLintVersion == "" && fs.existsSync(goMod)) { if (requestedVersion == "" && fs.existsSync(goMod)) {
const content = fs.readFileSync(goMod, "utf-8"); const content = fs.readFileSync(goMod, "utf-8");
const match = content.match(modVersionRe); const match = content.match(modVersionRe);
if (match) { if (match) {
requestedLintVersion = match[1]; requestedVersion = match[1];
core.info(`Found golangci-lint version '${requestedLintVersion}' in '${goMod}' file`); core.info(`Found golangci-lint version '${requestedVersion}' in '${goMod}' file`);
} }
} }
const parsedRequestedLintVersion = parseVersion(requestedLintVersion); const parsedRequestedVersion = parseVersion(requestedVersion);
if (parsedRequestedLintVersion == null) { if (parsedRequestedVersion == null) {
return null; return null;
} }
if (isLessVersion(parsedRequestedLintVersion, minVersion)) { if (isLessVersion(parsedRequestedVersion, minVersion)) {
throw new Error(`requested golangci-lint version '${requestedLintVersion}' isn't supported: we support only ${(0, exports.stringifyVersion)(minVersion)} and later versions`); throw new Error(`requested golangci-lint version '${requestedVersion}' isn't supported: we support only ${(0, exports.stringifyVersion)(minVersion)} and later versions`);
} }
return parsedRequestedLintVersion; return parsedRequestedVersion;
}; };
const getConfig = async () => { const fetchVersionMapping = async () => {
const http = new httpm.HttpClient(`golangci/golangci-lint-action`, [], { const http = new httpm.HttpClient(`golangci/golangci-lint-action`, [], {
allowRetries: true, allowRetries: true,
maxRetries: 5, maxRetries: 5,
}); });
try { try {
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/master/assets/github-action-config.json`; // TODO(ldez): HEAD should be replaced with an explicit version (ex: v1.64.0).
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v1.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})`);
@@ -94479,42 +94413,37 @@ const getConfig = async () => {
throw new Error(`failed to get action config: ${exc.message}`); throw new Error(`failed to get action config: ${exc.message}`);
} }
}; };
async function findLintVersion(mode) { 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`);
return { TargetVersion: v ? v : "latest", AssetURL: "github.com/golangci/golangci-lint" }; // TODO(ldez): latest should be replaced with an explicit version (ex: v1.64.0).
return { TargetVersion: v ? v : "latest" };
} }
const reqLintVersion = getRequestedLintVersion(); const reqVersion = getRequestedVersion();
// if the patched version is passed, just use it // if the patched version is passed, just use it
if (reqLintVersion?.major !== null && reqLintVersion?.minor != null && reqLintVersion?.patch !== null) { // TODO(ldez): should be updated to `reqVersion?.major === 2`.
if (reqVersion?.major === 1 && reqVersion?.minor != null && reqVersion?.patch !== null) {
return new Promise((resolve) => { return new Promise((resolve) => {
let arch = "amd64"; const versionWithoutV = `${reqVersion.major}.${reqVersion.minor}.${reqVersion.patch}`;
if (os_1.default.arch() === "arm64") { resolve({ TargetVersion: `v${versionWithoutV}` });
arch = "arm64";
}
const versionWithoutV = `${reqLintVersion.major}.${reqLintVersion.minor}.${reqLintVersion.patch}`;
resolve({
TargetVersion: `v${versionWithoutV}`,
AssetURL: `https://github.com/golangci/golangci-lint/releases/download/v${versionWithoutV}/golangci-lint-${versionWithoutV}-linux-${arch}.tar.gz`,
});
}); });
} }
const startedAt = Date.now(); const startedAt = Date.now();
const config = await getConfig(); const mapping = await fetchVersionMapping();
if (!config.MinorVersionToConfig) { if (!mapping.MinorVersionToConfig) {
core.warning(JSON.stringify(config)); core.warning(JSON.stringify(mapping));
throw new Error(`invalid config: no MinorVersionToConfig field`); throw new Error(`invalid config: no MinorVersionToConfig field`);
} }
const versionConfig = config.MinorVersionToConfig[(0, exports.stringifyVersion)(reqLintVersion)]; const versionInfo = mapping.MinorVersionToConfig[(0, exports.stringifyVersion)(reqVersion)];
if (!versionConfig) { if (!versionInfo) {
throw new Error(`requested golangci-lint version '${(0, exports.stringifyVersion)(reqLintVersion)}' doesn't exist`); throw new Error(`requested golangci-lint version '${(0, exports.stringifyVersion)(reqVersion)}' doesn't exist`);
} }
if (versionConfig.Error) { if (versionInfo.Error) {
throw new Error(`failed to use requested golangci-lint version '${(0, exports.stringifyVersion)(reqLintVersion)}': ${versionConfig.Error}`); throw new Error(`failed to use requested golangci-lint version '${(0, exports.stringifyVersion)(reqVersion)}': ${versionInfo.Error}`);
} }
core.info(`Requested golangci-lint '${(0, exports.stringifyVersion)(reqLintVersion)}', using '${versionConfig.TargetVersion}', calculation took ${Date.now() - startedAt}ms`); core.info(`Requested golangci-lint '${(0, exports.stringifyVersion)(reqVersion)}', using '${versionInfo.TargetVersion}', calculation took ${Date.now() - startedAt}ms`);
return versionConfig; return versionInfo;
} }
@@ -94640,6 +94569,14 @@ module.exports = require("net");
/***/ }), /***/ }),
/***/ 7598:
/***/ ((module) => {
"use strict";
module.exports = require("node:crypto");
/***/ }),
/***/ 8474: /***/ 8474:
/***/ ((module) => { /***/ ((module) => {

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

@@ -8662,7 +8662,11 @@ function copyFile(srcFile, destFile, force) {
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -8675,7 +8679,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -8705,11 +8709,11 @@ function _findMatch(versionSpec, stable, candidates, archFilter) {
let file; let file;
for (const candidate of candidates) { for (const candidate of candidates) {
const version = candidate.version; const version = candidate.version;
core_1.debug(`check ${version} satisfies ${versionSpec}`); (0, core_1.debug)(`check ${version} satisfies ${versionSpec}`);
if (semver.satisfies(version, versionSpec) && if (semver.satisfies(version, versionSpec) &&
(!stable || candidate.stable === stable)) { (!stable || candidate.stable === stable)) {
file = candidate.files.find(item => { file = candidate.files.find(item => {
core_1.debug(`${item.arch}===${archFilter} && ${item.platform}===${platFilter}`); (0, core_1.debug)(`${item.arch}===${archFilter} && ${item.platform}===${platFilter}`);
let chk = item.arch === archFilter && item.platform === platFilter; let chk = item.arch === archFilter && item.platform === platFilter;
if (chk && item.platform_version) { if (chk && item.platform_version) {
const osVersion = module.exports._getOsVersion(); const osVersion = module.exports._getOsVersion();
@@ -8723,7 +8727,7 @@ function _findMatch(versionSpec, stable, candidates, archFilter) {
return chk; return chk;
}); });
if (file) { if (file) {
core_1.debug(`matched ${candidate.version}`); (0, core_1.debug)(`matched ${candidate.version}`);
match = candidate; match = candidate;
break; break;
} }
@@ -8761,10 +8765,7 @@ function _getOsVersion() {
if (parts.length === 2 && if (parts.length === 2 &&
(parts[0].trim() === 'VERSION_ID' || (parts[0].trim() === 'VERSION_ID' ||
parts[0].trim() === 'DISTRIB_RELEASE')) { parts[0].trim() === 'DISTRIB_RELEASE')) {
version = parts[1] version = parts[1].trim().replace(/^"/, '').replace(/"$/, '');
.trim()
.replace(/^"/, '')
.replace(/"$/, '');
break; break;
} }
} }
@@ -8797,7 +8798,11 @@ exports._readLinuxVersionFile = _readLinuxVersionFile;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -8810,7 +8815,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -8887,7 +8892,11 @@ exports.RetryHelper = RetryHelper;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -8900,7 +8909,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -8913,13 +8922,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next()); step((generator = generator.apply(thisArg, _arguments || [])).next());
}); });
}; };
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.evaluateVersions = exports.isExplicitVersion = exports.findFromManifest = exports.getManifestFromRepo = exports.findAllVersions = exports.find = exports.cacheFile = exports.cacheDir = exports.extractZip = exports.extractXar = exports.extractTar = exports.extract7z = exports.downloadTool = exports.HTTPError = void 0; exports.evaluateVersions = exports.isExplicitVersion = exports.findFromManifest = exports.getManifestFromRepo = exports.findAllVersions = exports.find = exports.cacheFile = exports.cacheDir = exports.extractZip = exports.extractXar = exports.extractTar = exports.extract7z = exports.downloadTool = exports.HTTPError = void 0;
const core = __importStar(__nccwpck_require__(7484)); const core = __importStar(__nccwpck_require__(7484));
const io = __importStar(__nccwpck_require__(4994)); const io = __importStar(__nccwpck_require__(4994));
const crypto = __importStar(__nccwpck_require__(6982));
const fs = __importStar(__nccwpck_require__(9896)); const fs = __importStar(__nccwpck_require__(9896));
const mm = __importStar(__nccwpck_require__(8036)); const mm = __importStar(__nccwpck_require__(8036));
const os = __importStar(__nccwpck_require__(857)); const os = __importStar(__nccwpck_require__(857));
@@ -8929,7 +8936,6 @@ const semver = __importStar(__nccwpck_require__(9318));
const stream = __importStar(__nccwpck_require__(2203)); const stream = __importStar(__nccwpck_require__(2203));
const util = __importStar(__nccwpck_require__(9023)); const util = __importStar(__nccwpck_require__(9023));
const assert_1 = __nccwpck_require__(2613); const assert_1 = __nccwpck_require__(2613);
const v4_1 = __importDefault(__nccwpck_require__(9021));
const exec_1 = __nccwpck_require__(5236); const exec_1 = __nccwpck_require__(5236);
const retry_helper_1 = __nccwpck_require__(7380); const retry_helper_1 = __nccwpck_require__(7380);
class HTTPError extends Error { class HTTPError extends Error {
@@ -8954,7 +8960,7 @@ const userAgent = 'actions/tool-cache';
*/ */
function downloadTool(url, dest, auth, headers) { function downloadTool(url, dest, auth, headers) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
dest = dest || path.join(_getTempDirectory(), v4_1.default()); dest = dest || path.join(_getTempDirectory(), crypto.randomUUID());
yield io.mkdirP(path.dirname(dest)); yield io.mkdirP(path.dirname(dest));
core.debug(`Downloading ${url}`); core.debug(`Downloading ${url}`);
core.debug(`Destination ${dest}`); core.debug(`Destination ${dest}`);
@@ -9043,8 +9049,8 @@ function downloadToolAttempt(url, dest, auth, headers) {
*/ */
function extract7z(file, dest, _7zPath) { function extract7z(file, dest, _7zPath) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS'); (0, assert_1.ok)(IS_WINDOWS, 'extract7z() not supported on current OS');
assert_1.ok(file, 'parameter "file" is required'); (0, assert_1.ok)(file, 'parameter "file" is required');
dest = yield _createExtractFolder(dest); dest = yield _createExtractFolder(dest);
const originalCwd = process.cwd(); const originalCwd = process.cwd();
process.chdir(dest); process.chdir(dest);
@@ -9061,7 +9067,7 @@ function extract7z(file, dest, _7zPath) {
const options = { const options = {
silent: true silent: true
}; };
yield exec_1.exec(`"${_7zPath}"`, args, options); yield (0, exec_1.exec)(`"${_7zPath}"`, args, options);
} }
finally { finally {
process.chdir(originalCwd); process.chdir(originalCwd);
@@ -9090,7 +9096,7 @@ function extract7z(file, dest, _7zPath) {
}; };
try { try {
const powershellPath = yield io.which('powershell', true); const powershellPath = yield io.which('powershell', true);
yield exec_1.exec(`"${powershellPath}"`, args, options); yield (0, exec_1.exec)(`"${powershellPath}"`, args, options);
} }
finally { finally {
process.chdir(originalCwd); process.chdir(originalCwd);
@@ -9118,7 +9124,7 @@ function extractTar(file, dest, flags = 'xz') {
// Determine whether GNU tar // Determine whether GNU tar
core.debug('Checking tar --version'); core.debug('Checking tar --version');
let versionOutput = ''; let versionOutput = '';
yield exec_1.exec('tar --version', [], { yield (0, exec_1.exec)('tar --version', [], {
ignoreReturnCode: true, ignoreReturnCode: true,
silent: true, silent: true,
listeners: { listeners: {
@@ -9154,7 +9160,7 @@ function extractTar(file, dest, flags = 'xz') {
args.push('--overwrite'); args.push('--overwrite');
} }
args.push('-C', destArg, '-f', fileArg); args.push('-C', destArg, '-f', fileArg);
yield exec_1.exec(`tar`, args); yield (0, exec_1.exec)(`tar`, args);
return dest; return dest;
}); });
} }
@@ -9169,8 +9175,8 @@ exports.extractTar = extractTar;
*/ */
function extractXar(file, dest, flags = []) { function extractXar(file, dest, flags = []) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
assert_1.ok(IS_MAC, 'extractXar() not supported on current OS'); (0, assert_1.ok)(IS_MAC, 'extractXar() not supported on current OS');
assert_1.ok(file, 'parameter "file" is required'); (0, assert_1.ok)(file, 'parameter "file" is required');
dest = yield _createExtractFolder(dest); dest = yield _createExtractFolder(dest);
let args; let args;
if (flags instanceof Array) { if (flags instanceof Array) {
@@ -9184,7 +9190,7 @@ function extractXar(file, dest, flags = []) {
args.push('-v'); args.push('-v');
} }
const xarPath = yield io.which('xar', true); const xarPath = yield io.which('xar', true);
yield exec_1.exec(`"${xarPath}"`, _unique(args)); yield (0, exec_1.exec)(`"${xarPath}"`, _unique(args));
return dest; return dest;
}); });
} }
@@ -9238,7 +9244,7 @@ function extractZipWin(file, dest) {
pwshCommand pwshCommand
]; ];
core.debug(`Using pwsh at path: ${pwshPath}`); core.debug(`Using pwsh at path: ${pwshPath}`);
yield exec_1.exec(`"${pwshPath}"`, args); yield (0, exec_1.exec)(`"${pwshPath}"`, args);
} }
else { else {
const powershellCommand = [ const powershellCommand = [
@@ -9259,7 +9265,7 @@ function extractZipWin(file, dest) {
]; ];
const powershellPath = yield io.which('powershell', true); const powershellPath = yield io.which('powershell', true);
core.debug(`Using powershell at path: ${powershellPath}`); core.debug(`Using powershell at path: ${powershellPath}`);
yield exec_1.exec(`"${powershellPath}"`, args); yield (0, exec_1.exec)(`"${powershellPath}"`, args);
} }
}); });
} }
@@ -9271,7 +9277,7 @@ function extractZipNix(file, dest) {
args.unshift('-q'); args.unshift('-q');
} }
args.unshift('-o'); //overwrite with -o, otherwise a prompt is shown which freezes the run args.unshift('-o'); //overwrite with -o, otherwise a prompt is shown which freezes the run
yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest }); yield (0, exec_1.exec)(`"${unzipPath}"`, args, { cwd: dest });
}); });
} }
/** /**
@@ -9448,7 +9454,7 @@ function _createExtractFolder(dest) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (!dest) { if (!dest) {
// create a temp dir // create a temp dir
dest = path.join(_getTempDirectory(), v4_1.default()); dest = path.join(_getTempDirectory(), crypto.randomUUID());
} }
yield io.mkdirP(dest); yield io.mkdirP(dest);
return dest; return dest;
@@ -9521,7 +9527,7 @@ exports.evaluateVersions = evaluateVersions;
*/ */
function _getCacheDirectory() { function _getCacheDirectory() {
const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || ''; const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || '';
assert_1.ok(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined'); (0, assert_1.ok)(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined');
return cacheDirectory; return cacheDirectory;
} }
/** /**
@@ -9529,7 +9535,7 @@ function _getCacheDirectory() {
*/ */
function _getTempDirectory() { function _getTempDirectory() {
const tempDirectory = process.env['RUNNER_TEMP'] || ''; const tempDirectory = process.env['RUNNER_TEMP'] || '';
assert_1.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined'); (0, assert_1.ok)(tempDirectory, 'Expected RUNNER_TEMP to be defined');
return tempDirectory; return tempDirectory;
} }
/** /**
@@ -72162,6 +72168,14 @@ const { isUint8Array, isArrayBuffer } = __nccwpck_require__(8253)
const { File: UndiciFile } = __nccwpck_require__(3041) const { File: UndiciFile } = __nccwpck_require__(3041)
const { parseMIMEType, serializeAMimeType } = __nccwpck_require__(4322) const { parseMIMEType, serializeAMimeType } = __nccwpck_require__(4322)
let random
try {
const crypto = __nccwpck_require__(7598)
random = (max) => crypto.randomInt(0, max)
} catch {
random = (max) => Math.floor(Math.random(max))
}
let ReadableStream = globalThis.ReadableStream let ReadableStream = globalThis.ReadableStream
/** @type {globalThis['File']} */ /** @type {globalThis['File']} */
@@ -72247,7 +72261,7 @@ function extractBody (object, keepalive = false) {
// Set source to a copy of the bytes held by object. // Set source to a copy of the bytes held by object.
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength)) source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
} else if (util.isFormDataLike(object)) { } else if (util.isFormDataLike(object)) {
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, '0')}` const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, '0')}`
const prefix = `--${boundary}\r\nContent-Disposition: form-data` const prefix = `--${boundary}\r\nContent-Disposition: form-data`
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */ /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
@@ -86286,90 +86300,6 @@ exports.getUserAgent = getUserAgent;
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map
/***/ }),
/***/ 8682:
/***/ ((module) => {
/**
* Convert array of 16 byte values to UUID string format of the form:
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
*/
var byteToHex = [];
for (var i = 0; i < 256; ++i) {
byteToHex[i] = (i + 0x100).toString(16).substr(1);
}
function bytesToUuid(buf, offset) {
var i = offset || 0;
var bth = byteToHex;
// join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
return ([
bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]], '-',
bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]],
bth[buf[i++]], bth[buf[i++]]
]).join('');
}
module.exports = bytesToUuid;
/***/ }),
/***/ 1694:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
// Unique ID creation requires a high quality random # generator. In node.js
// this is pretty straight-forward - we use the crypto API.
var crypto = __nccwpck_require__(6982);
module.exports = function nodeRNG() {
return crypto.randomBytes(16);
};
/***/ }),
/***/ 9021:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
var rng = __nccwpck_require__(1694);
var bytesToUuid = __nccwpck_require__(8682);
function v4(options, buf, offset) {
var i = buf && offset || 0;
if (typeof(options) == 'string') {
buf = options === 'binary' ? new Array(16) : null;
options = null;
}
options = options || {};
var rnds = options.random || (options.rng || rng)();
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
rnds[6] = (rnds[6] & 0x0f) | 0x40;
rnds[8] = (rnds[8] & 0x3f) | 0x80;
// Copy bytes to buffer, if provided
if (buf) {
for (var ii = 0; ii < 16; ++ii) {
buf[i + ii] = rnds[ii];
}
}
return buf || bytesToUuid(rnds);
}
module.exports = v4;
/***/ }), /***/ }),
/***/ 7125: /***/ 7125:
@@ -93759,8 +93689,7 @@ const os_1 = __importDefault(__nccwpck_require__(857));
const path_1 = __importDefault(__nccwpck_require__(6928)); const path_1 = __importDefault(__nccwpck_require__(6928));
const util_1 = __nccwpck_require__(9023); const util_1 = __nccwpck_require__(9023);
const execShellCommand = (0, util_1.promisify)(child_process_1.exec); const execShellCommand = (0, util_1.promisify)(child_process_1.exec);
const downloadURL = "https://github.com/golangci/golangci-lint/releases/download"; const getAssetURL = (versionInfo) => {
const getAssetURL = (versionConfig) => {
let ext = "tar.gz"; let ext = "tar.gz";
let platform = os_1.default.platform().toString(); let platform = os_1.default.platform().toString();
switch (platform) { switch (platform) {
@@ -93782,8 +93711,8 @@ const getAssetURL = (versionConfig) => {
arch = "386"; arch = "386";
break; break;
} }
const noPrefix = versionConfig.TargetVersion.slice(1); const noPrefix = versionInfo.TargetVersion.slice(1);
return `${downloadURL}/${versionConfig.TargetVersion}/golangci-lint-${noPrefix}-${platform}-${arch}.${ext}`; return `https://github.com/golangci/golangci-lint/releases/download/${versionInfo.TargetVersion}/golangci-lint-${noPrefix}-${platform}-${arch}.${ext}`;
}; };
var InstallMode; var InstallMode;
(function (InstallMode) { (function (InstallMode) {
@@ -93802,55 +93731,57 @@ const printOutput = (res) => {
/** /**
* Install golangci-lint. * Install golangci-lint.
* *
* @param versionConfig information about version to install. * @param versionInfo information about version to install.
* @param mode installation mode. * @param mode installation mode.
* @returns path to installed binary of golangci-lint. * @returns path to installed binary of golangci-lint.
*/ */
async function installLint(versionConfig, mode) { async function installLint(versionInfo, mode) {
core.info(`Installation mode: ${mode}`); core.info(`Installation mode: ${mode}`);
switch (mode) { switch (mode) {
case InstallMode.Binary: case InstallMode.Binary:
return installBin(versionConfig); return installBin(versionInfo);
case InstallMode.GoInstall: case InstallMode.GoInstall:
return goInstall(versionConfig); return goInstall(versionInfo);
default: default:
return installBin(versionConfig); return installBin(versionInfo);
} }
} }
/** /**
* Install golangci-lint via `go install`. * Install golangci-lint via `go install`.
* *
* @param versionConfig information about version to install. * @param versionInfo information about version to install.
* @returns path to installed binary of golangci-lint. * @returns path to installed binary of golangci-lint.
*/ */
async function goInstall(versionConfig) { async function goInstall(versionInfo) {
core.info(`Installing golangci-lint ${versionConfig.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" } };
const exres = await execShellCommand(`go install github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`, options); // TODO(ldez): it should be updated for v2.
const exres = await execShellCommand(`go install github.com/golangci/golangci-lint/cmd/golangci-lint@${versionInfo.TargetVersion}`, options);
printOutput(exres); printOutput(exres);
const res = await execShellCommand(`go install -n github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`, options); // TODO(ldez): it should be updated for v2.
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 lintPath = res.stderr const binPath = res.stderr
.split(/\r?\n/) .split(/\r?\n/)
.map((v) => v.trimStart().trimEnd()) .map((v) => v.trimStart().trimEnd())
.filter((v) => v.startsWith("touch ")) .filter((v) => v.startsWith("touch "))
.reduce((a, b) => a + b, "") .reduce((a, b) => a + b, "")
.split(` `, 2)[1]; .split(` `, 2)[1];
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`); core.info(`Installed golangci-lint into ${binPath} in ${Date.now() - startedAt}ms`);
return lintPath; return binPath;
} }
/** /**
* Install golangci-lint via the precompiled binary. * Install golangci-lint via the precompiled binary.
* *
* @param versionConfig information about version to install. * @param versionInfo information about version to install.
* @returns path to installed binary of golangci-lint. * @returns path to installed binary of golangci-lint.
*/ */
async function installBin(versionConfig) { async function installBin(versionInfo) {
core.info(`Installing golangci-lint binary ${versionConfig.TargetVersion}...`); core.info(`Installing golangci-lint binary ${versionInfo.TargetVersion}...`);
const startedAt = Date.now(); const startedAt = Date.now();
const assetURL = getAssetURL(versionConfig); const assetURL = getAssetURL(versionInfo);
core.info(`Downloading binary ${assetURL} ...`); core.info(`Downloading binary ${assetURL} ...`);
const archivePath = await tc.downloadTool(assetURL); const archivePath = await tc.downloadTool(assetURL);
let extractedDir = ""; let extractedDir = "";
@@ -93869,9 +93800,9 @@ async function installBin(versionConfig) {
} }
const urlParts = assetURL.split(`/`); const urlParts = assetURL.split(`/`);
const dirName = urlParts[urlParts.length - 1].replace(repl, ``); const dirName = urlParts[urlParts.length - 1].replace(repl, ``);
const lintPath = path_1.default.join(extractedDir, dirName, `golangci-lint`); const binPath = path_1.default.join(extractedDir, dirName, `golangci-lint`);
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`); core.info(`Installed golangci-lint into ${binPath} in ${Date.now() - startedAt}ms`);
return lintPath; return binPath;
} }
@@ -93942,14 +93873,14 @@ function isOnlyNewIssues() {
async function prepareLint() { async function prepareLint() {
const mode = core.getInput("install-mode").toLowerCase(); const mode = core.getInput("install-mode").toLowerCase();
if (mode === install_1.InstallMode.None) { if (mode === install_1.InstallMode.None) {
const bin = await (0, which_1.default)("golangci-lint", { nothrow: true }); const binPath = await (0, which_1.default)("golangci-lint", { nothrow: true });
if (!bin) { if (!binPath) {
throw new Error("golangci-lint binary not found in the PATH"); throw new Error("golangci-lint binary not found in the PATH");
} }
return bin; return binPath;
} }
const versionConfig = await (0, version_1.findLintVersion)(mode); const versionInfo = await (0, version_1.getVersion)(mode);
return await (0, install_1.installLint)(versionConfig, mode); return await (0, install_1.installLint)(versionInfo, mode);
} }
async function fetchPatch() { async function fetchPatch() {
if (!isOnlyNewIssues()) { if (!isOnlyNewIssues()) {
@@ -94048,10 +93979,10 @@ async function prepareEnv() {
const startedAt = Date.now(); const startedAt = Date.now();
// Prepare cache, lint and go in parallel. // Prepare cache, lint and go in parallel.
await (0, cache_1.restoreCache)(); await (0, cache_1.restoreCache)();
const lintPath = await prepareLint(); const binPath = await prepareLint();
const patchPath = await fetchPatch(); const patchPath = await fetchPatch();
core.info(`Prepared env in ${Date.now() - startedAt}ms`); core.info(`Prepared env in ${Date.now() - startedAt}ms`);
return { lintPath, patchPath }; return { binPath: binPath, patchPath };
} }
const printOutput = (res) => { const printOutput = (res) => {
if (res.stdout) { if (res.stdout) {
@@ -94160,9 +94091,9 @@ async function runLint(lintPath, patchPath) {
} }
async function run() { async function run() {
try { try {
const { lintPath, patchPath } = await core.group(`prepare environment`, prepareEnv); const { binPath, patchPath } = await core.group(`prepare environment`, prepareEnv);
core.addPath(path.dirname(lintPath)); core.addPath(path.dirname(binPath));
await core.group(`run golangci-lint`, () => runLint(lintPath, patchPath)); await core.group(`run golangci-lint`, () => runLint(binPath, patchPath));
} }
catch (error) { catch (error) {
core.error(`Failed to run: ${error}, ${error.stack}`); core.error(`Failed to run: ${error}, ${error.stack}`);
@@ -94388,17 +94319,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.stringifyVersion = void 0; exports.stringifyVersion = void 0;
exports.findLintVersion = findLintVersion; exports.getVersion = getVersion;
const core = __importStar(__nccwpck_require__(7484)); const core = __importStar(__nccwpck_require__(7484));
const httpm = __importStar(__nccwpck_require__(4844)); const httpm = __importStar(__nccwpck_require__(4844));
const fs = __importStar(__nccwpck_require__(9896)); const fs = __importStar(__nccwpck_require__(9896));
const os_1 = __importDefault(__nccwpck_require__(857));
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\s(v.+)/; const modVersionRe = /github.com\/golangci\/golangci-lint\s(v.+)/;
const parseVersion = (s) => { const parseVersion = (s) => {
if (s == "latest" || s == "") { if (s == "latest" || s == "") {
// TODO(ldez): it should be replaced with an explicit version (ex: v1.64.0)
return null; return null;
} }
const match = s.match(versionRe); const match = s.match(versionRe);
@@ -94418,6 +94350,7 @@ 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: 1,
minor: 28, minor: 28,
@@ -94437,37 +94370,38 @@ const isLessVersion = (a, b) => {
// then it returns false, since the patch version of requested is always zero // then it returns false, since the patch version of requested is always zero
return a.minor < b.minor; return a.minor < b.minor;
}; };
const getRequestedLintVersion = () => { const getRequestedVersion = () => {
let requestedLintVersion = core.getInput(`version`); let requestedVersion = core.getInput(`version`);
const workingDirectory = core.getInput(`working-directory`); const workingDirectory = core.getInput(`working-directory`);
let goMod = "go.mod"; let goMod = "go.mod";
if (workingDirectory) { if (workingDirectory) {
goMod = path_1.default.join(workingDirectory, goMod); goMod = path_1.default.join(workingDirectory, goMod);
} }
if (requestedLintVersion == "" && fs.existsSync(goMod)) { if (requestedVersion == "" && fs.existsSync(goMod)) {
const content = fs.readFileSync(goMod, "utf-8"); const content = fs.readFileSync(goMod, "utf-8");
const match = content.match(modVersionRe); const match = content.match(modVersionRe);
if (match) { if (match) {
requestedLintVersion = match[1]; requestedVersion = match[1];
core.info(`Found golangci-lint version '${requestedLintVersion}' in '${goMod}' file`); core.info(`Found golangci-lint version '${requestedVersion}' in '${goMod}' file`);
} }
} }
const parsedRequestedLintVersion = parseVersion(requestedLintVersion); const parsedRequestedVersion = parseVersion(requestedVersion);
if (parsedRequestedLintVersion == null) { if (parsedRequestedVersion == null) {
return null; return null;
} }
if (isLessVersion(parsedRequestedLintVersion, minVersion)) { if (isLessVersion(parsedRequestedVersion, minVersion)) {
throw new Error(`requested golangci-lint version '${requestedLintVersion}' isn't supported: we support only ${(0, exports.stringifyVersion)(minVersion)} and later versions`); throw new Error(`requested golangci-lint version '${requestedVersion}' isn't supported: we support only ${(0, exports.stringifyVersion)(minVersion)} and later versions`);
} }
return parsedRequestedLintVersion; return parsedRequestedVersion;
}; };
const getConfig = async () => { const fetchVersionMapping = async () => {
const http = new httpm.HttpClient(`golangci/golangci-lint-action`, [], { const http = new httpm.HttpClient(`golangci/golangci-lint-action`, [], {
allowRetries: true, allowRetries: true,
maxRetries: 5, maxRetries: 5,
}); });
try { try {
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/master/assets/github-action-config.json`; // TODO(ldez): HEAD should be replaced with an explicit version (ex: v1.64.0).
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v1.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})`);
@@ -94479,42 +94413,37 @@ const getConfig = async () => {
throw new Error(`failed to get action config: ${exc.message}`); throw new Error(`failed to get action config: ${exc.message}`);
} }
}; };
async function findLintVersion(mode) { 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`);
return { TargetVersion: v ? v : "latest", AssetURL: "github.com/golangci/golangci-lint" }; // TODO(ldez): latest should be replaced with an explicit version (ex: v1.64.0).
return { TargetVersion: v ? v : "latest" };
} }
const reqLintVersion = getRequestedLintVersion(); const reqVersion = getRequestedVersion();
// if the patched version is passed, just use it // if the patched version is passed, just use it
if (reqLintVersion?.major !== null && reqLintVersion?.minor != null && reqLintVersion?.patch !== null) { // TODO(ldez): should be updated to `reqVersion?.major === 2`.
if (reqVersion?.major === 1 && reqVersion?.minor != null && reqVersion?.patch !== null) {
return new Promise((resolve) => { return new Promise((resolve) => {
let arch = "amd64"; const versionWithoutV = `${reqVersion.major}.${reqVersion.minor}.${reqVersion.patch}`;
if (os_1.default.arch() === "arm64") { resolve({ TargetVersion: `v${versionWithoutV}` });
arch = "arm64";
}
const versionWithoutV = `${reqLintVersion.major}.${reqLintVersion.minor}.${reqLintVersion.patch}`;
resolve({
TargetVersion: `v${versionWithoutV}`,
AssetURL: `https://github.com/golangci/golangci-lint/releases/download/v${versionWithoutV}/golangci-lint-${versionWithoutV}-linux-${arch}.tar.gz`,
});
}); });
} }
const startedAt = Date.now(); const startedAt = Date.now();
const config = await getConfig(); const mapping = await fetchVersionMapping();
if (!config.MinorVersionToConfig) { if (!mapping.MinorVersionToConfig) {
core.warning(JSON.stringify(config)); core.warning(JSON.stringify(mapping));
throw new Error(`invalid config: no MinorVersionToConfig field`); throw new Error(`invalid config: no MinorVersionToConfig field`);
} }
const versionConfig = config.MinorVersionToConfig[(0, exports.stringifyVersion)(reqLintVersion)]; const versionInfo = mapping.MinorVersionToConfig[(0, exports.stringifyVersion)(reqVersion)];
if (!versionConfig) { if (!versionInfo) {
throw new Error(`requested golangci-lint version '${(0, exports.stringifyVersion)(reqLintVersion)}' doesn't exist`); throw new Error(`requested golangci-lint version '${(0, exports.stringifyVersion)(reqVersion)}' doesn't exist`);
} }
if (versionConfig.Error) { if (versionInfo.Error) {
throw new Error(`failed to use requested golangci-lint version '${(0, exports.stringifyVersion)(reqLintVersion)}': ${versionConfig.Error}`); throw new Error(`failed to use requested golangci-lint version '${(0, exports.stringifyVersion)(reqVersion)}': ${versionInfo.Error}`);
} }
core.info(`Requested golangci-lint '${(0, exports.stringifyVersion)(reqLintVersion)}', using '${versionConfig.TargetVersion}', calculation took ${Date.now() - startedAt}ms`); core.info(`Requested golangci-lint '${(0, exports.stringifyVersion)(reqVersion)}', using '${versionInfo.TargetVersion}', calculation took ${Date.now() - startedAt}ms`);
return versionConfig; return versionInfo;
} }
@@ -94640,6 +94569,14 @@ module.exports = require("net");
/***/ }), /***/ }),
/***/ 7598:
/***/ ((module) => {
"use strict";
module.exports = require("node:crypto");
/***/ }),
/***/ 8474: /***/ 8474:
/***/ ((module) => { /***/ ((module) => {

180
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "golanci-lint-action", "name": "golanci-lint-action",
"version": "3.1.0", "version": "6.3.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "golanci-lint-action", "name": "golanci-lint-action",
"version": "3.1.0", "version": "6.3.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^4.0.0", "@actions/cache": "^4.0.0",
@@ -14,8 +14,8 @@
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/github": "^6.0.0", "@actions/github": "^6.0.0",
"@actions/http-client": "^2.2.3", "@actions/http-client": "^2.2.3",
"@actions/tool-cache": "^2.0.1", "@actions/tool-cache": "^2.0.2",
"@types/node": "^22.10.5", "@types/node": "^22.13.1",
"@types/semver": "^7.5.8", "@types/semver": "^7.5.8",
"@types/tmp": "^0.2.6", "@types/tmp": "^0.2.6",
"@types/which": "^3.0.4", "@types/which": "^3.0.4",
@@ -23,13 +23,13 @@
"which": "^5.0.0" "which": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^8.19.1", "@typescript-eslint/eslint-plugin": "^8.23.0",
"@typescript-eslint/parser": "^8.19.1", "@typescript-eslint/parser": "^8.23.0",
"@vercel/ncc": "^0.38.3", "@vercel/ncc": "^0.38.3",
"eslint": "^8.57.1", "eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^10.0.1",
"eslint-plugin-import": "^2.31.0", "eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.1", "eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-simple-import-sort": "^12.1.1",
"prettier": "^3.4.2", "prettier": "^3.4.2",
"typescript": "^5.7.3" "typescript": "^5.7.3"
@@ -105,16 +105,16 @@
"integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==" "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q=="
}, },
"node_modules/@actions/tool-cache": { "node_modules/@actions/tool-cache": {
"version": "2.0.1", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.1.tgz", "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.2.tgz",
"integrity": "sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==", "integrity": "sha512-fBhNNOWxuoLxztQebpOaWu6WeVmuwa77Z+DxIZ1B+OYvGkGQon6kTVg6Z32Cb13WCuw0szqonK+hh03mJV7Z6w==",
"license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.11.1",
"@actions/exec": "^1.0.0", "@actions/exec": "^1.0.0",
"@actions/http-client": "^2.0.1", "@actions/http-client": "^2.0.1",
"@actions/io": "^1.1.1", "@actions/io": "^1.1.1",
"semver": "^6.1.0", "semver": "^6.1.0"
"uuid": "^3.3.2"
} }
}, },
"node_modules/@azure/abort-controller": { "node_modules/@azure/abort-controller": {
@@ -706,9 +706,10 @@
"dev": true "dev": true
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "22.10.5", "version": "22.13.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.5.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.1.tgz",
"integrity": "sha512-F8Q+SeGimwOo86fiovQh8qiXfFEh2/ocYv7tU5pJ3EXMSSxk1Joj5wefpFK2fHTf/N6HKGSxIDBT9f3gCxXPkQ==", "integrity": "sha512-jK8uzQlrvXqEU91UxiK5J7pKHyzgnI1Qnl0QDHIgVGuolJhRb9EEl28Cj9b3rGR8B2lhFCtvIm5os8lFnO/1Ew==",
"license": "MIT",
"dependencies": { "dependencies": {
"undici-types": "~6.20.0" "undici-types": "~6.20.0"
} }
@@ -759,20 +760,21 @@
"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.19.1", "version": "8.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.19.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.23.0.tgz",
"integrity": "sha512-tJzcVyvvb9h/PB96g30MpxACd9IrunT7GF9wfA9/0TJ1LxGOJx1TdPzSbBBnNED7K9Ka8ybJsnEpiXPktolTLg==", "integrity": "sha512-vBz65tJgRrA1Q5gWlRfvoH+w943dq9K1p1yDBY2pc+a1nbBLZp7fB9+Hk8DaALUbzjqlMfgaqlVPT1REJdkt/w==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"@eslint-community/regexpp": "^4.10.0", "@eslint-community/regexpp": "^4.10.0",
"@typescript-eslint/scope-manager": "8.19.1", "@typescript-eslint/scope-manager": "8.23.0",
"@typescript-eslint/type-utils": "8.19.1", "@typescript-eslint/type-utils": "8.23.0",
"@typescript-eslint/utils": "8.19.1", "@typescript-eslint/utils": "8.23.0",
"@typescript-eslint/visitor-keys": "8.19.1", "@typescript-eslint/visitor-keys": "8.23.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",
"ts-api-utils": "^2.0.0" "ts-api-utils": "^2.0.1"
}, },
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -788,15 +790,16 @@
} }
}, },
"node_modules/@typescript-eslint/parser": { "node_modules/@typescript-eslint/parser": {
"version": "8.19.1", "version": "8.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.19.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.23.0.tgz",
"integrity": "sha512-67gbfv8rAwawjYx3fYArwldTQKoYfezNUT4D5ioWetr/xCrxXxvleo3uuiFuKfejipvq+og7mjz3b0G2bVyUCw==", "integrity": "sha512-h2lUByouOXFAlMec2mILeELUbME5SZRN/7R9Cw2RD2lRQQY08MWMM+PmVVKKJNK1aIwqTo9t/0CvOxwPbRIE2Q==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/scope-manager": "8.19.1", "@typescript-eslint/scope-manager": "8.23.0",
"@typescript-eslint/types": "8.19.1", "@typescript-eslint/types": "8.23.0",
"@typescript-eslint/typescript-estree": "8.19.1", "@typescript-eslint/typescript-estree": "8.23.0",
"@typescript-eslint/visitor-keys": "8.19.1", "@typescript-eslint/visitor-keys": "8.23.0",
"debug": "^4.3.4" "debug": "^4.3.4"
}, },
"engines": { "engines": {
@@ -812,13 +815,14 @@
} }
}, },
"node_modules/@typescript-eslint/scope-manager": { "node_modules/@typescript-eslint/scope-manager": {
"version": "8.19.1", "version": "8.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.19.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.23.0.tgz",
"integrity": "sha512-60L9KIuN/xgmsINzonOcMDSB8p82h95hoBfSBtXuO4jlR1R9L1xSkmVZKgCPVfavDlXihh4ARNjXhh1gGnLC7Q==", "integrity": "sha512-OGqo7+dXHqI7Hfm+WqkZjKjsiRtFUQHPdGMXzk5mYXhJUedO7e/Y7i8AK3MyLMgZR93TX4bIzYrfyVjLC+0VSw==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/types": "8.19.1", "@typescript-eslint/types": "8.23.0",
"@typescript-eslint/visitor-keys": "8.19.1" "@typescript-eslint/visitor-keys": "8.23.0"
}, },
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -829,15 +833,16 @@
} }
}, },
"node_modules/@typescript-eslint/type-utils": { "node_modules/@typescript-eslint/type-utils": {
"version": "8.19.1", "version": "8.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.19.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.23.0.tgz",
"integrity": "sha512-Rp7k9lhDKBMRJB/nM9Ksp1zs4796wVNyihG9/TU9R6KCJDNkQbc2EOKjrBtLYh3396ZdpXLtr/MkaSEmNMtykw==", "integrity": "sha512-iIuLdYpQWZKbiH+RkCGc6iu+VwscP5rCtQ1lyQ7TYuKLrcZoeJVpcLiG8DliXVkUxirW/PWlmS+d6yD51L9jvA==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/typescript-estree": "8.19.1", "@typescript-eslint/typescript-estree": "8.23.0",
"@typescript-eslint/utils": "8.19.1", "@typescript-eslint/utils": "8.23.0",
"debug": "^4.3.4", "debug": "^4.3.4",
"ts-api-utils": "^2.0.0" "ts-api-utils": "^2.0.1"
}, },
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -852,10 +857,11 @@
} }
}, },
"node_modules/@typescript-eslint/types": { "node_modules/@typescript-eslint/types": {
"version": "8.19.1", "version": "8.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.19.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.23.0.tgz",
"integrity": "sha512-JBVHMLj7B1K1v1051ZaMMgLW4Q/jre5qGK0Ew6UgXz1Rqh+/xPzV1aW581OM00X6iOfyr1be+QyW8LOUf19BbA==", "integrity": "sha512-1sK4ILJbCmZOTt9k4vkoulT6/y5CHJ1qUYxqpF1K/DBAd8+ZUL4LlSCxOssuH5m4rUaaN0uS0HlVPvd45zjduQ==",
"dev": true, "dev": true,
"license": "MIT",
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
}, },
@@ -865,19 +871,20 @@
} }
}, },
"node_modules/@typescript-eslint/typescript-estree": { "node_modules/@typescript-eslint/typescript-estree": {
"version": "8.19.1", "version": "8.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.19.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.23.0.tgz",
"integrity": "sha512-jk/TZwSMJlxlNnqhy0Eod1PNEvCkpY6MXOXE/WLlblZ6ibb32i2We4uByoKPv1d0OD2xebDv4hbs3fm11SMw8Q==", "integrity": "sha512-LcqzfipsB8RTvH8FX24W4UUFk1bl+0yTOf9ZA08XngFwMg4Kj8A+9hwz8Cr/ZS4KwHrmo9PJiLZkOt49vPnuvQ==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/types": "8.19.1", "@typescript-eslint/types": "8.23.0",
"@typescript-eslint/visitor-keys": "8.19.1", "@typescript-eslint/visitor-keys": "8.23.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",
"minimatch": "^9.0.4", "minimatch": "^9.0.4",
"semver": "^7.6.0", "semver": "^7.6.0",
"ts-api-utils": "^2.0.0" "ts-api-utils": "^2.0.1"
}, },
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -895,6 +902,7 @@
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"balanced-match": "^1.0.0" "balanced-match": "^1.0.0"
} }
@@ -904,6 +912,7 @@
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
"dev": true, "dev": true,
"license": "ISC",
"dependencies": { "dependencies": {
"brace-expansion": "^2.0.1" "brace-expansion": "^2.0.1"
}, },
@@ -915,10 +924,11 @@
} }
}, },
"node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
"version": "7.6.3", "version": "7.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz",
"integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==",
"dev": true, "dev": true,
"license": "ISC",
"bin": { "bin": {
"semver": "bin/semver.js" "semver": "bin/semver.js"
}, },
@@ -927,15 +937,16 @@
} }
}, },
"node_modules/@typescript-eslint/utils": { "node_modules/@typescript-eslint/utils": {
"version": "8.19.1", "version": "8.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.19.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.23.0.tgz",
"integrity": "sha512-IxG5gLO0Ne+KaUc8iW1A+XuKLd63o4wlbI1Zp692n1xojCl/THvgIKXJXBZixTh5dd5+yTJ/VXH7GJaaw21qXA==", "integrity": "sha512-uB/+PSo6Exu02b5ZEiVtmY6RVYO7YU5xqgzTIVZwTHvvK3HsL8tZZHFaTLFtRG3CsV4A5mhOv+NZx5BlhXPyIA==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.4.0", "@eslint-community/eslint-utils": "^4.4.0",
"@typescript-eslint/scope-manager": "8.19.1", "@typescript-eslint/scope-manager": "8.23.0",
"@typescript-eslint/types": "8.19.1", "@typescript-eslint/types": "8.23.0",
"@typescript-eslint/typescript-estree": "8.19.1" "@typescript-eslint/typescript-estree": "8.23.0"
}, },
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -950,12 +961,13 @@
} }
}, },
"node_modules/@typescript-eslint/visitor-keys": { "node_modules/@typescript-eslint/visitor-keys": {
"version": "8.19.1", "version": "8.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.19.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.23.0.tgz",
"integrity": "sha512-fzmjU8CHK853V/avYZAvuVut3ZTfwN5YtMaoi+X9Y9MA9keaWNHC3zEQ9zvyX/7Hj+5JkNyK1l7TOR2hevHB6Q==", "integrity": "sha512-oWWhcWDLwDfu++BGTZcmXWqpwtkwb5o7fxUIGksMQQDSdPW9prsSnfIOZMlsj4vBOSrcnjIUZMiIjODgGosFhQ==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/types": "8.19.1", "@typescript-eslint/types": "8.23.0",
"eslint-visitor-keys": "^4.2.0" "eslint-visitor-keys": "^4.2.0"
}, },
"engines": { "engines": {
@@ -971,6 +983,7 @@
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz",
"integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==",
"dev": true, "dev": true,
"license": "Apache-2.0",
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
}, },
@@ -1712,12 +1725,12 @@
} }
}, },
"node_modules/eslint-config-prettier": { "node_modules/eslint-config-prettier": {
"version": "9.1.0", "version": "10.0.1",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-10.0.1.tgz",
"integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", "integrity": "sha512-lZBts941cyJyeaooiKxAtzoPHTN+GbQTJFAIdQbRhA4/8whaAraEh47Whw/ZFfrjNSnlAxqfm9i0XVAEkULjCw==",
"dev": true, "dev": true,
"bin": { "bin": {
"eslint-config-prettier": "bin/cli.js" "eslint-config-prettier": "build/bin/cli.js"
}, },
"peerDependencies": { "peerDependencies": {
"eslint": ">=7.0.0" "eslint": ">=7.0.0"
@@ -1824,9 +1837,9 @@
} }
}, },
"node_modules/eslint-plugin-prettier": { "node_modules/eslint-plugin-prettier": {
"version": "5.2.1", "version": "5.2.3",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.3.tgz",
"integrity": "sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==", "integrity": "sha512-qJ+y0FfCp/mQYQ/vWQ3s7eUlFEL4PyKfAJxsnYTJ4YT73nsJBWqmEpFryxV9OeUiqmsTsYJ5Y+KDNaeP31wrRw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"prettier-linter-helpers": "^1.0.0", "prettier-linter-helpers": "^1.0.0",
@@ -3534,10 +3547,11 @@
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
}, },
"node_modules/ts-api-utils": { "node_modules/ts-api-utils": {
"version": "2.0.0", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.0.0.tgz", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.0.1.tgz",
"integrity": "sha512-xCt/TOAc+EOHS1XPnijD3/yzpH6qg2xppZO1YDqGoVsNXfQfzHpOdNuXwrwOU8u4ITXJyDCTyt8w5g1sZv9ynQ==", "integrity": "sha512-dnlgjFSVetynI8nzgJ+qF62efpglpWRk8isUEWZGWlJYySCTD6aKvbUDu+zbPeDakk3bg5H4XpitHukgfL1m9w==",
"dev": true, "dev": true,
"license": "MIT",
"engines": { "engines": {
"node": ">=18.12" "node": ">=18.12"
}, },
@@ -3747,9 +3761,10 @@
} }
}, },
"node_modules/undici": { "node_modules/undici": {
"version": "5.28.4", "version": "5.28.5",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz",
"integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", "integrity": "sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==",
"license": "MIT",
"dependencies": { "dependencies": {
"@fastify/busboy": "^2.0.0" "@fastify/busboy": "^2.0.0"
}, },
@@ -3776,15 +3791,6 @@
"punycode": "^2.1.0" "punycode": "^2.1.0"
} }
}, },
"node_modules/uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
"bin": {
"uuid": "bin/uuid"
}
},
"node_modules/webidl-conversions": { "node_modules/webidl-conversions": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",

View File

@@ -1,6 +1,6 @@
{ {
"name": "golanci-lint-action", "name": "golanci-lint-action",
"version": "3.1.0", "version": "6.3.1",
"private": true, "private": true,
"description": "golangci-lint github action", "description": "golangci-lint github action",
"main": "dist/main.js", "main": "dist/main.js",
@@ -29,8 +29,8 @@
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/github": "^6.0.0", "@actions/github": "^6.0.0",
"@actions/http-client": "^2.2.3", "@actions/http-client": "^2.2.3",
"@actions/tool-cache": "^2.0.1", "@actions/tool-cache": "^2.0.2",
"@types/node": "^22.10.5", "@types/node": "^22.13.1",
"@types/semver": "^7.5.8", "@types/semver": "^7.5.8",
"@types/tmp": "^0.2.6", "@types/tmp": "^0.2.6",
"@types/which": "^3.0.4", "@types/which": "^3.0.4",
@@ -38,13 +38,13 @@
"which": "^5.0.0" "which": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^8.19.1", "@typescript-eslint/eslint-plugin": "^8.23.0",
"@typescript-eslint/parser": "^8.19.1", "@typescript-eslint/parser": "^8.23.0",
"@vercel/ncc": "^0.38.3", "@vercel/ncc": "^0.38.3",
"eslint": "^8.57.1", "eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^10.0.1",
"eslint-plugin-import": "^2.31.0", "eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.1", "eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-simple-import-sort": "^12.1.1",
"prettier": "^3.4.2", "prettier": "^3.4.2",
"typescript": "^5.7.3" "typescript": "^5.7.3"

View File

@@ -5,14 +5,13 @@ import os from "os"
import path from "path" import path from "path"
import { promisify } from "util" import { promisify } from "util"
import { VersionConfig } from "./version" import { VersionInfo } from "./version"
const execShellCommand = promisify(exec) const execShellCommand = promisify(exec)
const downloadURL = "https://github.com/golangci/golangci-lint/releases/download" const getAssetURL = (versionInfo: VersionInfo): string => {
const getAssetURL = (versionConfig: VersionConfig): string => {
let ext = "tar.gz" let ext = "tar.gz"
let platform = os.platform().toString() let platform = os.platform().toString()
switch (platform) { switch (platform) {
case "win32": case "win32":
@@ -20,6 +19,7 @@ const getAssetURL = (versionConfig: VersionConfig): string => {
ext = "zip" ext = "zip"
break break
} }
let arch = os.arch() let arch = os.arch()
switch (arch) { switch (arch) {
case "arm64": case "arm64":
@@ -33,9 +33,10 @@ const getAssetURL = (versionConfig: VersionConfig): string => {
arch = "386" arch = "386"
break break
} }
const noPrefix = versionConfig.TargetVersion.slice(1)
return `${downloadURL}/${versionConfig.TargetVersion}/golangci-lint-${noPrefix}-${platform}-${arch}.${ext}` const noPrefix = versionInfo.TargetVersion.slice(1)
return `https://github.com/golangci/golangci-lint/releases/download/${versionInfo.TargetVersion}/golangci-lint-${noPrefix}-${platform}-${arch}.${ext}`
} }
export enum InstallMode { export enum InstallMode {
@@ -61,73 +62,75 @@ const printOutput = (res: ExecRes): void => {
/** /**
* Install golangci-lint. * Install golangci-lint.
* *
* @param versionConfig information about version to install. * @param versionInfo information about version to install.
* @param mode installation mode. * @param mode installation mode.
* @returns path to installed binary of golangci-lint. * @returns path to installed binary of golangci-lint.
*/ */
export async function installLint(versionConfig: VersionConfig, mode: InstallMode): Promise<string> { export async function installLint(versionInfo: VersionInfo, mode: InstallMode): Promise<string> {
core.info(`Installation mode: ${mode}`) core.info(`Installation mode: ${mode}`)
switch (mode) { switch (mode) {
case InstallMode.Binary: case InstallMode.Binary:
return installBin(versionConfig) return installBin(versionInfo)
case InstallMode.GoInstall: case InstallMode.GoInstall:
return goInstall(versionConfig) return goInstall(versionInfo)
default: default:
return installBin(versionConfig) return installBin(versionInfo)
} }
} }
/** /**
* Install golangci-lint via `go install`. * Install golangci-lint via `go install`.
* *
* @param versionConfig information about version to install. * @param versionInfo information about version to install.
* @returns path to installed binary of golangci-lint. * @returns path to installed binary of golangci-lint.
*/ */
export async function goInstall(versionConfig: VersionConfig): Promise<string> { export async function goInstall(versionInfo: VersionInfo): Promise<string> {
core.info(`Installing golangci-lint ${versionConfig.TargetVersion}...`) core.info(`Installing golangci-lint ${versionInfo.TargetVersion}...`)
const startedAt = Date.now() const startedAt = Date.now()
const options: ExecOptions = { env: { ...process.env, CGO_ENABLED: "1" } } const options: ExecOptions = { env: { ...process.env, CGO_ENABLED: "1" } }
// 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@${versionConfig.TargetVersion}`, `go install github.com/golangci/golangci-lint/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@${versionConfig.TargetVersion}`, `go install -n github.com/golangci/golangci-lint/cmd/golangci-lint@${versionInfo.TargetVersion}`,
options options
) )
printOutput(res) printOutput(res)
// The output of `go install -n` when the binary is already installed is `touch <path_to_the_binary>`. // The output of `go install -n` when the binary is already installed is `touch <path_to_the_binary>`.
const lintPath = res.stderr const binPath = res.stderr
.split(/\r?\n/) .split(/\r?\n/)
.map((v) => v.trimStart().trimEnd()) .map((v) => v.trimStart().trimEnd())
.filter((v) => v.startsWith("touch ")) .filter((v) => v.startsWith("touch "))
.reduce((a, b) => a + b, "") .reduce((a, b) => a + b, "")
.split(` `, 2)[1] .split(` `, 2)[1]
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`) core.info(`Installed golangci-lint into ${binPath} in ${Date.now() - startedAt}ms`)
return lintPath return binPath
} }
/** /**
* Install golangci-lint via the precompiled binary. * Install golangci-lint via the precompiled binary.
* *
* @param versionConfig information about version to install. * @param versionInfo information about version to install.
* @returns path to installed binary of golangci-lint. * @returns path to installed binary of golangci-lint.
*/ */
export async function installBin(versionConfig: VersionConfig): Promise<string> { export async function installBin(versionInfo: VersionInfo): Promise<string> {
core.info(`Installing golangci-lint binary ${versionConfig.TargetVersion}...`) core.info(`Installing golangci-lint binary ${versionInfo.TargetVersion}...`)
const startedAt = Date.now() const startedAt = Date.now()
const assetURL = getAssetURL(versionConfig) const assetURL = getAssetURL(versionInfo)
core.info(`Downloading binary ${assetURL} ...`) core.info(`Downloading binary ${assetURL} ...`)
@@ -149,9 +152,9 @@ export async function installBin(versionConfig: VersionConfig): Promise<string>
const urlParts = assetURL.split(`/`) const urlParts = assetURL.split(`/`)
const dirName = urlParts[urlParts.length - 1].replace(repl, ``) const dirName = urlParts[urlParts.length - 1].replace(repl, ``)
const lintPath = path.join(extractedDir, dirName, `golangci-lint`) const binPath = path.join(extractedDir, dirName, `golangci-lint`)
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`) core.info(`Installed golangci-lint into ${binPath} in ${Date.now() - startedAt}ms`)
return lintPath return binPath
} }

View File

@@ -11,7 +11,7 @@ import which from "which"
import { restoreCache, saveCache } from "./cache" import { restoreCache, saveCache } from "./cache"
import { installLint, InstallMode } from "./install" import { installLint, InstallMode } from "./install"
import { alterDiffPatch } from "./utils/diffUtils" import { alterDiffPatch } from "./utils/diffUtils"
import { findLintVersion } from "./version" import { getVersion } from "./version"
const execShellCommand = promisify(exec) const execShellCommand = promisify(exec)
const writeFile = promisify(fs.writeFile) const writeFile = promisify(fs.writeFile)
@@ -25,16 +25,16 @@ async function prepareLint(): Promise<string> {
const mode = core.getInput("install-mode").toLowerCase() const mode = core.getInput("install-mode").toLowerCase()
if (mode === InstallMode.None) { if (mode === InstallMode.None) {
const bin = await which("golangci-lint", { nothrow: true }) const binPath = await which("golangci-lint", { nothrow: true })
if (!bin) { if (!binPath) {
throw new Error("golangci-lint binary not found in the PATH") throw new Error("golangci-lint binary not found in the PATH")
} }
return bin return binPath
} }
const versionConfig = await findLintVersion(<InstallMode>mode) const versionInfo = await getVersion(<InstallMode>mode)
return await installLint(versionConfig, <InstallMode>mode) return await installLint(versionInfo, <InstallMode>mode)
} }
async function fetchPatch(): Promise<string> { async function fetchPatch(): Promise<string> {
@@ -141,7 +141,7 @@ async function fetchPushPatch(ctx: Context): Promise<string> {
} }
type Env = { type Env = {
lintPath: string binPath: string
patchPath: string patchPath: string
} }
@@ -151,12 +151,12 @@ async function prepareEnv(): Promise<Env> {
// Prepare cache, lint and go in parallel. // Prepare cache, lint and go in parallel.
await restoreCache() await restoreCache()
const lintPath = await prepareLint() const binPath = await prepareLint()
const patchPath = await fetchPatch() const patchPath = await fetchPatch()
core.info(`Prepared env in ${Date.now() - startedAt}ms`) core.info(`Prepared env in ${Date.now() - startedAt}ms`)
return { lintPath, patchPath } return { binPath: binPath, patchPath }
} }
type ExecRes = { type ExecRes = {
@@ -292,9 +292,9 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
export async function run(): Promise<void> { export async function run(): Promise<void> {
try { try {
const { lintPath, patchPath } = await core.group(`prepare environment`, prepareEnv) const { binPath, patchPath } = await core.group(`prepare environment`, prepareEnv)
core.addPath(path.dirname(lintPath)) core.addPath(path.dirname(binPath))
await core.group(`run golangci-lint`, () => runLint(lintPath, patchPath)) await core.group(`run golangci-lint`, () => runLint(binPath, patchPath))
} catch (error) { } catch (error) {
core.error(`Failed to run: ${error}, ${error.stack}`) core.error(`Failed to run: ${error}, ${error.stack}`)
core.setFailed(error.message) core.setFailed(error.message)

View File

@@ -1,7 +1,6 @@
import * as core from "@actions/core" import * as core from "@actions/core"
import * as httpm from "@actions/http-client" import * as httpm from "@actions/http-client"
import * as fs from "fs" import * as fs from "fs"
import os from "os"
import path from "path" import path from "path"
import { InstallMode } from "./install" import { InstallMode } from "./install"
@@ -14,10 +13,12 @@ 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\s(v.+)/ const modVersionRe = /github.com\/golangci\/golangci-lint\s(v.+)/
const parseVersion = (s: string): Version => { const parseVersion = (s: string): Version => {
if (s == "latest" || s == "") { if (s == "latest" || s == "") {
// TODO(ldez): it should be replaced with an explicit version (ex: v1.64.0)
return null return null
} }
@@ -40,6 +41,7 @@ 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: 1,
minor: 28, minor: 28,
@@ -62,8 +64,8 @@ const isLessVersion = (a: Version, b: Version): boolean => {
return a.minor < b.minor return a.minor < b.minor
} }
const getRequestedLintVersion = (): Version => { const getRequestedVersion = (): Version => {
let requestedLintVersion = core.getInput(`version`) let requestedVersion = core.getInput(`version`)
const workingDirectory = core.getInput(`working-directory`) const workingDirectory = core.getInput(`working-directory`)
let goMod = "go.mod" let goMod = "go.mod"
@@ -71,50 +73,50 @@ const getRequestedLintVersion = (): Version => {
goMod = path.join(workingDirectory, goMod) goMod = path.join(workingDirectory, goMod)
} }
if (requestedLintVersion == "" && fs.existsSync(goMod)) { if (requestedVersion == "" && fs.existsSync(goMod)) {
const content = fs.readFileSync(goMod, "utf-8") const content = fs.readFileSync(goMod, "utf-8")
const match = content.match(modVersionRe) const match = content.match(modVersionRe)
if (match) { if (match) {
requestedLintVersion = match[1] requestedVersion = match[1]
core.info(`Found golangci-lint version '${requestedLintVersion}' in '${goMod}' file`) core.info(`Found golangci-lint version '${requestedVersion}' in '${goMod}' file`)
} }
} }
const parsedRequestedLintVersion = parseVersion(requestedLintVersion) const parsedRequestedVersion = parseVersion(requestedVersion)
if (parsedRequestedLintVersion == null) { if (parsedRequestedVersion == null) {
return null return null
} }
if (isLessVersion(parsedRequestedLintVersion, minVersion)) { if (isLessVersion(parsedRequestedVersion, minVersion)) {
throw new Error( throw new Error(
`requested golangci-lint version '${requestedLintVersion}' isn't supported: we support only ${stringifyVersion( `requested golangci-lint version '${requestedVersion}' isn't supported: we support only ${stringifyVersion(
minVersion minVersion
)} and later versions` )} and later versions`
) )
} }
return parsedRequestedLintVersion return parsedRequestedVersion
} }
export type VersionConfig = { export type VersionInfo = {
Error?: string Error?: string
TargetVersion: string TargetVersion: string
AssetURL: string
} }
type Config = { type VersionMapping = {
MinorVersionToConfig: { MinorVersionToConfig: {
[minorVersion: string]: VersionConfig [minorVersion: string]: VersionInfo
} }
} }
const getConfig = async (): Promise<Config> => { const fetchVersionMapping = async (): Promise<VersionMapping> => {
const http = new httpm.HttpClient(`golangci/golangci-lint-action`, [], { const http = new httpm.HttpClient(`golangci/golangci-lint-action`, [], {
allowRetries: true, allowRetries: true,
maxRetries: 5, maxRetries: 5,
}) })
try { try {
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/master/assets/github-action-config.json` // TODO(ldez): HEAD should be replaced with an explicit version (ex: v1.64.0).
const url = `https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/assets/github-action-config-v1.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})`)
@@ -127,53 +129,48 @@ const getConfig = async (): Promise<Config> => {
} }
} }
export async function findLintVersion(mode: InstallMode): Promise<VersionConfig> { export async function getVersion(mode: InstallMode): Promise<VersionInfo> {
core.info(`Finding needed golangci-lint version...`) core.info(`Finding needed golangci-lint version...`)
if (mode == InstallMode.GoInstall) { if (mode == InstallMode.GoInstall) {
const v: string = core.getInput(`version`) const v: string = core.getInput(`version`)
return { TargetVersion: v ? v : "latest", AssetURL: "github.com/golangci/golangci-lint" } // TODO(ldez): latest should be replaced with an explicit version (ex: v1.64.0).
return { TargetVersion: v ? v : "latest" }
} }
const reqLintVersion = getRequestedLintVersion() const reqVersion = getRequestedVersion()
// if the patched version is passed, just use it // if the patched version is passed, just use it
if (reqLintVersion?.major !== null && reqLintVersion?.minor != null && reqLintVersion?.patch !== null) { // TODO(ldez): should be updated to `reqVersion?.major === 2`.
if (reqVersion?.major === 1 && reqVersion?.minor != null && reqVersion?.patch !== null) {
return new Promise((resolve) => { return new Promise((resolve) => {
let arch: string = "amd64" const versionWithoutV = `${reqVersion.major}.${reqVersion.minor}.${reqVersion.patch}`
if (os.arch() === "arm64") { resolve({ TargetVersion: `v${versionWithoutV}` })
arch = "arm64"
}
const versionWithoutV = `${reqLintVersion.major}.${reqLintVersion.minor}.${reqLintVersion.patch}`
resolve({
TargetVersion: `v${versionWithoutV}`,
AssetURL: `https://github.com/golangci/golangci-lint/releases/download/v${versionWithoutV}/golangci-lint-${versionWithoutV}-linux-${arch}.tar.gz`,
})
}) })
} }
const startedAt = Date.now() const startedAt = Date.now()
const config = await getConfig() const mapping = await fetchVersionMapping()
if (!config.MinorVersionToConfig) { if (!mapping.MinorVersionToConfig) {
core.warning(JSON.stringify(config)) core.warning(JSON.stringify(mapping))
throw new Error(`invalid config: no MinorVersionToConfig field`) throw new Error(`invalid config: no MinorVersionToConfig field`)
} }
const versionConfig = config.MinorVersionToConfig[stringifyVersion(reqLintVersion)] const versionInfo = mapping.MinorVersionToConfig[stringifyVersion(reqVersion)]
if (!versionConfig) { if (!versionInfo) {
throw new Error(`requested golangci-lint version '${stringifyVersion(reqLintVersion)}' doesn't exist`) throw new Error(`requested golangci-lint version '${stringifyVersion(reqVersion)}' doesn't exist`)
} }
if (versionConfig.Error) { if (versionInfo.Error) {
throw new Error(`failed to use requested golangci-lint version '${stringifyVersion(reqLintVersion)}': ${versionConfig.Error}`) throw new Error(`failed to use requested golangci-lint version '${stringifyVersion(reqVersion)}': ${versionInfo.Error}`)
} }
core.info( core.info(
`Requested golangci-lint '${stringifyVersion(reqLintVersion)}', using '${versionConfig.TargetVersion}', calculation took ${ `Requested golangci-lint '${stringifyVersion(reqVersion)}', using '${versionInfo.TargetVersion}', calculation took ${
Date.now() - startedAt Date.now() - startedAt
}ms` }ms`
) )
return versionConfig return versionInfo
} }