Skip to content

Commit effdcb9

Browse files
committed
chore: improved mono-repo management
This PR prepares the forthcoming release. We need to tidy up a little bit the way the mono-repo setup is handled. This starts by embracing `go.work`. Content ======= * added go.work declaration * ci: adapted go tests to go.work. This should dramatically reduce the number of test jobs. At this moment, we still lint go modules in independent jobs. * ci: fixed issue with go mod caching * fix: dependabot not being able to update nested modules * updated stretchr/testify dependency (because dependabot didn't succeed doing so previously) * removed replace directives from top-level module. We still to keep the replace directives in sub-modules. These will disappear when we cut the next release. * doc (updated TODO items list) adapter tagger script to go.work Signed-off-by: Frederic BIDON <[email protected]>
1 parent f344ab5 commit effdcb9

File tree

25 files changed

+134
-54
lines changed

25 files changed

+134
-54
lines changed

.github/dependabot.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ updates:
77
interval: "weekly"
88
day: "friday"
99
open-pull-requests-limit: 2 # <- default is 5
10+
allow:
11+
- dependency-type: all
1012
groups: # <- group all github actions updates in a single PR
1113
# 1. development-dependencies are auto-merged
1214
development-dependencies:

.github/workflows/go-test.yml

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ jobs:
2828
# NOTES:
2929
#
3030
# > * git bash on a windows runner should support GNU find. find flags should be supported by find on macos.
31-
# > * We don't attempt any tricks with the go work command. Perhaps this will be the official way in future go releases.
32-
# > * There is no simple way to get the expected result with go list, unless all submodules are dependencies of the
33-
# root module (which is not a requirement).
31+
# > * with go.work file enabled, we may now collect all submodules with go list -m
32+
# >
33+
# > The outcome is currently only used for linting. Tests may now skip that part.
3434
set -euxo pipefail
3535
3636
root="$(git rev-parse --show-toplevel)"
@@ -49,7 +49,7 @@ jobs:
4949
printf " \"${base_dir}\"" >> "$GITHUB_OUTPUT"
5050
all_mods+=("${base_dir}")
5151
((index++)) || true
52-
done < <(find . -name go.mod | grep -v "\.git" | sort | uniq)
52+
done < <(go list -f '{{.Dir}}' -m)
5353
printf "]" >> "$GITHUB_OUTPUT"
5454
5555
echo "::notice title=Modules found::${all_mods[@]}"
@@ -78,6 +78,7 @@ jobs:
7878
version: latest
7979
only-new-issues: true
8080
skip-cache: true
81+
# golangci-lint doesn't support go.work to lint multiple modules in one single pass
8182
working-directory: '${{ matrix.module }}'
8283

8384
lint:
@@ -98,29 +99,41 @@ jobs:
9899
matrix:
99100
os: [ ubuntu-latest, macos-latest, windows-latest ]
100101
go_version: ['oldstable', 'stable' ]
101-
module: ${{ fromJSON(needs.module-matrix.outputs.modules) }}
102102

103103
steps:
104+
- uses: actions/checkout@v5
105+
#- name: Ensure cache is available
106+
# run: |
107+
# mkdir -p /home/runner/go/pkg/mod
108+
# mkdir -p /home/runner/.cache/go.build
104109
- uses: actions/setup-go@v6
105110
with:
106111
go-version: '${{ matrix.go_version }}'
107112
check-latest: true
108113
cache: true
109114
cache-dependency-path: '**/go.sum'
110115

111-
- uses: actions/checkout@v5
112-
- name: Run unit tests on a single module in this repo
116+
- name: Run unit tests on all modules in this repo
113117
shell: bash
114-
working-directory: '${{ matrix.module }}'
115-
run: |
118+
env:
116119
# *.coverage.* pattern is automatically detected by codecov
117-
COVER_PROFILE="$(basename ${{ matrix.module }}).coverage.${{ matrix.os }}.${{ matrix.go_version }}.out"
118-
if [[ "${{ matrix.module }}" == "jsonutils/adapters/testintegration" ]] ; then
119-
# integration tests capture coverage elsewhere
120-
go test -v -race -coverprofile="${COVER_PROFILE}" -covermode=atomic -coverpkg=../../../... ./...
121-
exit 0
120+
COVER_PROFILE: 'all_modules.coverage.${{ matrix.os }}.${{ matrix.go_version }}.out'
121+
run: |
122+
declare -a ALL_MODULES
123+
BASH_MAJOR=$(echo $BASH_VERSION|cut -d'.' -f1)
124+
if [[ "${BASH_MAJOR}" -ge 4 ]] ; then
125+
mapfile ALL_MODULES < <(go list -f '{{.Dir}}/...' -m)
126+
else
127+
# for older bash versions, e.g. on macOS runner. This fallback will eventually disappear.
128+
while read line ; do
129+
ALL_MODULES+=("${line}")
130+
done < <(go list -f '{{.Dir}}/...' -m)
122131
fi
123-
go test -v -race -coverprofile="${COVER_PROFILE}" -covermode=atomic -coverpkg=$(go list)/... ./...
132+
echo "::notice title=Modules found::${ALL_MODULES[@]}"
133+
134+
# with go.work file enabled, go test recognizes sub-modules and collects all packages to be covered
135+
# without specifying -coverpkg.
136+
go test -v -race -coverprofile="${COVER_PROFILE}" -covermode=atomic ${ALL_MODULES[@]}
124137
125138
- name: Upload coverage to codecov
126139
uses: codecov/codecov-action@v5

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@ All kinds of contributions are welcome.
166166
A few ideas:
167167

168168
* [x] Complete the split of dependencies to isolate easyjson from the rest
169+
* [x] Improve CI to reduce needed tests
169170
* [ ] Improve mangling utilities (improve readability, support for capitalized words,
170171
better word substitution for non-letter symbols...)
171172
* [ ] Move back to this common shared pot a few of the technical features introduced by go-swagger independently
172173
(e.g. mangle go package names, search package with go modules support, ...)
173174
* [ ] Apply a similar mono-repo approach to go-openapi/strfmt which suffer from similar woes: bloated API,
174175
imposed dependency to some database driver.
175176
* [ ] Adapt `go-swagger` (incl. generated code) to the new `swag` API.
176-
* [ ] Improve CI to reduce needed tests
177177
* [ ] Replace dependency to `gopkg.in/yaml.v3` (`yamlutil`)
178178
* [ ] Factorize some tests, as there is a lot of redundant testing code in `jsonutils`
179179

TODO.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* benchmark & profiling
2+
* more thorough testing for nil / null case
3+
* ci pipeline to manage releases
4+
* cleaner mockery generation (doesn't work out of the box for multi-modules)

conv/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/go-openapi/swag/conv
22

33
require (
44
github.com/go-openapi/swag/typeutils v0.0.0-00010101000000-000000000000
5-
github.com/stretchr/testify v1.10.0
5+
github.com/stretchr/testify v1.11.1
66
)
77

88
require (

conv/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
88
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
99
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1010
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
11-
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
12-
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
11+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
12+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
1313
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1414
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
1515
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

fileutils/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/go-openapi/swag/fileutils
22

3-
require github.com/stretchr/testify v1.10.0
3+
require github.com/stretchr/testify v1.11.1
44

55
require (
66
github.com/davecgh/go-spew v1.1.1 // indirect

fileutils/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
99
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
1010
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1111
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
12-
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
13-
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
12+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
13+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
1414
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1515
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
1616
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

go.mod

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,10 @@ require (
1919

2020
require (
2121
github.com/davecgh/go-spew v1.1.1 // indirect
22+
github.com/josharian/intern v1.0.0 // indirect
23+
github.com/mailru/easyjson v0.9.0 // indirect
2224
github.com/pmezard/go-difflib v1.0.0 // indirect
2325
gopkg.in/yaml.v3 v3.0.1 // indirect
2426
)
2527

26-
replace (
27-
github.com/go-openapi/swag/cmdutils => ./cmdutils
28-
github.com/go-openapi/swag/conv => ./conv
29-
github.com/go-openapi/swag/fileutils => ./fileutils
30-
github.com/go-openapi/swag/jsonname => ./jsonname
31-
github.com/go-openapi/swag/jsonutils => ./jsonutils
32-
github.com/go-openapi/swag/jsonutils/fixtures_test => ./jsonutils/fixtures_test
33-
github.com/go-openapi/swag/loading => ./loading
34-
github.com/go-openapi/swag/mangling => ./mangling
35-
github.com/go-openapi/swag/netutils => ./netutils
36-
github.com/go-openapi/swag/stringutils => ./stringutils
37-
github.com/go-openapi/swag/typeutils => ./typeutils
38-
github.com/go-openapi/swag/yamlutils => ./yamlutils
39-
)
40-
4128
go 1.24.0

go.sum

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
11
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
22
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/go-openapi/swag/cmdutils v0.24.0 h1:KlRCffHwXFI6E5MV9n8o8zBRElpY4uK4yWyAMWETo9I=
4+
github.com/go-openapi/swag/cmdutils v0.24.0/go.mod h1:uxib2FAeQMByyHomTlsP8h1TtPd54Msu2ZDU/H5Vuf8=
5+
github.com/go-openapi/swag/conv v0.24.0 h1:ejB9+7yogkWly6pnruRX45D1/6J+ZxRu92YFivx54ik=
6+
github.com/go-openapi/swag/conv v0.24.0/go.mod h1:jbn140mZd7EW2g8a8Y5bwm8/Wy1slLySQQ0ND6DPc2c=
7+
github.com/go-openapi/swag/fileutils v0.24.0 h1:U9pCpqp4RUytnD689Ek/N1d2N/a//XCeqoH508H5oak=
8+
github.com/go-openapi/swag/fileutils v0.24.0/go.mod h1:3SCrCSBHyP1/N+3oErQ1gP+OX1GV2QYFSnrTbzwli90=
9+
github.com/go-openapi/swag/jsonname v0.24.0 h1:2wKS9bgRV/xB8c62Qg16w4AUiIrqqiniJFtZGi3dg5k=
10+
github.com/go-openapi/swag/jsonname v0.24.0/go.mod h1:GXqrPzGJe611P7LG4QB9JKPtUZ7flE4DOVechNaDd7Q=
11+
github.com/go-openapi/swag/jsonutils v0.24.0 h1:F1vE1q4pg1xtO3HTyJYRmEuJ4jmIp2iZ30bzW5XgZts=
12+
github.com/go-openapi/swag/jsonutils v0.24.0/go.mod h1:vBowZtF5Z4DDApIoxcIVfR8v0l9oq5PpYRUuteVu6f0=
13+
github.com/go-openapi/swag/loading v0.24.0 h1:ln/fWTwJp2Zkj5DdaX4JPiddFC5CHQpvaBKycOlceYc=
14+
github.com/go-openapi/swag/loading v0.24.0/go.mod h1:gShCN4woKZYIxPxbfbyHgjXAhO61m88tmjy0lp/LkJk=
15+
github.com/go-openapi/swag/mangling v0.24.0 h1:PGOQpViCOUroIeak/Uj/sjGAq9LADS3mOyjznmHy2pk=
16+
github.com/go-openapi/swag/mangling v0.24.0/go.mod h1:Jm5Go9LHkycsz0wfoaBDkdc4CkpuSnIEf62brzyCbhc=
17+
github.com/go-openapi/swag/netutils v0.24.0 h1:Bz02HRjYv8046Ycg/w80q3g9QCWeIqTvlyOjQPDjD8w=
18+
github.com/go-openapi/swag/netutils v0.24.0/go.mod h1:WRgiHcYTnx+IqfMCtu0hy9oOaPR0HnPbmArSRN1SkZM=
19+
github.com/go-openapi/swag/stringutils v0.24.0 h1:i4Z/Jawf9EvXOLUbT97O0HbPUja18VdBxeadyAqS1FM=
20+
github.com/go-openapi/swag/stringutils v0.24.0/go.mod h1:5nUXB4xA0kw2df5PRipZDslPJgJut+NjL7D25zPZ/4w=
21+
github.com/go-openapi/swag/typeutils v0.24.0 h1:d3szEGzGDf4L2y1gYOSSLeK6h46F+zibnEas2Jm/wIw=
22+
github.com/go-openapi/swag/typeutils v0.24.0/go.mod h1:q8C3Kmk/vh2VhpCLaoR2MVWOGP8y7Jc8l82qCTd1DYI=
23+
github.com/go-openapi/swag/yamlutils v0.24.0 h1:bhw4894A7Iw6ne+639hsBNRHg9iZg/ISrOVr+sJGp4c=
24+
github.com/go-openapi/swag/yamlutils v0.24.0/go.mod h1:DpKv5aYuaGm/sULePoeiG8uwMpZSfReo1HR3Ik0yaG8=
25+
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
26+
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
327
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
428
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
529
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
630
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
31+
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
32+
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
733
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
834
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
935
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=

0 commit comments

Comments
 (0)