dev: use golangci-lint action (#1066)
This commit is contained in:
parent
01b726a048
commit
38782dd097
17
.github/workflows/pr.yml
vendored
17
.github/workflows/pr.yml
vendored
@ -1,5 +1,5 @@
|
||||
---
|
||||
name: PR build
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
@ -8,7 +8,20 @@ on:
|
||||
- master
|
||||
pull_request:
|
||||
jobs:
|
||||
# We already run the current golangci-lint in tests, but here we test
|
||||
# our GitHub action with the latest stable golangci-lint.
|
||||
golangci-lint:
|
||||
name: golangci-lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: lint
|
||||
uses: golangci/golangci-lint-action@v0.1.3
|
||||
with:
|
||||
version: v1.26
|
||||
github-token: ${{ secrets.GOLANGCI_LINT_TOKEN }}
|
||||
tests-on-windows:
|
||||
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
matrix:
|
||||
@ -25,6 +38,7 @@ jobs:
|
||||
run: make.exe test
|
||||
continue-on-error: true
|
||||
tests-on-unix:
|
||||
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
@ -49,6 +63,7 @@ jobs:
|
||||
- name: Run tests on Unix-like operating systems
|
||||
run: make test
|
||||
check_generated:
|
||||
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
@ -23,6 +23,8 @@ run:
|
||||
# can use regexp here: generated.*, regexp is applied on full path;
|
||||
# default value is empty list, but default dirs are skipped independently
|
||||
# from this option's value (see skip-dirs-use-default).
|
||||
# "/" will be replaced by current OS file path separator to properly work
|
||||
# on Windows.
|
||||
skip-dirs:
|
||||
- src/external_libs
|
||||
- autogenerated_by_my_lib
|
||||
@ -35,6 +37,8 @@ run:
|
||||
# won't be reported. Default value is empty list, but there is
|
||||
# no need to include all autogenerated files, we confidently recognize
|
||||
# autogenerated files. If it's not please let us know.
|
||||
# "/" will be replaced by current OS file path separator to properly work
|
||||
# on Windows.
|
||||
skip-files:
|
||||
- ".*\\.my\\.go$"
|
||||
- lib/bad.go
|
||||
|
@ -103,11 +103,17 @@ linters:
|
||||
- whitespace
|
||||
|
||||
# don't enable:
|
||||
# - asciicheck
|
||||
# - gochecknoglobals
|
||||
# - gocognit
|
||||
# - godot
|
||||
# - godox
|
||||
# - goerr113
|
||||
# - maligned
|
||||
# - nestif
|
||||
# - prealloc
|
||||
# - testpackage
|
||||
# - wsl
|
||||
|
||||
issues:
|
||||
# Excluding configuration per-path, per-linter, per-text and per-source
|
||||
|
17
README.md
17
README.md
@ -1,7 +1,6 @@
|
||||
# GolangCI-Lint
|
||||
|
||||
[](https://travis-ci.com/golangci/golangci-lint)
|
||||
[](https://golangci.com)
|
||||

|
||||
[](/LICENSE)
|
||||
[](https://github.com/golangci/golangci-lint/releases/latest)
|
||||
[](https://hub.docker.com/r/golangci/golangci-lint)
|
||||
@ -44,6 +43,10 @@ Sponsored by [GolangCI.com](https://golangci.com): SaaS service for running lint
|
||||
- [Configuration](#configuration)
|
||||
- [Command-Line Options](#command-line-options)
|
||||
- [Config File](#config-file)
|
||||
- [Custom Linters](#custom-linters)
|
||||
- [Create a Copy of `golangci-lint` that Can Run with Plugins](#create-a-copy-of-golangci-lint-that-can-run-with-plugins)
|
||||
- [Configure Your Project for Linting](#configure-your-project-for-linting)
|
||||
- [To Create Your Own Custom Linter](#to-create-your-own-custom-linter)
|
||||
- [False Positives](#false-positives)
|
||||
- [Nolint](#nolint)
|
||||
- [FAQ](#faq)
|
||||
@ -646,6 +649,8 @@ run:
|
||||
# can use regexp here: generated.*, regexp is applied on full path;
|
||||
# default value is empty list, but default dirs are skipped independently
|
||||
# from this option's value (see skip-dirs-use-default).
|
||||
# "/" will be replaced by current OS file path separator to properly work
|
||||
# on Windows.
|
||||
skip-dirs:
|
||||
- src/external_libs
|
||||
- autogenerated_by_my_lib
|
||||
@ -658,6 +663,8 @@ run:
|
||||
# won't be reported. Default value is empty list, but there is
|
||||
# no need to include all autogenerated files, we confidently recognize
|
||||
# autogenerated files. If it's not please let us know.
|
||||
# "/" will be replaced by current OS file path separator to properly work
|
||||
# on Windows.
|
||||
skip-files:
|
||||
- ".*\\.my\\.go$"
|
||||
- lib/bad.go
|
||||
@ -1104,11 +1111,17 @@ linters:
|
||||
- whitespace
|
||||
|
||||
# don't enable:
|
||||
# - asciicheck
|
||||
# - gochecknoglobals
|
||||
# - gocognit
|
||||
# - godot
|
||||
# - godox
|
||||
# - goerr113
|
||||
# - maligned
|
||||
# - nestif
|
||||
# - prealloc
|
||||
# - testpackage
|
||||
# - wsl
|
||||
|
||||
issues:
|
||||
# Excluding configuration per-path, per-linter, per-text and per-source
|
||||
|
@ -1,7 +1,6 @@
|
||||
# GolangCI-Lint
|
||||
|
||||
[](https://travis-ci.com/golangci/golangci-lint)
|
||||
[](https://golangci.com)
|
||||

|
||||
[](/LICENSE)
|
||||
[](https://github.com/golangci/golangci-lint/releases/latest)
|
||||
[](https://hub.docker.com/r/golangci/golangci-lint)
|
||||
@ -44,6 +43,10 @@ Sponsored by [GolangCI.com](https://golangci.com): SaaS service for running lint
|
||||
- [Configuration](#configuration)
|
||||
- [Command-Line Options](#command-line-options)
|
||||
- [Config File](#config-file)
|
||||
- [Custom Linters](#custom-linters)
|
||||
- [Create a Copy of `golangci-lint` that Can Run with Plugins](#create-a-copy-of-golangci-lint-that-can-run-with-plugins)
|
||||
- [Configure Your Project for Linting](#configure-your-project-for-linting)
|
||||
- [To Create Your Own Custom Linter](#to-create-your-own-custom-linter)
|
||||
- [False Positives](#false-positives)
|
||||
- [Nolint](#nolint)
|
||||
- [FAQ](#faq)
|
||||
|
1
go.sum
1
go.sum
@ -266,6 +266,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM
|
||||
github.com/spf13/viper v1.6.1 h1:VPZzIkznI1YhVMRi6vNFLHSwhnhReBfgTxIPccpfdZk=
|
||||
github.com/spf13/viper v1.6.1/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
|
@ -31,6 +31,7 @@ const goFileSuffix = ".go"
|
||||
func NewSkipDirs(patterns []string, log logutils.Log, runArgs []string) (*SkipDirs, error) {
|
||||
var patternsRe []*regexp.Regexp
|
||||
for _, p := range patterns {
|
||||
p = normalizePathInRegex(p)
|
||||
patternRe, err := regexp.Compile(p)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "can't compile regexp %q", p)
|
||||
|
@ -16,6 +16,7 @@ var _ Processor = SkipFiles{}
|
||||
func NewSkipFiles(patterns []string) (*SkipFiles, error) {
|
||||
var patternsRe []*regexp.Regexp
|
||||
for _, p := range patterns {
|
||||
p = normalizePathInRegex(p)
|
||||
patternRe, err := regexp.Compile(p)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't compile regexp %q: %s", p, err)
|
||||
|
@ -1,6 +1,10 @@
|
||||
package processors
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/golangci/golangci-lint/pkg/result"
|
||||
@ -44,3 +48,15 @@ func transformIssues(issues []result.Issue, transform func(i *result.Issue) *res
|
||||
|
||||
return retIssues
|
||||
}
|
||||
|
||||
var separatorToReplace = regexp.QuoteMeta(string(filepath.Separator))
|
||||
|
||||
func normalizePathInRegex(path string) string {
|
||||
if filepath.Separator == '/' {
|
||||
return path
|
||||
}
|
||||
|
||||
// This replacing should be safe because "/" are disallowed in Windows
|
||||
// https://docs.microsoft.com/ru-ru/windows/win32/fileio/naming-a-file
|
||||
return strings.ReplaceAll(path, "/", separatorToReplace)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user