Compare commits
51 Commits
0ad4b72404
...
e60da84bfa
Author | SHA1 | Date | |
---|---|---|---|
|
e60da84bfa | ||
|
1dd93d052e | ||
|
5421a116d2 | ||
|
260e8cefdb | ||
|
9665fb5353 | ||
|
62530743f6 | ||
|
f71f362e47 | ||
|
7ec71f69b1 | ||
|
60c0fc4730 | ||
|
a7b658d295 | ||
|
ec5d18412c | ||
|
a0297a1378 | ||
|
58eda26a51 | ||
|
44c2434506 | ||
|
2f13b8027d | ||
|
1ac36865a6 | ||
|
9937fdf718 | ||
|
cb60b26e7a | ||
|
774c35bccc | ||
|
7ce548721e | ||
|
0e1fd32b0c | ||
|
9e66d46e22 | ||
|
1720a0ed2a | ||
|
eab1d2f3d7 | ||
|
160a1d779c | ||
|
02ee5067dc | ||
|
311e61576a | ||
|
363026db34 | ||
|
ea0c88120e | ||
|
968ad765a9 | ||
|
82fb3f49c2 | ||
|
10480e9d12 | ||
|
523baec228 | ||
|
8e06968c92 | ||
|
79a180da27 | ||
|
b92645ea9c | ||
|
3d4174dbf5 | ||
|
0ddaf3ca3f | ||
|
971e284b60 | ||
|
bbe7eb52aa | ||
|
ebae5cee81 | ||
|
06c3f3a551 | ||
|
56689d8f71 | ||
|
c7bab6f874 | ||
|
33f56cc1ef | ||
|
e9542245b2 | ||
|
68de804037 | ||
|
22a37566e1 | ||
|
cb36b7b064 | ||
|
acfc9fc846 | ||
|
1b319a7ae6 |
8
.github/workflows/codeql.yaml
vendored
8
.github/workflows/codeql.yaml
vendored
@ -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'
|
||||||
|
|
||||||
|
15
.github/workflows/test.yml
vendored
15
.github/workflows/test.yml
vendored
@ -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:
|
||||||
@ -47,13 +51,14 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
|
- ubuntu-24.04-arm
|
||||||
- macos-latest
|
- macos-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
version:
|
version:
|
||||||
- ""
|
- ""
|
||||||
- "latest"
|
- "latest"
|
||||||
- "v1.60"
|
- "v1.60" # TODO(ldez): it should be updated for v2.
|
||||||
- "v1.60.1"
|
- "v1.60.1" # TODO(ldez): it should be updated for v2.
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@ -75,13 +80,14 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
|
- ubuntu-24.04-arm
|
||||||
- macos-latest
|
- macos-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
version:
|
version:
|
||||||
- ""
|
- ""
|
||||||
- "latest"
|
- "latest"
|
||||||
- "v1.60.1"
|
- "v1.60.1" # TODO(ldez): it should be updated for v2.
|
||||||
- "adbdfdb288e939a175182b7a12b7555215ce98b2"
|
- "adbdfdb288e939a175182b7a12b7555215ce98b2" # TODO(ldez): it should be updated for v2.
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@ -104,6 +110,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
|
- ubuntu-24.04-arm
|
||||||
- macos-latest
|
- macos-latest
|
||||||
- windows-latest
|
- windows-latest
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -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
|
||||||
|
23
README.md
23
README.md
@ -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
|
||||||
|
|
||||||
@ -544,5 +544,6 @@ This scheme is basic and needs improvements. Pull requests and ideas are welcome
|
|||||||
|
|
||||||
1. Install [act](https://github.com/nektos/act#installation)
|
1. Install [act](https://github.com/nektos/act#installation)
|
||||||
2. Make a symlink for `act` to work properly: `ln -s . golangci-lint-action`
|
2. Make a symlink for `act` to work properly: `ln -s . golangci-lint-action`
|
||||||
3. Prepare deps once: `npm run prepare-deps`
|
3. Install dependencies: `npm install`
|
||||||
4. Run `npm run local` after any change to test it
|
4. Build: `npm run build`
|
||||||
|
5. Run `npm run local` after any change to test it
|
||||||
|
13338
dist/post_run/index.js
generated
vendored
13338
dist/post_run/index.js
generated
vendored
File diff suppressed because one or more lines are too long
13338
dist/run/index.js
generated
vendored
13338
dist/run/index.js
generated
vendored
File diff suppressed because one or more lines are too long
649
package-lock.json
generated
649
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
30
package.json
30
package.json
@ -24,29 +24,29 @@
|
|||||||
"author": "golangci",
|
"author": "golangci",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^3.2.4",
|
"@actions/cache": "^4.0.0",
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.11.1",
|
||||||
"@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.1",
|
"@actions/http-client": "^2.2.3",
|
||||||
"@actions/tool-cache": "^2.0.1",
|
"@actions/tool-cache": "^2.0.2",
|
||||||
"@types/node": "^22.2.0",
|
"@types/node": "^22.13.0",
|
||||||
"@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",
|
||||||
"tmp": "^0.2.3",
|
"tmp": "^0.2.3",
|
||||||
"which": "^4.0.0"
|
"which": "^5.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@typescript-eslint/eslint-plugin": "^8.1.0",
|
"@typescript-eslint/eslint-plugin": "^8.22.0",
|
||||||
"@typescript-eslint/parser": "^8.1.0",
|
"@typescript-eslint/parser": "^8.22.0",
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.38.3",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.1",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^10.0.1",
|
||||||
"eslint-plugin-import": "^2.29.1",
|
"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.3.3",
|
"prettier": "^3.4.2",
|
||||||
"typescript": "^5.5.4"
|
"typescript": "^5.7.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build tools
|
//go:build tools
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
@ -22,6 +22,9 @@ const getAssetURL = (versionConfig: VersionConfig): string => {
|
|||||||
}
|
}
|
||||||
let arch = os.arch()
|
let arch = os.arch()
|
||||||
switch (arch) {
|
switch (arch) {
|
||||||
|
case "arm64":
|
||||||
|
arch = "arm64"
|
||||||
|
break
|
||||||
case "x64":
|
case "x64":
|
||||||
arch = "amd64"
|
arch = "amd64"
|
||||||
break
|
break
|
||||||
@ -88,12 +91,14 @@ export async function goInstall(versionConfig: VersionConfig): Promise<string> {
|
|||||||
|
|
||||||
const options: ExecOptions = { env: { ...process.env, CGO_ENABLED: "1" } }
|
const options: ExecOptions = { env: { ...process.env, CGO_ENABLED: "1" } }
|
||||||
|
|
||||||
|
// TODO(ldez): it should be updated for v2.
|
||||||
const exres = await execShellCommand(
|
const exres = await execShellCommand(
|
||||||
`go install github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`,
|
`go install github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.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@${versionConfig.TargetVersion}`,
|
||||||
options
|
options
|
||||||
@ -101,7 +106,12 @@ export async function goInstall(versionConfig: VersionConfig): Promise<string> {
|
|||||||
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.trimStart().trimEnd().split(` `, 2)[1]
|
const lintPath = res.stderr
|
||||||
|
.split(/\r?\n/)
|
||||||
|
.map((v) => v.trimStart().trimEnd())
|
||||||
|
.filter((v) => v.startsWith("touch "))
|
||||||
|
.reduce((a, b) => a + b, "")
|
||||||
|
.split(` `, 2)[1]
|
||||||
|
|
||||||
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`)
|
core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`)
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
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"
|
||||||
@ -17,6 +18,7 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,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,
|
||||||
@ -113,7 +116,8 @@ const getConfig = async (): Promise<Config> => {
|
|||||||
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})`)
|
||||||
@ -131,6 +135,8 @@ export async function findLintVersion(mode: InstallMode): Promise<VersionConfig>
|
|||||||
|
|
||||||
if (mode == InstallMode.GoInstall) {
|
if (mode == InstallMode.GoInstall) {
|
||||||
const v: string = core.getInput(`version`)
|
const v: string = core.getInput(`version`)
|
||||||
|
// TODO(ldez): latest should be replaced with an explicit version (ex: v1.64.0).
|
||||||
|
// TODO(ldez): AssetURL should be updated for v2.
|
||||||
return { TargetVersion: v ? v : "latest", AssetURL: "github.com/golangci/golangci-lint" }
|
return { TargetVersion: v ? v : "latest", AssetURL: "github.com/golangci/golangci-lint" }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,10 +145,14 @@ export async function findLintVersion(mode: InstallMode): Promise<VersionConfig>
|
|||||||
// 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) {
|
if (reqLintVersion?.major !== null && reqLintVersion?.minor != null && reqLintVersion?.patch !== null) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
let arch: string = "amd64"
|
||||||
|
if (os.arch() === "arm64") {
|
||||||
|
arch = "arm64"
|
||||||
|
}
|
||||||
const versionWithoutV = `${reqLintVersion.major}.${reqLintVersion.minor}.${reqLintVersion.patch}`
|
const versionWithoutV = `${reqLintVersion.major}.${reqLintVersion.minor}.${reqLintVersion.patch}`
|
||||||
resolve({
|
resolve({
|
||||||
TargetVersion: `v${versionWithoutV}`,
|
TargetVersion: `v${versionWithoutV}`,
|
||||||
AssetURL: `https://github.com/golangci/golangci-lint/releases/download/v${versionWithoutV}/golangci-lint-${versionWithoutV}-linux-amd64.tar.gz`,
|
AssetURL: `https://github.com/golangci/golangci-lint/releases/download/v${versionWithoutV}/golangci-lint-${versionWithoutV}-linux-${arch}.tar.gz`,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user