Skip to content

Commit

Permalink
github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
a-menshchikov committed Jul 23, 2024
1 parent 27f5d4b commit 64a2620
Show file tree
Hide file tree
Showing 6 changed files with 283 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: golangci-lint
on:
push:
branches:
- main
pull_request:

permissions:
contents: read
pull-requests: read

env:
GO_VERSION: stable
GOLANGCI_LINT_VERSION: v1.59

jobs:
detect-modules:
runs-on: ubuntu-latest
outputs:
modules: ${{ steps.set-modules.outputs.modules }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- id: set-modules
run: echo "modules=$(go list -m -json | jq -s '.' | jq -c '[.[].Dir]')" >> $GITHUB_OUTPUT

golangci:
name: lint
needs: detect-modules
runs-on: ubuntu-latest
strategy:
matrix:
modules: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: golangci-lint ${{ matrix.modules }}
uses: golangci/golangci-lint-action@v6
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
working-directory: ${{ matrix.modules }}

gotest:
name: tests
needs: detect-modules
runs-on: ubuntu-latest
strategy:
matrix:
modules: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Test with the Go CLI
run: go test -race ${{ matrix.modules }}/...
69 changes: 69 additions & 0 deletions closer/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
output:
formats:
- format: colored-line-number
print-issued-lines: true
print-linter-name: true

linters-settings:
gocognit:
min-complexity: 10
goconst:
min-len: 2
min-occurrences: 2
gosec:
excludes:
# _ instead of err checks
- G104
govet:
enable-all: true
nakedret:
max-func-lines: 10
nolintlint:
require-specific: true
prealloc:
range-loops: true
revive:
rules:
- name: unexported-return
disabled: true
staticcheck:
# SA5001: Allow to ignore returned error before deferring *.Close()
checks: ["all", "-SA5001"]

linters:
disable-all: true
enable:
- bodyclose
- errcheck
- errorlint
- exportloopref
- gocheckcompilerdirectives
- gocognit
- goconst
- goimports
- gosec
- gosimple
- govet
- ineffassign
- makezero
- mnd
- nakedret
- noctx
- nolintlint
- nosprintfhostport
- prealloc
- revive
- staticcheck
- tenv
- testpackage
- typecheck
- unconvert
- unused
- wastedassign

issues:
exclude-rules:
- path: '(.+)_test\.go'
linters:
- fieldalignment
- gocognit
72 changes: 72 additions & 0 deletions ctxkey/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
output:
formats:
- format: colored-line-number
print-issued-lines: true
print-linter-name: true

linters-settings:
gocognit:
min-complexity: 10
goconst:
min-len: 2
min-occurrences: 2
gosec:
excludes:
# _ instead of err checks
- G104
govet:
enable-all: true
nakedret:
max-func-lines: 10
nolintlint:
require-specific: true
prealloc:
range-loops: true
revive:
rules:
- name: unexported-return
disabled: true
staticcheck:
# SA5001: Allow to ignore returned error before deferring *.Close()
checks: ["all", "-SA5001"]

linters:
disable-all: true
enable:
- bodyclose
- errcheck
- errorlint
- exportloopref
- gocheckcompilerdirectives
- gocognit
- goconst
- goimports
- gosec
- gosimple
- govet
- ineffassign
- makezero
- mnd
- nakedret
- noctx
- nolintlint
- nosprintfhostport
- prealloc
- revive
- staticcheck
- tenv
- testpackage
- typecheck
- unconvert
- unused
- wastedassign

issues:
exclude-rules:
- path: 'ctxkey\.go'
linters:
- goimports
- path: '(.+)_test\.go'
linters:
- fieldalignment
- gocognit
7 changes: 7 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
go 1.20

use (
./closer
./ctxkey
./time
)
4 changes: 4 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
69 changes: 69 additions & 0 deletions time/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
output:
formats:
- format: colored-line-number
print-issued-lines: true
print-linter-name: true

linters-settings:
gocognit:
min-complexity: 10
goconst:
min-len: 2
min-occurrences: 2
gosec:
excludes:
# _ instead of err checks
- G104
govet:
enable-all: true
nakedret:
max-func-lines: 10
nolintlint:
require-specific: true
prealloc:
range-loops: true
revive:
rules:
- name: unexported-return
disabled: true
staticcheck:
# SA5001: Allow to ignore returned error before deferring *.Close()
checks: ["all", "-SA5001"]

linters:
disable-all: true
enable:
- bodyclose
- errcheck
- errorlint
- exportloopref
- gocheckcompilerdirectives
- gocognit
- goconst
- goimports
- gosec
- gosimple
- govet
- ineffassign
- makezero
- mnd
- nakedret
- noctx
- nolintlint
- nosprintfhostport
- prealloc
- revive
- staticcheck
- tenv
- testpackage
- typecheck
- unconvert
- unused
- wastedassign

issues:
exclude-rules:
- path: '(.+)_test\.go'
linters:
- fieldalignment
- gocognit

0 comments on commit 64a2620

Please sign in to comment.