Skip to content

Commit

Permalink
Merge pull request #36 from mihaitodor/enable-linting
Browse files Browse the repository at this point in the history
Enable linting and CI
  • Loading branch information
Jeffail authored Jul 12, 2021
2 parents 058073f + 4b1cb01 commit a274c3c
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 2 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test

on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x

- name: Checkout code
uses: actions/checkout@v2

- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Tidy
run: go mod tidy && git diff-index --quiet HEAD || { >&2 echo "Stale go.{mod,sum} detected. This can be fixed with 'go mod tidy'."; exit 1; }

- name: Test
run: go test -count 100 ./...

golangci-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: latest
args: --timeout 10m
39 changes: 39 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
run:
timeout: 30s

issues:
max-issues-per-linter: 0
max-same-issues: 0

linters-settings:
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style

linters:
disable-all: true
enable:
# Default linters reported by golangci-lint help linters` in v1.39.0
- deadcode
- errcheck
- gosimple
- govet
- gosimple
- ineffassign
- staticcheck
- structcheck
- stylecheck
- typecheck
- unused
- varcheck
# Extra linters:
- gofmt
- goimports
- gocritic
- revive
- bodyclose
- gosec
2 changes: 1 addition & 1 deletion tunny_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func TestTimedJobsAfterClose(t *testing.T) {
})
pool.Close()

_, act := pool.ProcessTimed(10, time.Duration(1))
_, act := pool.ProcessTimed(10, time.Duration(10*time.Millisecond))
if exp := ErrPoolNotRunning; exp != act {
t.Errorf("Wrong error returned: %v != %v", act, exp)
}
Expand Down
2 changes: 1 addition & 1 deletion worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (w *workerWrapper) run() {
case <-w.interruptChan:
w.interruptChan = make(chan struct{})
}
case _, _ = <-w.interruptChan:
case <-w.interruptChan:
w.interruptChan = make(chan struct{})
}
case <-w.closeChan:
Expand Down

0 comments on commit a274c3c

Please sign in to comment.