From a180f5062e382f86d0207a240cbe27487f9c1139 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 10 Jun 2023 13:50:17 +0200 Subject: [PATCH] feat: add install-mode --- .github/workflows/test.yml | 29 ++++++++++++ README.md | 6 +++ action.yml | 4 ++ dist/post_run/index.js | 91 +++++++++++++++++++++++++++++++----- dist/run/index.js | 91 +++++++++++++++++++++++++++++++----- src/install.ts | 94 ++++++++++++++++++++++++++++++++++++-- src/run.ts | 16 ++++--- src/version.ts | 17 ++++++- 8 files changed, 316 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7e7f84c4f5..b86f5e0ac1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -69,6 +69,35 @@ jobs: args: --timeout=3m --issues-exit-code=0 ./sample/... only-new-issues: true + test-go-install: # make sure the action works on a clean machine without building (go-install mode) + needs: [ build ] + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + version: + - "" + - "latest" + - "v1.53.2" + - "b5093688c0d3008eaacd6066773a1a52e689252f" + runs-on: ${{ matrix.os }} + permissions: + contents: read + pull-requests: read + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + cache: false # setup-go v4 caches by default + - uses: ./ + with: + version: ${{ matrix.version }} + args: --timeout=3m --issues-exit-code=0 ./sample/... + only-new-issues: true + install-mode: goinstall + test-go-mod-version: needs: [ build ] strategy: diff --git a/README.md b/README.md index 710202af42..df10ec8d9b 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,9 @@ jobs: # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. # skip-build-cache: true + + # Optional:The mode to install golangci-lint. It can be 'binary' or 'goinstall'. + # install-mode: "goinstall" ``` We recommend running this action in a job separate from other jobs (`go test`, etc) @@ -126,6 +129,9 @@ jobs: # Optional: show only new issues if it's a pull request. The default value is `false`. # only-new-issues: true + + # Optional:The mode to install golangci-lint. It can be 'binary' or 'goinstall'. + # install-mode: "goinstall" ``` You will also likely need to add the following `.gitattributes` file to ensure that line endings for windows builds are properly formatted: diff --git a/action.yml b/action.yml index 3e5d74d4d0..f82b8d05ad 100644 --- a/action.yml +++ b/action.yml @@ -34,6 +34,10 @@ inputs: description: "if set to true then the action doesn't cache or restore ~/.cache/go-build." default: false required: false + install-mode: + description: "The mode to install golangci-lint. It can be 'binary' or 'goinstall'." + default: "binary" + required: false runs: using: "node16" main: "dist/run/index.js" diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 25c77c3128..6966f55833 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -66370,11 +66370,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.installLint = void 0; +exports.installBin = exports.goInstall = exports.installLint = exports.InstallMode = void 0; const core = __importStar(__nccwpck_require__(2186)); const tc = __importStar(__nccwpck_require__(7784)); +const child_process_1 = __nccwpck_require__(2081); const os_1 = __importDefault(__nccwpck_require__(2037)); const path_1 = __importDefault(__nccwpck_require__(1017)); +const util_1 = __nccwpck_require__(3837); +const execShellCommand = (0, util_1.promisify)(child_process_1.exec); const downloadURL = "https://github.com/golangci/golangci-lint/releases/download"; const getAssetURL = (versionConfig) => { let ext = "tar.gz"; @@ -66398,13 +66401,74 @@ const getAssetURL = (versionConfig) => { const noPrefix = versionConfig.TargetVersion.slice(1); return `${downloadURL}/${versionConfig.TargetVersion}/golangci-lint-${noPrefix}-${platform}-${arch}.${ext}`; }; -// The installLint returns path to installed binary of golangci-lint. -function installLint(versionConfig) { +var InstallMode; +(function (InstallMode) { + InstallMode["Binary"] = "binary"; + InstallMode["GoInstall"] = "goinstall"; +})(InstallMode = exports.InstallMode || (exports.InstallMode = {})); +const printOutput = (res) => { + if (res.stdout) { + core.info(res.stdout); + } + if (res.stderr) { + core.info(res.stderr); + } +}; +/** + * Install golangci-lint. + * + * @param versionConfig information about version to install. + * @param mode installation mode. + * @returns path to installed binary of golangci-lint. + */ +function installLint(versionConfig, mode) { + return __awaiter(this, void 0, void 0, function* () { + core.info(`Installation mode: ${mode}`); + switch (mode) { + case InstallMode.Binary: + return installBin(versionConfig); + case InstallMode.GoInstall: + return goInstall(versionConfig); + default: + return installBin(versionConfig); + } + }); +} +exports.installLint = installLint; +/** + * Install golangci-lint via `go install`. + * + * @param versionConfig information about version to install. + * @returns path to installed binary of golangci-lint. + */ +function goInstall(versionConfig) { return __awaiter(this, void 0, void 0, function* () { core.info(`Installing golangci-lint ${versionConfig.TargetVersion}...`); const startedAt = Date.now(); + const options = { env: Object.assign(Object.assign({}, process.env), { CGO_ENABLED: "1" }) }; + const exres = yield execShellCommand(`go install github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`, options); + printOutput(exres); + const res = yield execShellCommand(`go install -n github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`, options); + printOutput(res); + // The output of `go install -n` when the binary is already installed is `touch `. + const lintPath = res.stderr.trimStart().trimEnd().split(` `, 2)[1]; + core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`); + return lintPath; + }); +} +exports.goInstall = goInstall; +/** + * Install golangci-lint via the precompiled binary. + * + * @param versionConfig information about version to install. + * @returns path to installed binary of golangci-lint. + */ +function installBin(versionConfig) { + return __awaiter(this, void 0, void 0, function* () { + core.info(`Installing golangci-lint binary ${versionConfig.TargetVersion}...`); + const startedAt = Date.now(); const assetURL = getAssetURL(versionConfig); - core.info(`Downloading ${assetURL} ...`); + core.info(`Downloading binary ${assetURL} ...`); const archivePath = yield tc.downloadTool(assetURL); let extractedDir = ""; let repl = /\.tar\.gz$/; @@ -66427,7 +66491,7 @@ function installLint(versionConfig) { return lintPath; }); } -exports.installLint = installLint; +exports.installBin = installBin; /***/ }), @@ -66486,8 +66550,9 @@ const writeFile = (0, util_1.promisify)(fs.writeFile); const createTempDir = (0, util_1.promisify)(tmp_1.dir); function prepareLint() { return __awaiter(this, void 0, void 0, function* () { - const versionConfig = yield (0, version_1.findLintVersion)(); - return yield (0, install_1.installLint)(versionConfig); + const mode = core.getInput("install-mode").toLowerCase(); + const versionConfig = yield (0, version_1.findLintVersion)(mode); + return yield (0, install_1.installLint)(versionConfig, mode); }); } function fetchPatch() { @@ -66548,11 +66613,10 @@ function prepareEnv() { return __awaiter(this, void 0, void 0, function* () { const startedAt = Date.now(); // Prepare cache, lint and go in parallel. - const restoreCachePromise = (0, cache_1.restoreCache)(); + yield (0, cache_1.restoreCache)(); const prepareLintPromise = prepareLint(); const patchPromise = fetchPatch(); const lintPath = yield prepareLintPromise; - yield restoreCachePromise; const patchPath = yield patchPromise; core.info(`Prepared env in ${Date.now() - startedAt}ms`); return { lintPath, patchPath }; @@ -66609,7 +66673,7 @@ function runLint(lintPath, patchPath) { } cmdArgs.cwd = path.resolve(workingDirectory); } - const cmd = `${lintPath} run ${addedArgs.join(` `)} ${userArgs}`.trimRight(); + const cmd = `${lintPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd(); core.info(`Running [${cmd}] in [${cmdArgs.cwd || ``}] ...`); const startedAt = Date.now(); try { @@ -66774,6 +66838,7 @@ const core = __importStar(__nccwpck_require__(2186)); const httpm = __importStar(__nccwpck_require__(6255)); const fs = __importStar(__nccwpck_require__(7147)); const path_1 = __importDefault(__nccwpck_require__(1017)); +const install_1 = __nccwpck_require__(1649); const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/; const modVersionRe = /github.com\/golangci\/golangci-lint\s(v.+)/; const parseVersion = (s) => { @@ -66858,9 +66923,13 @@ const getConfig = () => __awaiter(void 0, void 0, void 0, function* () { throw new Error(`failed to get action config: ${exc.message}`); } }); -function findLintVersion() { +function findLintVersion(mode) { return __awaiter(this, void 0, void 0, function* () { core.info(`Finding needed golangci-lint version...`); + if (mode == install_1.InstallMode.GoInstall) { + const v = core.getInput(`version`); + return { TargetVersion: v ? v : "latest", AssetURL: "github.com/golangci/golangci-lint" }; + } const reqLintVersion = getRequestedLintVersion(); // if the patched version is passed, just use it if ((reqLintVersion === null || reqLintVersion === void 0 ? void 0 : reqLintVersion.major) !== null && (reqLintVersion === null || reqLintVersion === void 0 ? void 0 : reqLintVersion.minor) != null && (reqLintVersion === null || reqLintVersion === void 0 ? void 0 : reqLintVersion.patch) !== null) { diff --git a/dist/run/index.js b/dist/run/index.js index 6dbd2dc6fb..916fcdf7bc 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -66370,11 +66370,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.installLint = void 0; +exports.installBin = exports.goInstall = exports.installLint = exports.InstallMode = void 0; const core = __importStar(__nccwpck_require__(2186)); const tc = __importStar(__nccwpck_require__(7784)); +const child_process_1 = __nccwpck_require__(2081); const os_1 = __importDefault(__nccwpck_require__(2037)); const path_1 = __importDefault(__nccwpck_require__(1017)); +const util_1 = __nccwpck_require__(3837); +const execShellCommand = (0, util_1.promisify)(child_process_1.exec); const downloadURL = "https://github.com/golangci/golangci-lint/releases/download"; const getAssetURL = (versionConfig) => { let ext = "tar.gz"; @@ -66398,13 +66401,74 @@ const getAssetURL = (versionConfig) => { const noPrefix = versionConfig.TargetVersion.slice(1); return `${downloadURL}/${versionConfig.TargetVersion}/golangci-lint-${noPrefix}-${platform}-${arch}.${ext}`; }; -// The installLint returns path to installed binary of golangci-lint. -function installLint(versionConfig) { +var InstallMode; +(function (InstallMode) { + InstallMode["Binary"] = "binary"; + InstallMode["GoInstall"] = "goinstall"; +})(InstallMode = exports.InstallMode || (exports.InstallMode = {})); +const printOutput = (res) => { + if (res.stdout) { + core.info(res.stdout); + } + if (res.stderr) { + core.info(res.stderr); + } +}; +/** + * Install golangci-lint. + * + * @param versionConfig information about version to install. + * @param mode installation mode. + * @returns path to installed binary of golangci-lint. + */ +function installLint(versionConfig, mode) { + return __awaiter(this, void 0, void 0, function* () { + core.info(`Installation mode: ${mode}`); + switch (mode) { + case InstallMode.Binary: + return installBin(versionConfig); + case InstallMode.GoInstall: + return goInstall(versionConfig); + default: + return installBin(versionConfig); + } + }); +} +exports.installLint = installLint; +/** + * Install golangci-lint via `go install`. + * + * @param versionConfig information about version to install. + * @returns path to installed binary of golangci-lint. + */ +function goInstall(versionConfig) { return __awaiter(this, void 0, void 0, function* () { core.info(`Installing golangci-lint ${versionConfig.TargetVersion}...`); const startedAt = Date.now(); + const options = { env: Object.assign(Object.assign({}, process.env), { CGO_ENABLED: "1" }) }; + const exres = yield execShellCommand(`go install github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`, options); + printOutput(exres); + const res = yield execShellCommand(`go install -n github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`, options); + printOutput(res); + // The output of `go install -n` when the binary is already installed is `touch `. + const lintPath = res.stderr.trimStart().trimEnd().split(` `, 2)[1]; + core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`); + return lintPath; + }); +} +exports.goInstall = goInstall; +/** + * Install golangci-lint via the precompiled binary. + * + * @param versionConfig information about version to install. + * @returns path to installed binary of golangci-lint. + */ +function installBin(versionConfig) { + return __awaiter(this, void 0, void 0, function* () { + core.info(`Installing golangci-lint binary ${versionConfig.TargetVersion}...`); + const startedAt = Date.now(); const assetURL = getAssetURL(versionConfig); - core.info(`Downloading ${assetURL} ...`); + core.info(`Downloading binary ${assetURL} ...`); const archivePath = yield tc.downloadTool(assetURL); let extractedDir = ""; let repl = /\.tar\.gz$/; @@ -66427,7 +66491,7 @@ function installLint(versionConfig) { return lintPath; }); } -exports.installLint = installLint; +exports.installBin = installBin; /***/ }), @@ -66486,8 +66550,9 @@ const writeFile = (0, util_1.promisify)(fs.writeFile); const createTempDir = (0, util_1.promisify)(tmp_1.dir); function prepareLint() { return __awaiter(this, void 0, void 0, function* () { - const versionConfig = yield (0, version_1.findLintVersion)(); - return yield (0, install_1.installLint)(versionConfig); + const mode = core.getInput("install-mode").toLowerCase(); + const versionConfig = yield (0, version_1.findLintVersion)(mode); + return yield (0, install_1.installLint)(versionConfig, mode); }); } function fetchPatch() { @@ -66548,11 +66613,10 @@ function prepareEnv() { return __awaiter(this, void 0, void 0, function* () { const startedAt = Date.now(); // Prepare cache, lint and go in parallel. - const restoreCachePromise = (0, cache_1.restoreCache)(); + yield (0, cache_1.restoreCache)(); const prepareLintPromise = prepareLint(); const patchPromise = fetchPatch(); const lintPath = yield prepareLintPromise; - yield restoreCachePromise; const patchPath = yield patchPromise; core.info(`Prepared env in ${Date.now() - startedAt}ms`); return { lintPath, patchPath }; @@ -66609,7 +66673,7 @@ function runLint(lintPath, patchPath) { } cmdArgs.cwd = path.resolve(workingDirectory); } - const cmd = `${lintPath} run ${addedArgs.join(` `)} ${userArgs}`.trimRight(); + const cmd = `${lintPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd(); core.info(`Running [${cmd}] in [${cmdArgs.cwd || ``}] ...`); const startedAt = Date.now(); try { @@ -66774,6 +66838,7 @@ const core = __importStar(__nccwpck_require__(2186)); const httpm = __importStar(__nccwpck_require__(6255)); const fs = __importStar(__nccwpck_require__(7147)); const path_1 = __importDefault(__nccwpck_require__(1017)); +const install_1 = __nccwpck_require__(1649); const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/; const modVersionRe = /github.com\/golangci\/golangci-lint\s(v.+)/; const parseVersion = (s) => { @@ -66858,9 +66923,13 @@ const getConfig = () => __awaiter(void 0, void 0, void 0, function* () { throw new Error(`failed to get action config: ${exc.message}`); } }); -function findLintVersion() { +function findLintVersion(mode) { return __awaiter(this, void 0, void 0, function* () { core.info(`Finding needed golangci-lint version...`); + if (mode == install_1.InstallMode.GoInstall) { + const v = core.getInput(`version`); + return { TargetVersion: v ? v : "latest", AssetURL: "github.com/golangci/golangci-lint" }; + } const reqLintVersion = getRequestedLintVersion(); // if the patched version is passed, just use it if ((reqLintVersion === null || reqLintVersion === void 0 ? void 0 : reqLintVersion.major) !== null && (reqLintVersion === null || reqLintVersion === void 0 ? void 0 : reqLintVersion.minor) != null && (reqLintVersion === null || reqLintVersion === void 0 ? void 0 : reqLintVersion.patch) !== null) { diff --git a/src/install.ts b/src/install.ts index b854030b78..f98d87c876 100644 --- a/src/install.ts +++ b/src/install.ts @@ -1,10 +1,14 @@ import * as core from "@actions/core" import * as tc from "@actions/tool-cache" +import { exec, ExecOptions } from "child_process" import os from "os" import path from "path" +import { promisify } from "util" import { VersionConfig } from "./version" +const execShellCommand = promisify(exec) + const downloadURL = "https://github.com/golangci/golangci-lint/releases/download" const getAssetURL = (versionConfig: VersionConfig): string => { @@ -31,13 +35,95 @@ const getAssetURL = (versionConfig: VersionConfig): string => { return `${downloadURL}/${versionConfig.TargetVersion}/golangci-lint-${noPrefix}-${platform}-${arch}.${ext}` } -// The installLint returns path to installed binary of golangci-lint. -export async function installLint(versionConfig: VersionConfig): Promise { +export enum InstallMode { + Binary = "binary", + GoInstall = "goinstall", +} + +type ExecRes = { + stdout: string + stderr: string +} + +const printOutput = (res: ExecRes): void => { + if (res.stdout) { + core.info(res.stdout) + } + if (res.stderr) { + core.info(res.stderr) + } +} + +/** + * Install golangci-lint. + * + * @param versionConfig information about version to install. + * @param mode installation mode. + * @returns path to installed binary of golangci-lint. + */ +export async function installLint(versionConfig: VersionConfig, mode: InstallMode): Promise { + core.info(`Installation mode: ${mode}`) + + switch (mode) { + case InstallMode.Binary: + return installBin(versionConfig) + case InstallMode.GoInstall: + return goInstall(versionConfig) + default: + return installBin(versionConfig) + } +} + +/** + * Install golangci-lint via `go install`. + * + * @param versionConfig information about version to install. + * @returns path to installed binary of golangci-lint. + */ +export async function goInstall(versionConfig: VersionConfig): Promise { core.info(`Installing golangci-lint ${versionConfig.TargetVersion}...`) + + const startedAt = Date.now() + + const options: ExecOptions = { env: { ...process.env, CGO_ENABLED: "1" } } + + const exres = await execShellCommand( + `go install github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`, + options + ) + printOutput(exres) + + const res = await execShellCommand( + `go install -n github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`, + options + ) + printOutput(res) + + // The output of `go install -n` when the binary is already installed is `touch `. + const lintPath = res.stderr.trimStart().trimEnd().split(` `, 2)[1] + + core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`) + + return lintPath +} + +/** + * Install golangci-lint via the precompiled binary. + * + * @param versionConfig information about version to install. + * @returns path to installed binary of golangci-lint. + */ +export async function installBin(versionConfig: VersionConfig): Promise { + core.info(`Installing golangci-lint binary ${versionConfig.TargetVersion}...`) + const startedAt = Date.now() + const assetURL = getAssetURL(versionConfig) - core.info(`Downloading ${assetURL} ...`) + + core.info(`Downloading binary ${assetURL} ...`) + const archivePath = await tc.downloadTool(assetURL) + let extractedDir = "" let repl = /\.tar\.gz$/ if (assetURL.endsWith("zip")) { @@ -55,6 +141,8 @@ export async function installLint(versionConfig: VersionConfig): Promise const urlParts = assetURL.split(`/`) const dirName = urlParts[urlParts.length - 1].replace(repl, ``) const lintPath = path.join(extractedDir, dirName, `golangci-lint`) + core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`) + return lintPath } diff --git a/src/run.ts b/src/run.ts index 2fd55d51ce..6ff46dd554 100644 --- a/src/run.ts +++ b/src/run.ts @@ -7,7 +7,7 @@ import { dir } from "tmp" import { promisify } from "util" import { restoreCache, saveCache } from "./cache" -import { installLint } from "./install" +import { installLint, InstallMode } from "./install" import { findLintVersion } from "./version" const execShellCommand = promisify(exec) @@ -15,8 +15,10 @@ const writeFile = promisify(fs.writeFile) const createTempDir = promisify(dir) async function prepareLint(): Promise { - const versionConfig = await findLintVersion() - return await installLint(versionConfig) + const mode = core.getInput("install-mode").toLowerCase() + const versionConfig = await findLintVersion(mode) + + return await installLint(versionConfig, mode) } async function fetchPatch(): Promise { @@ -83,15 +85,15 @@ async function prepareEnv(): Promise { const startedAt = Date.now() // Prepare cache, lint and go in parallel. - const restoreCachePromise = restoreCache() + await restoreCache() const prepareLintPromise = prepareLint() const patchPromise = fetchPatch() const lintPath = await prepareLintPromise - await restoreCachePromise const patchPath = await patchPromise core.info(`Prepared env in ${Date.now() - startedAt}ms`) + return { lintPath, patchPath } } @@ -159,8 +161,10 @@ async function runLint(lintPath: string, patchPath: string): Promise { cmdArgs.cwd = path.resolve(workingDirectory) } - const cmd = `${lintPath} run ${addedArgs.join(` `)} ${userArgs}`.trimRight() + const cmd = `${lintPath} run ${addedArgs.join(` `)} ${userArgs}`.trimEnd() + core.info(`Running [${cmd}] in [${cmdArgs.cwd || ``}] ...`) + const startedAt = Date.now() try { const res = await execShellCommand(cmd, cmdArgs) diff --git a/src/version.ts b/src/version.ts index c5303d4717..aaa294697c 100644 --- a/src/version.ts +++ b/src/version.ts @@ -3,6 +3,8 @@ import * as httpm from "@actions/http-client" import * as fs from "fs" import path from "path" +import { InstallMode } from "./install" + // TODO: make a class export type Version = { major: number @@ -17,6 +19,7 @@ const parseVersion = (s: string): Version => { if (s == "latest" || s == "") { return null } + const match = s.match(versionRe) if (!match) { throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`) @@ -61,6 +64,7 @@ const isLessVersion = (a: Version, b: Version): boolean => { const getRequestedLintVersion = (): Version => { let requestedLintVersion = core.getInput(`version`) const workingDirectory = core.getInput(`working-directory`) + let goMod = "go.mod" if (workingDirectory) { goMod = path.join(workingDirectory, goMod) @@ -79,6 +83,7 @@ const getRequestedLintVersion = (): Version => { if (parsedRequestedLintVersion == null) { return null } + if (isLessVersion(parsedRequestedLintVersion, minVersion)) { throw new Error( `requested golangci-lint version '${requestedLintVersion}' isn't supported: we support only ${stringifyVersion( @@ -86,6 +91,7 @@ const getRequestedLintVersion = (): Version => { )} and later versions` ) } + return parsedRequestedLintVersion } @@ -120,9 +126,16 @@ const getConfig = async (): Promise => { } } -export async function findLintVersion(): Promise { +export async function findLintVersion(mode: InstallMode): Promise { core.info(`Finding needed golangci-lint version...`) + + if (mode == InstallMode.GoInstall) { + const v: string = core.getInput(`version`) + return { TargetVersion: v ? v : "latest", AssetURL: "github.com/golangci/golangci-lint" } + } + const reqLintVersion = getRequestedLintVersion() + // if the patched version is passed, just use it if (reqLintVersion?.major !== null && reqLintVersion?.minor != null && reqLintVersion?.patch !== null) { return new Promise((resolve) => { @@ -133,6 +146,7 @@ export async function findLintVersion(): Promise { }) }) } + const startedAt = Date.now() const config = await getConfig() @@ -155,5 +169,6 @@ export async function findLintVersion(): Promise { Date.now() - startedAt }ms` ) + return versionConfig }