Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update go, mods, workflow & linter #18

Merged
merged 4 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 0 additions & 53 deletions .github/workflows/go-cross.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: golangci

on:
pull_request:

jobs:

main:
name: lint
runs-on: ubuntu-latest
env:
GOLANGCI_LINT_VERSION: v1.60
CGO_ENABLED: 0

steps:
# https://github.com/marketplace/actions/checkout
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0

# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Check and get dependencies
run: |
go mod tidy
git diff --exit-code go.mod
git diff --exit-code go.sum
go mod download

# https://github.com/marketplace/actions/golangci-lint
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: "${{ env.GOLANGCI_LINT_VERSION }}"
54 changes: 0 additions & 54 deletions .github/workflows/main.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: go

on:
pull_request:

jobs:

cross:
name: test
runs-on: ${{ matrix.os }}
env:
CGO_ENABLED: 0

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
# https://github.com/marketplace/actions/checkout
- name: Checkout code
uses: actions/checkout@v4

# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Test
run: go test -v -cover ./...

32 changes: 16 additions & 16 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
run:
timeout: 2m
skip-files:
- ^unsecured/

linters-settings:
depguard:
rules:
main:
deny:
- pkg: "github.com/pkg/errors"
desc: Should be replaced by standard lib errors package
govet:
check-shadowing: true
enable-all: true
disable:
- fieldalignment
Expand All @@ -31,24 +34,18 @@ linters-settings:
linters:
enable-all: true
disable:
- maligned # Deprecated
- scopelint # Deprecated
- golint # Deprecated
- interfacer # Deprecated
- exhaustivestruct # Deprecated
- ifshort # Deprecated
- varcheck # Deprecated
- deadcode # Deprecated
- structcheck # Deprecated
- nosnakecase # Deprecated
- execinquery # Deprecated
- gomnd # Deprecated
- cyclop # duplicate of gocyclo
- rowserrcheck # SQL
- sqlclosecheck # SQL
- dupl
- lll
- nestif
- gomnd
- goerr113
- mnd
- err113
mloiseleur marked this conversation as resolved.
Show resolved Hide resolved
- tagalign
- prealloc
- wrapcheck
- nlreturn
- wsl
Expand All @@ -62,7 +59,7 @@ linters:

issues:
exclude-use-default: false
max-per-linter: 0
max-issues-per-linter: 0
max-same-issues: 0
mloiseleur marked this conversation as resolved.
Show resolved Hide resolved
exclude:
- 'ST1000: at least one file in a package should have a package comment'
Expand All @@ -74,3 +71,6 @@ issues:
- goconst
- gosec
- maintidx
- path: 'parser/element_fill.go'
linters:
- mnd
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
.PHONY: clean lint lint-fix test

export GO111MODULE=on

default: lint test

test:
Expand All @@ -11,4 +9,4 @@ lint:
golangci-lint run

lint-fix:
golangci-lint run --fix
golangci-lint run --fix
10 changes: 4 additions & 6 deletions cli/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func TestCommand_AddCommand(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -80,7 +79,7 @@ func TestCommand_PrintHelp(t *testing.T) {
Field string
}
}{},
Run: func(args []string) error {
Run: func(_ []string) error {
return nil
},
CustomHelpFunc: func(w io.Writer, _ *Command) error {
Expand All @@ -102,7 +101,6 @@ func TestCommand_PrintHelp(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -740,7 +738,7 @@ func Test_execute_configuration(t *testing.T) {
Description: "sub1",
Configuration: element,
Resources: []ResourceLoader{&FlagLoader{}},
Run: func(args []string) error {
Run: func(_ []string) error {
return nil
},
}
Expand Down Expand Up @@ -804,7 +802,7 @@ func Test_execute_configuration_file(t *testing.T) {
Description: "sub1",
Configuration: element,
Resources: []ResourceLoader{fileLoader, &FlagLoader{}},
Run: func(args []string) error {
Run: func(_ []string) error {
return nil
},
}
Expand Down Expand Up @@ -837,7 +835,7 @@ func Test_execute_help(t *testing.T) {
Name: "root",
Description: "Description for root",
Configuration: element,
Run: func(args []string) error {
Run: func(_ []string) error {
return nil
},
}
Expand Down
1 change: 0 additions & 1 deletion cli/file_finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ func TestFinder_getPaths(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
11 changes: 5 additions & 6 deletions cli/help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestPrintHelp(t *testing.T) {
Name: "root",
Description: "Description for root",
Configuration: element,
Run: func(args []string) error {
Run: func(_ []string) error {
return nil
},
}
Expand Down Expand Up @@ -85,7 +85,7 @@ Flags:
Name: "sub1",
Description: "Description for sub1",
Configuration: element,
Run: func(args []string) error {
Run: func(_ []string) error {
return nil
},
})
Expand All @@ -95,7 +95,7 @@ Flags:
Name: "sub2",
Description: "Description for sub2",
Configuration: element,
Run: func(args []string) error {
Run: func(_ []string) error {
return nil
},
})
Expand Down Expand Up @@ -149,7 +149,7 @@ Flags:
Name: "root",
Description: "Description for root",
Configuration: nil,
Run: func(args []string) error {
Run: func(_ []string) error {
return nil
},
}
Expand All @@ -173,7 +173,7 @@ Use "root [command] --help" for help on any command.
Field string
}
}{},
Run: func(args []string) error {
Run: func(_ []string) error {
return nil
},
}
Expand All @@ -197,7 +197,6 @@ Flags:
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion env/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ func TestDecode(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
Loading