Compare commits

..

23 Commits

Author SHA1 Message Date
Sergey Vilgelm
809d3b078b Support latest tag for golangci-lint version (#64) 2020-08-02 11:04:32 -05:00
dependabot[bot]
b026646c83 build(deps): bump @actions/github from 2.1.1 to 4.0.0 (#45)
* build(deps): bump @actions/github from 2.1.1 to 4.0.0

Bumps [@actions/github](https://github.com/actions/toolkit/tree/HEAD/packages/github) from 2.1.1 to 4.0.0.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/master/packages/github/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/github)

Signed-off-by: dependabot[bot] <support@github.com>

* Fix usage of github action

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sergey Vilgelm <sergey.vilgelm@ibm.com>
2020-08-02 06:08:36 -05:00
Sergey Vilgelm
c598686db1 Update dist after the dependabot PRs (#62) 2020-08-01 09:09:28 -05:00
dependabot[bot]
25d72af787 build(deps): bump @actions/tool-cache from 1.5.5 to 1.6.0 (#61)
Bumps [@actions/tool-cache](https://github.com/actions/toolkit/tree/HEAD/packages/tool-cache) from 1.5.5 to 1.6.0.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/tool-cache/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/tool-cache)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-27 06:17:57 -05:00
dependabot[bot]
79f232513c build(deps-dev): bump @types/node from 14.0.23 to 14.0.26 (#60)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.0.23 to 14.0.26.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Xiang Dai <long0dai@foxmail.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-27 15:09:32 +08:00
dependabot[bot]
f7f5eff206 build(deps): bump @actions/cache from 0.2.1 to 1.0.1 (#59)
Bumps [@actions/cache](https://github.com/actions/toolkit/tree/HEAD/packages/cache) from 0.2.1 to 1.0.1.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/cache/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/@actions/io@1.0.1/packages/cache)

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Xiang Dai <long0dai@foxmail.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-27 15:08:57 +08:00
dependabot[bot]
485c6a047e build(deps-dev): bump typescript from 3.9.6 to 3.9.7 (#57)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.9.6 to 3.9.7.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v3.9.6...v3.9.7)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-27 15:08:12 +08:00
dependabot[bot]
e2ff3f296a build(deps): bump setup-go from v2.1.0 to v2.1.1 (#58)
Bumps [setup-go](https://github.com/actions/setup-go) from v2.1.0 to v2.1.1.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](1616116e1b...d0c5defdf3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-27 15:08:03 +08:00
Sergey Vilgelm
294f27a519 Update README and test action to use v1.29 (#56) 2020-07-23 11:01:52 +08:00
Sergey Vilgelm
c238b72278 Prepare v2.0.0 (#40) 2020-07-15 12:18:02 -05:00
Tam Mach
ba40dc6b1d Run the build after dependabot PRs (#54) 2020-07-15 09:15:21 +10:00
dependabot[bot]
65dc624d8b build(deps-dev): bump prettier from 1.19.1 to 2.0.5 (#52)
* build(deps-dev): bump prettier from 1.19.1 to 2.0.5

Bumps [prettier](https://github.com/prettier/prettier) from 1.19.1 to 2.0.5.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/1.19.1...2.0.5)

Signed-off-by: dependabot[bot] <support@github.com>

* Fix prettier

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sergey Vilgelm <sergey.vilgelm@ibm.com>
2020-07-14 09:25:11 -05:00
dependabot[bot]
466abb7dfd build(deps-dev): bump @typescript-eslint/parser from 2.30.0 to 2.34.0 (#53)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 2.30.0 to 2.34.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v2.34.0/packages/parser)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-14 09:10:40 -05:00
dependabot[bot]
5c7c749f16 build(deps-dev): bump typescript from 3.8.3 to 3.9.6 (#51)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.8.3 to 3.9.6.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v3.8.3...v3.9.6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-14 09:05:15 -05:00
dependabot[bot]
2f458de87f build(deps-dev): bump @types/node from 12.12.37 to 14.0.23 (#47)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 12.12.37 to 14.0.23.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-14 09:00:15 -05:00
dependabot[bot]
94d029dd63 build(deps): bump @types/semver from 7.1.0 to 7.3.1 (#48)
Bumps [@types/semver](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/semver) from 7.1.0 to 7.3.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/semver)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-14 08:57:44 -05:00
dependabot[bot]
a5502f9224 build(deps-dev): bump eslint-plugin-import from 2.20.2 to 2.22.0 (#49)
Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.20.2 to 2.22.0.
- [Release notes](https://github.com/benmosher/eslint-plugin-import/releases)
- [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md)
- [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.20.2...v2.22.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-14 08:55:26 -05:00
dependabot[bot]
fa6ef09daf build(deps-dev): bump @types/uuid from 3.4.9 to 8.0.0 (#50)
Bumps [@types/uuid](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/uuid) from 3.4.9 to 8.0.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/uuid)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-14 08:51:27 -05:00
dependabot[bot]
2effa0b58a build(deps-dev): bump @typescript-eslint/eslint-plugin (#44)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 2.30.0 to 2.34.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v2.34.0/packages/eslint-plugin)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-14 08:43:50 -05:00
dependabot[bot]
3b01eb9dce build(deps-dev): bump eslint-plugin-prettier from 3.1.3 to 3.1.4 (#43)
Bumps [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) from 3.1.3 to 3.1.4.
- [Release notes](https://github.com/prettier/eslint-plugin-prettier/releases)
- [Changelog](https://github.com/prettier/eslint-plugin-prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-plugin-prettier/compare/v3.1.3...v3.1.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-14 08:40:43 -05:00
dependabot[bot]
0d019f3dae build(deps-dev): bump @zeit/ncc from 0.20.5 to 0.22.3 (#42)
Bumps [@zeit/ncc](https://github.com/zeit/ncc) from 0.20.5 to 0.22.3.
- [Release notes](https://github.com/zeit/ncc/releases)
- [Commits](https://github.com/zeit/ncc/compare/0.20.5...0.22.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-14 08:36:34 -05:00
dependabot[bot]
48e7180822 build(deps): bump @actions/tool-cache from 1.3.4 to 1.5.5 (#46)
Bumps [@actions/tool-cache](https://github.com/actions/toolkit/tree/HEAD/packages/tool-cache) from 1.3.4 to 1.5.5.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/master/packages/tool-cache/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/tool-cache)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-14 08:30:27 -05:00
Sergey Vilgelm
8577a0ee23 Enable dependabot (#41) 2020-07-14 08:26:47 -05:00
11 changed files with 88798 additions and 48038 deletions

14
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
reviewers:
- "golangci/team"
- package-ecosystem: npm
directory: "/"
schedule:
interval: weekly
reviewers:
- "golangci/team"

View File

@@ -4,7 +4,7 @@ on: # rebuild any PRs and main branch changes
push: push:
branches: branches:
- master - master
- 'releases/*' - "releases/*"
jobs: jobs:
build: # make sure build/ci work properly build: # make sure build/ci work properly
@@ -13,7 +13,6 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: | - run: |
npm install npm install
npm run prepare-deps
npm run all npm run all
test: # make sure the action works on a clean machine without building test: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -21,6 +20,6 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ./ - uses: ./
with: with:
version: v1.28 version: latest
args: --issues-exit-code=0 ./sample/... args: --issues-exit-code=0 ./sample/...
only-new-issues: true only-new-issues: true

View File

@@ -7,6 +7,12 @@ The action runs [golangci-lint](https://github.com/golangci/golangci-lint) and r
![GitHub Annotations](./static/annotations.png) ![GitHub Annotations](./static/annotations.png)
## Compatibility
* `v2.0.0+` works with `golangci-lint` version >= `v1.28.3`
* `v1.2.2` is deprecated due to we forgot to change the minimum version of `golangci-lint` to `v1.28.3` ([issue](https://github.com/golangci/golangci-lint-action/issues/39))
* `v1.2.1` works with `golangci-lint` version >= `v1.14.0` ([issue](https://github.com/golangci/golangci-lint-action/issues/39))
## How to use ## How to use
Add `.github/workflows/golangci-lint.yml` with the following contents: Add `.github/workflows/golangci-lint.yml` with the following contents:
@@ -30,7 +36,7 @@ jobs:
uses: golangci/golangci-lint-action@v1 uses: golangci/golangci-lint-action@v1
with: with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.26 version: v1.29
# Optional: working directory, useful for monorepos # Optional: working directory, useful for monorepos
# working-directory: somedir # working-directory: somedir

View File

@@ -1,31 +1,31 @@
--- ---
name: 'Run golangci-lint' name: "Run golangci-lint"
description: 'Official golangci-lint action with line-attached annotations for found issues, caching and parallel execution.' description: "Official golangci-lint action with line-attached annotations for found issues, caching and parallel execution."
author: 'golangci' author: "golangci"
inputs: inputs:
version: version:
description: 'version of golangci-lint to use in form of v1.2' description: "version of golangci-lint to use in form of v1.2 or `latest` to use the latest version"
required: true required: false
args: args:
description: 'golangci-lint command line arguments' description: "golangci-lint command line arguments"
default: '' default: ""
required: false required: false
working-directory: working-directory:
description: 'golangci-lint working directory, default is project root' description: "golangci-lint working directory, default is project root"
required: false required: false
github-token: github-token:
description: 'the token is used for fetching patch of a pull request to show only new issues' description: "the token is used for fetching patch of a pull request to show only new issues"
default: ${{ github.token }} default: ${{ github.token }}
required: true required: true
only-new-issues: only-new-issues:
description: 'if set to true and the action runs on a pull request - the action outputs only newly found issues' description: "if set to true and the action runs on a pull request - the action outputs only newly found issues"
default: false default: false
required: true required: true
runs: runs:
using: 'node12' using: "node12"
main: 'dist/run/index.js' main: "dist/run/index.js"
post: 'dist/post_run/index.js' post: "dist/post_run/index.js"
branding: branding:
icon: 'shield' icon: "shield"
color: 'yellow' color: "yellow"

67680
dist/post_run/index.js vendored

File diff suppressed because one or more lines are too long

67696
dist/run/index.js vendored

File diff suppressed because one or more lines are too long

938
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "golanci-lint-action", "name": "golanci-lint-action",
"version": "1.1.2", "version": "2.0.0",
"private": true, "private": true,
"description": "golangci-lint github action", "description": "golangci-lint github action",
"main": "dist/main.js", "main": "dist/main.js",
@@ -15,38 +15,38 @@
"lint-fix": "eslint **/*.ts --cache --fix", "lint-fix": "eslint **/*.ts --cache --fix",
"format": "prettier --write **/*.ts", "format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts", "format-check": "prettier --check **/*.ts",
"all": "npm run build && npm run format-check && npm run lint", "all": "npm run prepare-deps && npm run build && npm run format-check && npm run lint",
"local": "npm run build && act -j test -b" "local": "npm run build && act -j test -b"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/golangci/golangci-lint-action.git" "url": "git+https://github.com/golangci/golangci-lint-action.git"
}, },
"author": "GitHub", "author": "golangci",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^1.0.1",
"@actions/core": "^1.2.0", "@actions/core": "^1.2.0",
"@actions/exec": "^1.0.1", "@actions/exec": "^1.0.1",
"@actions/github": "^2.1.1", "@actions/github": "^4.0.0",
"@actions/tool-cache": "^1.3.4", "@actions/tool-cache": "^1.6.0",
"@actions/cache": "^0.2.1", "@types/semver": "^7.3.1",
"@types/semver": "^7.1.0",
"@types/tmp": "^0.2.0", "@types/tmp": "^0.2.0",
"setup-go": "git+https://github.com/actions/setup-go.git#v2.1.0", "setup-go": "git+https://github.com/actions/setup-go.git#v2.1.1",
"tmp": "^0.2.1" "tmp": "^0.2.1"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^12.0.4", "@types/node": "^14.0.27",
"@types/uuid": "^3.4.5", "@types/uuid": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^2.7.0", "@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.7.0", "@typescript-eslint/parser": "^2.34.0",
"@zeit/ncc": "^0.20.5", "@zeit/ncc": "^0.22.3",
"eslint": "^6.6.0", "eslint": "^6.6.0",
"eslint-config-prettier": "^6.5.0", "eslint-config-prettier": "^6.5.0",
"eslint-plugin-import": "^2.18.2", "eslint-plugin-import": "^2.22.0",
"eslint-plugin-prettier": "^3.1.1", "eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-simple-import-sort": "^5.0.2", "eslint-plugin-simple-import-sort": "^5.0.2",
"prettier": "^1.19.1", "prettier": "^2.0.5",
"typescript": "^3.8.3" "typescript": "^3.9.7"
} }
} }

View File

@@ -10,8 +10,8 @@ function checksumFile(hashName: string, path: string): Promise<string> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const hash = crypto.createHash(hashName) const hash = crypto.createHash(hashName)
const stream = fs.createReadStream(path) const stream = fs.createReadStream(path)
stream.on("error", err => reject(err)) stream.on("error", (err) => reject(err))
stream.on("data", chunk => hash.update(chunk)) stream.on("data", (chunk) => hash.update(chunk))
stream.on("end", () => resolve(hash.digest("hex"))) stream.on("end", () => resolve(hash.digest("hex")))
}) })
} }

View File

@@ -39,7 +39,7 @@ async function fetchPatch(): Promise<string> {
return `` return ``
} }
const octokit = new github.GitHub(core.getInput(`github-token`, { required: true })) const octokit = github.getOctokit(core.getInput(`github-token`, { required: true }))
let patch: string let patch: string
try { try {
const patchResp = await octokit.pulls.get({ const patchResp = await octokit.pulls.get({
@@ -125,9 +125,9 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
const userArgNames = new Set<string>() const userArgNames = new Set<string>()
userArgs userArgs
.split(/\s/) .split(/\s/)
.map(arg => arg.split(`=`)[0]) .map((arg) => arg.split(`=`)[0])
.filter(arg => arg.startsWith(`-`)) .filter((arg) => arg.startsWith(`-`))
.forEach(arg => { .forEach((arg) => {
userArgNames.add(arg.replace(`-`, ``)) userArgNames.add(arg.replace(`-`, ``))
}) })

View File

@@ -6,11 +6,14 @@ export type Version = {
major: number major: number
minor: number minor: number
patch: number | null patch: number | null
} } | null
const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/ const versionRe = /^v(\d+)\.(\d+)(?:\.(\d+))?$/
const parseVersion = (s: string): Version => { const parseVersion = (s: string): Version => {
if (s == "latest" || s == "") {
return null
}
const match = s.match(versionRe) const match = s.match(versionRe)
if (!match) { if (!match) {
throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`) throw new Error(`invalid version string '${s}', expected format v1.2 or v1.2.3`)
@@ -23,33 +26,41 @@ const parseVersion = (s: string): Version => {
} }
} }
export const stringifyVersion = (v: Version): string => `v${v.major}.${v.minor}${v.patch !== null ? `.${v.patch}` : ``}` export const stringifyVersion = (v: Version): string => {
if (v == null) {
return "latest"
}
return `v${v.major}.${v.minor}${v.patch !== null ? `.${v.patch}` : ``}`
}
const minVersion = { const minVersion = {
major: 1, major: 1,
minor: 14, minor: 28,
patch: 0, patch: 3,
} }
const isLessVersion = (a: Version, b: Version): boolean => { const isLessVersion = (a: Version, b: Version): boolean => {
if (a == null) {
return true
}
if (b == null) {
return false
}
if (a.major != b.major) { if (a.major != b.major) {
return a.major < b.major return a.major < b.major
} }
if (a.minor != b.minor) { // Do not compare patch parts because if the min version has a non zero value
// then it returns false, since the patch version of requested is always zero
return a.minor < b.minor return a.minor < b.minor
} }
if (a.patch === null || b.patch === null) {
return true
}
return a.patch < b.patch
}
const getRequestedLintVersion = (): Version => { const getRequestedLintVersion = (): Version => {
const requestedLintVersion = core.getInput(`version`, { required: true }) const requestedLintVersion = core.getInput(`version`)
const parsedRequestedLintVersion = parseVersion(requestedLintVersion) const parsedRequestedLintVersion = parseVersion(requestedLintVersion)
if (parsedRequestedLintVersion == null) {
return null
}
if (parsedRequestedLintVersion.patch !== null) { if (parsedRequestedLintVersion.patch !== null) {
throw new Error( throw new Error(
`requested golangci-lint version '${requestedLintVersion}' was specified with the patch version, need specify only minor version` `requested golangci-lint version '${requestedLintVersion}' was specified with the patch version, need specify only minor version`
@@ -99,15 +110,14 @@ const getConfig = async (): Promise<Config> => {
export async function findLintVersion(): Promise<VersionConfig> { export async function findLintVersion(): Promise<VersionConfig> {
core.info(`Finding needed golangci-lint version...`) core.info(`Finding needed golangci-lint version...`)
const startedAt = Date.now() const startedAt = Date.now()
const reqLintVersion = getRequestedLintVersion()
const config = await getConfig() const config = await getConfig()
if (!config.MinorVersionToConfig) { if (!config.MinorVersionToConfig) {
core.warning(JSON.stringify(config)) core.warning(JSON.stringify(config))
throw new Error(`invalid config: no MinorVersionToConfig field`) throw new Error(`invalid config: no MinorVersionToConfig field`)
} }
const reqLintVersion = getRequestedLintVersion()
const versionConfig = config.MinorVersionToConfig[stringifyVersion(reqLintVersion)] const versionConfig = config.MinorVersionToConfig[stringifyVersion(reqLintVersion)]
if (!versionConfig) { if (!versionConfig) {
throw new Error(`requested golangci-lint version '${stringifyVersion(reqLintVersion)}' doesn't exist`) throw new Error(`requested golangci-lint version '${stringifyVersion(reqLintVersion)}' doesn't exist`)
@@ -118,8 +128,9 @@ export async function findLintVersion(): Promise<VersionConfig> {
} }
core.info( core.info(
`Requested golangci-lint '${stringifyVersion(reqLintVersion)}', using '${versionConfig.TargetVersion}', calculation took ${Date.now() - `Requested golangci-lint '${stringifyVersion(reqLintVersion)}', using '${versionConfig.TargetVersion}', calculation took ${
startedAt}ms` Date.now() - startedAt
}ms`
) )
return versionConfig return versionConfig
} }