Compare commits

...

9 Commits

Author SHA1 Message Date
ca150a071d docs: fix version, @v0 doesn't work 2020-05-07 15:59:32 +03:00
1ef31b642a Merge pull request #10 from golangci/feature/fix-github-token
docs: recommend using GITHUB_TOKEN
2020-05-07 15:44:41 +03:00
fc9d1728df docs: recommend using GITHUB_TOKEN
Fixes: #9
2020-05-07 15:42:54 +03:00
1ad27ad153 s/@v1/@v0 2020-05-07 11:26:37 +03:00
1778ebaefa dev: shorten description 2020-05-05 18:17:02 +03:00
1dd9e0522b dev: improve description 2020-05-05 18:11:57 +03:00
66883b5fcf dev: change icon and color on GitHub marketplace 2020-05-05 17:57:46 +03:00
8ea3043ee4 docs: improve info about performance 2020-05-05 17:51:32 +03:00
95f6eefffa docs: add perf stat into README.md 2020-05-05 17:36:44 +03:00
3 changed files with 23 additions and 15 deletions

View File

@ -24,4 +24,4 @@ jobs:
with:
version: v1.26
args: --issues-exit-code=0 ./sample/...
github-token: ${{ secrets.GOLANGCI_LINT_GITHUB_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -2,15 +2,14 @@
[![Build Status](https://github.com/golangci/golangci-lint-action/workflows/build-and-test/badge.svg)](https://github.com/golangci/golangci-lint-action/actions)
![GitHub Annotations](./static/annotations.png)
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.
![GitHub Annotations](./static/annotations.png)
## How to use
1. Create a [GitHub token](https://github.com/settings/tokens/new) with scope `repo.public_repo`.
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:
Add `.github/workflows/golangci-lint.yml` with the following contents:
```yaml
name: golangci-lint
@ -28,7 +27,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v1
uses: golangci/golangci-lint-action@v0.1.8
with:
# 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
@ -36,8 +35,11 @@ jobs:
# Optional: golangci-lint command line arguments.
# args: ./the-only-dir-to-analyze/...
# Required: GitHub token with scope `repo.public_repo`. Used for fetching a list of releases of golangci-lint.
github-token: ${{ secrets.GOLANGCI_LINT_GITHUB_TOKEN }}
# Required: the token is used for fetching a list of releases of golangci-lint.
# 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
@ -57,6 +59,13 @@ The action was implemented with performance in mind:
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.
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
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)
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`.
4. Prepare deps once: `npm run prepare-deps`
5. Run `npm run local` after any change to test it
3. Prepare deps once: `npm run prepare-deps`
4. Run `npm run local` after any change to test it

View File

@ -1,6 +1,6 @@
---
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'
inputs:
version:
@ -19,5 +19,5 @@ runs:
main: 'dist/run/index.js'
post: 'dist/post_run/index.js'
branding:
icon: 'check-circle'
color: 'blue'
icon: 'shield'
color: 'yellow'