Skip to content

Commit 98ea71c

Browse files
mromaszewiczclaude
andcommitted
chore/update CI for nested modules
The echo-v5 strict middleware requires Go 1.25+, which is ahead of the rest of the runtime module (Go 1.20). To support this as a separate child module, the CI and build tooling needed to become multi-module aware. - Replace four separate workflow files (ci.yml, lint.yml, tidy.yml, generate.yml) with a single ci.yml that calls the shared reusable workflow from oapi-codegen/actions v0.5.0 - Update the root Makefile to iterate child modules via git ls-files '**/*go.mod', matching the pattern used by oapi-codegen - Bump golangci-lint from v1.55.2 to v2.10.1 and update flags for v2 - Add tidy-ci target for the reusable workflow - Add strictmiddleware/echo-v5/Makefile with a Go version guard that skips gracefully when running on Go < 1.25 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 702ab91 commit 98ea71c

File tree

6 files changed

+65
-115
lines changed

6 files changed

+65
-115
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1-
name: Build project
2-
on: [ push, pull_request ]
1+
name: CI
2+
on:
3+
push: {}
4+
pull_request: {}
5+
workflow_dispatch: {}
6+
permissions:
7+
contents: read
38
jobs:
49
build:
5-
name: Build
6-
runs-on: ubuntu-latest
7-
strategy:
8-
fail-fast: false
9-
# perform matrix testing to give us an earlier insight into issues with different versions of supported major versions of Go
10-
matrix:
11-
version:
12-
- "1.20"
13-
- "1.21"
14-
- "1.22"
15-
steps:
16-
- name: Check out source code
17-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
18-
19-
- name: Set up Go
20-
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
21-
with:
22-
go-version: ${{ matrix.version }}
23-
24-
- name: Test
25-
run: make test
10+
uses: oapi-codegen/actions/.github/workflows/ci.yml@75566d848d25021f137594c947f26171094fb511 # v0.5.0
11+
with:
12+
lint_versions: '["1.25"]'

.github/workflows/generate.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/tidy.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

Makefile

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,44 @@
11
GOBASE=$(shell pwd)
22
GOBIN=$(GOBASE)/bin
33

4-
help:
5-
@echo "This is a helper makefile for oapi-codegen"
6-
@echo "Targets:"
7-
@echo " generate: regenerate all generated files"
8-
@echo " test: run all tests"
9-
@echo " gin_example generate gin example server code"
10-
@echo " tidy tidy go mod"
11-
124
$(GOBIN)/golangci-lint:
13-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.55.2
5+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v2.10.1
146

157
.PHONY: tools
168
tools: $(GOBIN)/golangci-lint
179

1810
lint: tools
11+
# run the root module explicitly, to prevent recursive calls by re-invoking `make ...` top-level
1912
$(GOBIN)/golangci-lint run ./...
13+
# then, for all child modules, use a module-managed `Makefile`
14+
git ls-files '**/*go.mod' -z | xargs -0 -I{} bash -xc 'cd $$(dirname {}) && env GOBIN=$(GOBIN) make lint'
2015

2116
lint-ci: tools
22-
$(GOBIN)/golangci-lint run ./... --out-format=github-actions --timeout=5m
17+
# for the root module, explicitly run the step, to prevent recursive calls
18+
$(GOBIN)/golangci-lint run ./... --output.text.path=stdout --timeout=5m
19+
# then, for all child modules, use a module-managed `Makefile`
20+
git ls-files '**/*go.mod' -z | xargs -0 -I{} bash -xc 'cd $$(dirname {}) && env GOBIN=$(GOBIN) make lint-ci'
2321

2422
generate:
23+
# for the root module, explicitly run the step, to prevent recursive calls
2524
go generate ./...
25+
# then, for all child modules, use a module-managed `Makefile`
26+
git ls-files '**/*go.mod' -z | xargs -0 -I{} bash -xc 'cd $$(dirname {}) && make generate'
2627

2728
test:
29+
# for the root module, explicitly run the step, to prevent recursive calls
2830
go test -cover ./...
31+
# then, for all child modules, use a module-managed `Makefile`
32+
git ls-files '**/*go.mod' -z | xargs -0 -I{} bash -xc 'cd $$(dirname {}) && make test'
2933

3034
tidy:
31-
@echo "tidy..."
35+
# for the root module, explicitly run the step, to prevent recursive calls
3236
go mod tidy
37+
# then, for all child modules, use a module-managed `Makefile`
38+
git ls-files '**/*go.mod' -z | xargs -0 -I{} bash -xc 'cd $$(dirname {}) && make tidy'
39+
40+
tidy-ci:
41+
# for the root module, explicitly run the step, to prevent recursive calls
42+
tidied -verbose
43+
# then, for all child modules, use a module-managed `Makefile`
44+
git ls-files '**/*go.mod' -z | xargs -0 -I{} bash -xc 'cd $$(dirname {}) && make tidy-ci'

strictmiddleware/echo-v5/Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
MINIMUM_GO_MINOR := 25
2+
CURRENT_GO_MINOR := $(shell go version | awk '{split($$3,a,"."); print a[2]+0}')
3+
GO_VERSION_OK := $(shell [ $(CURRENT_GO_MINOR) -ge $(MINIMUM_GO_MINOR) ] && echo yes || echo no)
4+
5+
ifeq ($(GO_VERSION_OK),yes)
6+
7+
lint:
8+
$(GOBIN)/golangci-lint run ./...
9+
10+
lint-ci:
11+
$(GOBIN)/golangci-lint run ./... --output.text.path=stdout --timeout=5m
12+
13+
generate:
14+
go generate ./...
15+
16+
test:
17+
go test -cover ./...
18+
19+
tidy:
20+
go mod tidy
21+
22+
tidy-ci:
23+
tidied -verbose
24+
25+
else
26+
27+
SKIP_MSG := @echo "Skipping echo-v5: requires Go 1.$(MINIMUM_GO_MINOR)+ (have $$(go version | awk '{print $$3}'))"
28+
29+
lint lint-ci generate test tidy tidy-ci:
30+
$(SKIP_MSG)
31+
32+
endif

0 commit comments

Comments
 (0)