From f0479bba61f1b4e09257d83399389691594a7d71 Mon Sep 17 00:00:00 2001 From: Max Claus Nunes Date: Mon, 8 Aug 2022 11:40:24 -0300 Subject: [PATCH] Fix lint CI --- .github/workflows/workflow.yml | 19 ++++++++++--------- Makefile | 18 +++--------------- builder.go | 1 - gaper.go | 4 +--- watcher_test.go | 13 +++++++++---- 5 files changed, 23 insertions(+), 32 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 6962292..796423d 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -7,17 +7,16 @@ jobs: matrix: os: - ubuntu-latest - - macos-latest - - windows-latest + # - macos-latest + # - windows-latest go: - '1.19' - - '1.18' - - '1.17' - - '1.16' - - '1.15' + # - '1.18' + # - '1.17' + # - '1.16' + # - '1.15' env: OS: ${{ matrix.os }} - PYTHON: '3.7' steps: - uses: actions/checkout@master @@ -26,8 +25,10 @@ jobs: with: go-version: ${{ matrix.go }} - - name: Lint - run: make setup && make lint + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.48 - name: Test run: make test diff --git a/Makefile b/Makefile index 4db7679..c2d45e3 100644 --- a/Makefile +++ b/Makefile @@ -3,26 +3,14 @@ TEST_PACKAGES := $(shell go list ./... | grep -v cmd) COVER_PACKAGES := $(shell go list ./... | grep -v cmd | paste -sd "," -) 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: @go build -o ./gaper cmd/gaper/main.go ## 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: - @gometalinter \ - --deadline=120s \ - --line-length=120 \ - --enable-all \ - --disable=gochecknoinits --disable=gochecknoglobals \ - --vendor ./... + @golangci-lint run test: @go test -p=1 -coverpkg $(COVER_PACKAGES) \ diff --git a/builder.go b/builder.go index e5e2be7..3117138 100644 --- a/builder.go +++ b/builder.go @@ -17,7 +17,6 @@ type Builder interface { type builder struct { dir string binary string - errors string wd string buildArgs []string } diff --git a/gaper.go b/gaper.go index d2200fb..6409720 100644 --- a/gaper.go +++ b/gaper.go @@ -212,9 +212,7 @@ func setupConfig(cfg *Config) error { var extensions []string for i := range cfg.Extensions { values := strings.Split(cfg.Extensions[i], ",") - for _, e := range values { - extensions = append(extensions, e) - } + extensions = append(extensions, values...) } cfg.Extensions = extensions diff --git a/watcher_test.go b/watcher_test.go index 9aaa556..975974f 100644 --- a/watcher_test.go +++ b/watcher_test.go @@ -104,14 +104,19 @@ func TestWatcherWatchChange(t *testing.T) { time.Sleep(time.Millisecond * 500) // update hidden files and dirs to check builtin hidden ignore is working - os.Chtimes(hiddenfile1, time.Now(), time.Now()) - os.Chtimes(hiddenfile2, time.Now(), time.Now()) + err = os.Chtimes(hiddenfile1, 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 - 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) - os.Chtimes(mainfile, time.Now(), time.Now()) + err = os.Chtimes(mainfile, time.Now(), time.Now()) + assert.Nil(t, err, "chtimes error") select { case event := <-w.Events():