Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
1ef31b642a | |||
fc9d1728df | |||
1ad27ad153 | |||
1778ebaefa | |||
1dd9e0522b | |||
66883b5fcf | |||
8ea3043ee4 | |||
95f6eefffa | |||
977a01f96c | |||
13e2c1f984 |
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -24,4 +24,4 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: v1.26
|
version: v1.26
|
||||||
args: --issues-exit-code=0 ./sample/...
|
args: --issues-exit-code=0 ./sample/...
|
||||||
github-token: ${{ secrets.GOLANGCI_LINT_GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
30
README.md
30
README.md
@ -2,15 +2,14 @@
|
|||||||
|
|
||||||
[](https://github.com/golangci/golangci-lint-action/actions)
|
[](https://github.com/golangci/golangci-lint-action/actions)
|
||||||
|
|
||||||

|
It's the official GitHub action for [golangci-lint](https://github.com/golangci/golangci-lint) from it's authors.
|
||||||
|
The action runs [golangci-lint](https://github.com/golangci/golangci-lint) and reports issues from linters.
|
||||||
|
|
||||||
The action that runs [golangci-lint](https://github.com/golangci/golangci-lint) and reports issues from linters.
|

|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
1. Create a [GitHub token](https://github.com/settings/tokens/new) with scope `repo.public_repo`.
|
Add `.github/workflows/golangci-lint.yml` with the following contents:
|
||||||
2. Add it to a [repository secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#creating-encrypted-secrets): repository -> `Settings` -> `Secrets`.
|
|
||||||
3. Add `.github/workflows/golangci-lint.yml` with the following contents:
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: golangci-lint
|
name: golangci-lint
|
||||||
@ -28,7 +27,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v1
|
uses: golangci/golangci-lint-action@v0
|
||||||
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.26
|
||||||
@ -36,8 +35,11 @@ jobs:
|
|||||||
# Optional: golangci-lint command line arguments.
|
# Optional: golangci-lint command line arguments.
|
||||||
# args: ./the-only-dir-to-analyze/...
|
# args: ./the-only-dir-to-analyze/...
|
||||||
|
|
||||||
# Required: GitHub token with scope `repo.public_repo`. Used for fetching a list of releases of golangci-lint.
|
# Required: the token is used for fetching a list of releases of golangci-lint.
|
||||||
github-token: ${{ secrets.GOLANGCI_LINT_GITHUB_TOKEN }}
|
# The secret `GITHUB_TOKEN` is automatically created by GitHub,
|
||||||
|
# no need to create it manually.
|
||||||
|
# https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#about-the-github_token-secret
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Comments and Annotations
|
## Comments and Annotations
|
||||||
@ -57,6 +59,13 @@ The action was implemented with performance in mind:
|
|||||||
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, go and golangci-lint binary in parallel.
|
3. We do as much as we can in parallel, e.g. we download cache, go and golangci-lint binary in parallel.
|
||||||
|
|
||||||
|
For example, in a repository of [golangci-lint](https://github.com/golangci/golangci-lint) running this action without the cache takes 50s, but with cache takes 14s:
|
||||||
|
* in parallel:
|
||||||
|
* 13s to download Go
|
||||||
|
* 4s to restore 50 MB of cache
|
||||||
|
* 1s to find and install `golangci-lint`
|
||||||
|
* 1s to run `golangci-lint` (it takes 35s without cache)
|
||||||
|
|
||||||
## Internals
|
## Internals
|
||||||
|
|
||||||
We use JavaScript-based action. We don't use Docker-based action because:
|
We use JavaScript-based action. We don't use Docker-based action because:
|
||||||
@ -87,6 +96,5 @@ 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. Get a [GitHub token](https://github.com/settings/tokens/new) with the scope `repo.public_repo`. Export it by `export GITHUB_TOKEN=YOUR_TOKEN`.
|
3. Prepare deps once: `npm run prepare-deps`
|
||||||
4. Prepare deps once: `npm run prepare-deps`
|
4. Run `npm run local` after any change to test it
|
||||||
5. Run `npm run local` after any change to test it
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: 'Run golangci-lint'
|
name: 'Run golangci-lint'
|
||||||
description: 'Run golangci-lint (WIP)'
|
description: 'Official golangci-lint action with line-attached annotations for found issues, caching and parallel execution. Beta version.'
|
||||||
author: 'golangci'
|
author: 'golangci'
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
@ -19,5 +19,5 @@ runs:
|
|||||||
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: 'check-circle'
|
icon: 'shield'
|
||||||
color: 'blue'
|
color: 'yellow'
|
2
dist/post_run/index.js
vendored
2
dist/post_run/index.js
vendored
@ -27904,7 +27904,7 @@ function buildCacheKeys() {
|
|||||||
keys.push(cacheKey);
|
keys.push(cacheKey);
|
||||||
if (yield pathExists(`go.mod`)) {
|
if (yield pathExists(`go.mod`)) {
|
||||||
// Add checksum to key to invalidate a cache when dependencies change.
|
// Add checksum to key to invalidate a cache when dependencies change.
|
||||||
cacheKey += yield checksumFile(`cache-key`, `go.mod`);
|
cacheKey += yield checksumFile(`sha1`, `go.mod`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cacheKey += `nogomod`;
|
cacheKey += `nogomod`;
|
||||||
|
2
dist/run/index.js
vendored
2
dist/run/index.js
vendored
@ -27916,7 +27916,7 @@ function buildCacheKeys() {
|
|||||||
keys.push(cacheKey);
|
keys.push(cacheKey);
|
||||||
if (yield pathExists(`go.mod`)) {
|
if (yield pathExists(`go.mod`)) {
|
||||||
// Add checksum to key to invalidate a cache when dependencies change.
|
// Add checksum to key to invalidate a cache when dependencies change.
|
||||||
cacheKey += yield checksumFile(`cache-key`, `go.mod`);
|
cacheKey += yield checksumFile(`sha1`, `go.mod`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cacheKey += `nogomod`;
|
cacheKey += `nogomod`;
|
||||||
|
3
go.mod
Normal file
3
go.mod
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module github.com/golangci/golangci-lint-action
|
||||||
|
|
||||||
|
go 1.14
|
@ -42,7 +42,7 @@ async function buildCacheKeys(): Promise<string[]> {
|
|||||||
|
|
||||||
if (await pathExists(`go.mod`)) {
|
if (await pathExists(`go.mod`)) {
|
||||||
// Add checksum to key to invalidate a cache when dependencies change.
|
// Add checksum to key to invalidate a cache when dependencies change.
|
||||||
cacheKey += await checksumFile(`cache-key`, `go.mod`)
|
cacheKey += await checksumFile(`sha1`, `go.mod`)
|
||||||
} else {
|
} else {
|
||||||
cacheKey += `nogomod`
|
cacheKey += `nogomod`
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user