Using Github Actions with Golangci-linter
- go github golang
Github delivered a beta Github Actions, it’s a worflow that can run almost anything related to your code, like a CI/CD.
Here is a workflow for Go 1.13 module projects and golangci-lint.
name: golangci-lint
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Install golangci-lint
run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.18.0
- name: Run golangci-lint
run: $(go env GOPATH)/bin/golangci-lint run
This file should be placed in your repo under .github/workflows/golangci-lint.yml
but the action web editor will do it for you.
And the usual badge you can put in your README.md
[![Lint Status](https://github.com/myusername/myrepo/workflows/golangci-lint/badge.svg)](https://github.com/myusername/myrepo/actions)
Also remember you can tune golangci-lint
by placing a file at the root of your repo like:
run:
# default concurrency is a available CPU number
concurrency: 4
# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 2m
skip-files:
- gen.go
# modules-download-mode: vendor
linters:
disable:
- errcheck
- gochecknoglobals
- dupl
presets:
- bugs
- unused
- complexity
- style
Note: The worflow name part of the badge url is case sensitive ;)