golangci-lint-action

module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2020 License: MIT

README

golangci-lint-action

Build Status

GitHub Annotations

The action that runs golangci-lint and reports issues from linters.

How to use

  1. Create a GitHub token with scope repo.public_repo.
  2. Add it to a repository secrets: repository -> Settings -> Secrets.
  3. Add .github/workflows/golangci-lint.yml with 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:

  1. Currently, they don't support markdown formatting (see the feature request)
  2. 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:

  1. docker pulling is slow currently
  2. 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:

  1. Setup environment running in parallel:
  1. Run golangci-lint with specified by user args
  2. Save cache from $HOME/.cache/golangci-lint for later builds

Development of this action

  1. Install act
  2. Make a symlink for act to work properly: ln -s . golangci-lint-action
  3. Get a GitHub token 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

Directories

Path Synopsis
Package sample is used as test input for golangci action.
Package sample is used as test input for golangci action.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL