Skip to content
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
52 changes: 26 additions & 26 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,44 @@ on:
- main
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ "1.23", "1.24" ]
env:
GOLANGCI_LINT_VERSION: v1.64.6
GOLANGCI_LINT_VERSION: v2.1.6

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Go
if: success()
id: install-go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

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

- name: Cache Go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download dependencies
run: go mod download
if: steps.install-go.outputs.cache-hit != 'true'

- name: Run linter
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v8
Comment thread Dismissed
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}

- name: Run tests
run: go run gotest.tools/gotestsum@latest --junitfile tests.xml --format pkgname -- -cover -race ./...
- name: Setup gotestsum
uses: gertd/action-gotestsum@v3.0.0
Comment thread Dismissed
with:
gotestsum_version: v1.12.0

- name: Run Tests
run: gotestsum --junitfile tests.xml --format pkgname -- -cover -race ./...

- name: Test Summary
uses: test-summary/action@v2
Expand Down Expand Up @@ -87,22 +91,18 @@ jobs:
GO_VERSION: "1.23"

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Go
if: success()
id: install-go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

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

- name: Cache Go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download dependencies
run: go mod download
if: steps.install-go.outputs.cache-hit != 'true'

- name: Build oapi-gen
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} GOARM=${{ matrix.arm }} go build ./cmd/oapi-gen
44 changes: 25 additions & 19 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
version: "2"
run:
tests: false
timeout: 5m

linters-settings:
cyclop:
max-complexity: 15
skip-tests: true
lll:
line-length: 160
gofumpt:
extra-rules: true
gosec:
excludes:
- G601
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
settings:
gofumpt:
extra-rules: true
exclusions:
generated: lax

linters:
enable-all: true
default: all
disable:
- gocyclo # duplicate of cyclop
- tenv # deprecated
- depguard
- err113
- exhaustive
Expand All @@ -28,16 +27,23 @@ linters:
- gochecknoglobals
- gochecknoinits
- godox
- mnd
- gomoddirectives
- intrange
- ireturn
- nlreturn
- mnd
- nilnil
- nlreturn
- nonamedreturns
- varnamelen
- wrapcheck
- wsl

issues:
exclude-use-default: false
settings:
cyclop:
max-complexity: 15
gosec:
excludes:
- G601
lll:
line-length: 160
exclusions:
generated: lax
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Format all files
fmt:
@echo "==> Formatting source"
@gofmt -s -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
@golangci-lint fmt ./...
@echo "==> Done"
.PHONY: fmt

Expand Down
2 changes: 1 addition & 1 deletion gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,6 @@ func (TestObject) Formats() map[string]string {

func (TestObject) Enums() map[string][]string {
return map[string][]string{
"test4": []string{"192.168.1.0", "192.168.1.1"},
"test4": {"192.168.1.0", "192.168.1.1"},
}
}