Fix lint CI

This commit is contained in:
Max Claus Nunes 2022-08-08 11:40:24 -03:00
parent 90f855c72b
commit f0479bba61
5 changed files with 23 additions and 32 deletions

View File

@ -7,17 +7,16 @@ jobs:
matrix: matrix:
os: os:
- ubuntu-latest - ubuntu-latest
- macos-latest # - macos-latest
- windows-latest # - windows-latest
go: go:
- '1.19' - '1.19'
- '1.18' # - '1.18'
- '1.17' # - '1.17'
- '1.16' # - '1.16'
- '1.15' # - '1.15'
env: env:
OS: ${{ matrix.os }} OS: ${{ matrix.os }}
PYTHON: '3.7'
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
@ -26,8 +25,10 @@ jobs:
with: with:
go-version: ${{ matrix.go }} go-version: ${{ matrix.go }}
- name: Lint - name: golangci-lint
run: make setup && make lint uses: golangci/golangci-lint-action@v3
with:
version: v1.48
- name: Test - name: Test
run: make test run: make test

View File

@ -3,26 +3,14 @@ TEST_PACKAGES := $(shell go list ./... | grep -v cmd)
COVER_PACKAGES := $(shell go list ./... | grep -v cmd | paste -sd "," -) COVER_PACKAGES := $(shell go list ./... | grep -v cmd | paste -sd "," -)
LINTER := $(shell command -v gometalinter 2> /dev/null) LINTER := $(shell command -v gometalinter 2> /dev/null)
.PHONY: setup
setup:
ifndef LINTER
@echo "Installing linter"
@go get -u github.com/alecthomas/gometalinter
@gometalinter --install
endif
build: build:
@go build -o ./gaper cmd/gaper/main.go @go build -o ./gaper cmd/gaper/main.go
## lint: Validate golang code ## lint: Validate golang code
# Install it following this doc https://golangci-lint.run/usage/install/#local-installation,
# please use the same version from .github/workflows/workflow.yml.
lint: lint:
@gometalinter \ @golangci-lint run
--deadline=120s \
--line-length=120 \
--enable-all \
--disable=gochecknoinits --disable=gochecknoglobals \
--vendor ./...
test: test:
@go test -p=1 -coverpkg $(COVER_PACKAGES) \ @go test -p=1 -coverpkg $(COVER_PACKAGES) \

View File

@ -17,7 +17,6 @@ type Builder interface {
type builder struct { type builder struct {
dir string dir string
binary string binary string
errors string
wd string wd string
buildArgs []string buildArgs []string
} }

View File

@ -212,9 +212,7 @@ func setupConfig(cfg *Config) error {
var extensions []string var extensions []string
for i := range cfg.Extensions { for i := range cfg.Extensions {
values := strings.Split(cfg.Extensions[i], ",") values := strings.Split(cfg.Extensions[i], ",")
for _, e := range values { extensions = append(extensions, values...)
extensions = append(extensions, e)
}
} }
cfg.Extensions = extensions cfg.Extensions = extensions

View File

@ -104,14 +104,19 @@ func TestWatcherWatchChange(t *testing.T) {
time.Sleep(time.Millisecond * 500) time.Sleep(time.Millisecond * 500)
// update hidden files and dirs to check builtin hidden ignore is working // update hidden files and dirs to check builtin hidden ignore is working
os.Chtimes(hiddenfile1, time.Now(), time.Now()) err = os.Chtimes(hiddenfile1, time.Now(), time.Now())
os.Chtimes(hiddenfile2, time.Now(), time.Now()) assert.Nil(t, err, "chtimes error")
err = os.Chtimes(hiddenfile2, time.Now(), time.Now())
assert.Nil(t, err, "chtimes error")
// update testfile first to check ignore is working // update testfile first to check ignore is working
os.Chtimes(testfile, time.Now(), time.Now()) err = os.Chtimes(testfile, time.Now(), time.Now())
assert.Nil(t, err, "chtimes error")
time.Sleep(time.Millisecond * 500) time.Sleep(time.Millisecond * 500)
os.Chtimes(mainfile, time.Now(), time.Now()) err = os.Chtimes(mainfile, time.Now(), time.Now())
assert.Nil(t, err, "chtimes error")
select { select {
case event := <-w.Events(): case event := <-w.Events():