mirror of
https://github.com/golangci/golangci-lint-action.git
synced 2025-12-12 14:01:14 +00:00
Official GitHub Action for golangci-lint from its authors
| .github/workflows | ||
| dist | ||
| sample | ||
| src | ||
| static | ||
| .eslintrc.json | ||
| .gitignore | ||
| .prettierrc.json | ||
| action.yml | ||
| Dockerfile | ||
| entrypoint.sh | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
golangci-lint-action
The action that runs golangci-lint and reports issues from linters.
How to use
- Create a GitHub token with scope
repo.public_repo. - Add it to a repository secrets: repository ->
Settings->Secrets. - Add
.github/workflows/golangci-lint.ymlwith the following contents:
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
pull_request:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v1
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
# 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 }}
Comments and Annotations
Currently, GitHub parses the action's output and creates annotations.
The restrictions of annotations are the following:
- Currently, they don't support markdown formatting (see the feature request)
- They aren't shown in list of comments like it was with golangci.com. If you would like to have comments - please, up-vote the issue.
Internals
We use JavaScript-based action. We don't use Docker-based action because:
- docker pulling is slow currently
- it's easier to use caching from @actions/cache until GitHub team hasn't supported reusing actions from actions
Inside our action we perform 3 steps:
- Setup environment running in parallel:
- restore cache of previous analyzes into
$HOME/.cache/golangci-lint - list releases of golangci-lint and find the latest patch version for needed version (users of this action can specify only minor version). After that install golangci-lint using @actions/tool-cache
- install the latest Go 1.x version using @actions/setup-go
- Run
golangci-lintwith specified by userargs - Save cache from
$HOME/.cache/golangci-lintfor later builds
Development of this action
- Install act
- Make a symlink for
actto work properly:ln -s . golangci-lint-action - Get a GitHub token with the scope
repo.public_repo. Export it byexport GITHUB_TOKEN=YOUR_TOKEN. - Prepare deps once:
npm run prepare-deps - Run
npm run localafter any change to test it
