Skip to content

Commit 77c9f96

Browse files
authored
Dev (#370)
* delete go loop copy vars * discriminator and mapping updates * handler panic for rendering * utility handler fn extraction * extension grouping * update golangcilint * update styles * remove e2e ci * correct path for local pnpm * pnpm v update * column * update test os * fix wrong paths * lint
1 parent 5d14948 commit 77c9f96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+886
-452
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
export GOBIN=$PWD/bin/tools
55
export PATH=$GOBIN:$PATH
66
export PATH=$GOBIN/bin:$PATH
7+
export PATH=$PWD/bin/tools/bin:$PATH
78
export PATH=$PWD/bin:$PATH
89
export PATH=$PWD/bin/build:$PATH
910

.github/actions/setup/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ runs:
2828

2929
- uses: pnpm/action-setup@v2
3030
with:
31-
version: 8.3.1
31+
version: 9.12.0
3232
run_install: false
3333

3434
- name: Setup pnpm cache (1)

.github/workflows/tests.yaml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
jobs:
1717
run:
1818
timeout-minutes: 60
19-
runs-on: ubuntu-20.04
19+
runs-on: ubuntu-24.04
2020
steps:
2121
- uses: actions/checkout@v3
2222
with:
@@ -89,15 +89,6 @@ jobs:
8989
9090
project e2e.run
9191
92-
- uses: actions/upload-artifact@v3
93-
if: always()
94-
with:
95-
name: playwright-report
96-
path: e2e/playwright-report/
97-
retention-days: 5
98-
# TODO: reuse actions/setup:
99-
# https://stackoverflow.com/questions/65242830/in-a-github-actions-workflow-is-there-a-way-to-have-multiple-jobs-reuse-the-sam
100-
# https://github.com/kmadof/github-actions-manual/blob/main/.github/actions/say-hello/action.yml
10192
10293
- name: Build frontend
10394
run: |

.golangci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# https://github.com/MarioCarrion/todo-api-microservice-example/blob/main/.golangci.yml
2-
run:
3-
skip-files: # ignore yaml error...
4-
- ".*\\.xo\\.go$"
5-
- ".*\\.gen\\.go$"
6-
- ".*\\.pb\\.go$"
2+
# yaml-language-server: $schema=https://raw.githubusercontent.com/golangci/golangci-lint/refs/tags/v1.63.4/jsonschema/golangci.jsonschema.json
3+
74
linters:
85
enable-all: true
96
disable:
@@ -65,7 +62,6 @@ linters-settings:
6562
json: goCamel
6663
yaml: goCamel
6764
staticcheck:
68-
go: "1.22"
6965
checks:
7066
- "all"
7167
gci:
@@ -117,6 +113,10 @@ linters-settings:
117113
ignorePackageGlobs:
118114
- github.com/danicc097/openapi-go-gin-postgres-sqlc/*
119115
issues:
116+
exclude-files:
117+
- ".*\\.xo\\.go$"
118+
- ".*\\.gen\\.go$"
119+
- ".*\\.pb\\.go$"
120120
exclude-rules:
121121
- path: "internal/testutil/*" # doesn't work with internal/... for some reason
122122
linters:

bin/.project.dependencies.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ install.bin.column() {
5252
cp .libs/column ../bin/tools/
5353
cd ..
5454
rm -rf util-linux-2.*
55-
column --version
55+
column --version || column -v
5656
} 2>&4 | xlog >&3; } 4>&1 | xerr >&3; } 3>&1
5757
}
5858

bin/project

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ x.install-tools() {
285285
commands=(
286286
"go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@v4.15.2"
287287
"go install github.com/sqlc-dev/sqlc/cmd/sqlc@v1.24.0"
288-
"go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2"
288+
"go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.63.4"
289289
"go install github.com/tufin/oasdiff@v1.10.9"
290290
"go install golang.org/x/tools/cmd/goimports@latest"
291291
"go install mvdan.cc/gofumpt@latest"
@@ -1250,14 +1250,19 @@ x.lint.go() {
12501250
# golangci-lint run --config=.golangci.yml --allow-parallel-runners --fast --fix &>/dev/null || true
12511251
}
12521252

1253-
exhaustruct_lint() {
1253+
exhaustive_lint() {
12541254
local lint_config=$(
12551255
cat <<EOF
12561256
linters:
12571257
disable-all: true
12581258
enable:
12591259
- exhaustruct
1260+
- exhaustive
12601261
linters-settings:
1262+
exhaustive:
1263+
explicit-exhaustive-switch: true
1264+
explicit-exhaustive-map: true
1265+
default-case-required: true
12611266
exhaustruct:
12621267
# lint struct usage in all packages that use them
12631268
include:
@@ -1359,7 +1364,7 @@ x.test.backend.setup() {
13591364
x.test.backend() {
13601365
xsetup.backup
13611366
{ { {
1362-
exhaustruct_lint
1367+
exhaustive_lint
13631368

13641369
x.test.xo
13651370

bin/templates/crud-api-tests.go.tmpl.bash

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ $(test -n "$with_project" && echo " pj := models.ProjectNameDemo
5656
},
5757
}
5858
for _, tc := range tests {
59-
tc := tc
6059
t.Run(tc.name, func(t *testing.T) {
6160
t.Parallel()
6261
ufixture := ff.CreateUser(context.Background(), servicetestutil.CreateUserParams{
@@ -217,7 +216,6 @@ done)
217216
// },
218217
}
219218
for _, tc := range tests {
220-
tc := tc
221219
t.Run(tc.name, func(t *testing.T) {
222220
t.Parallel()
223221

bin/templates/crud-api.go.tmpl.bash

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ $(test -n "$with_project" && echo " params.ProjectID = internal.ProjectIDByName[
1818
${camel_name}, err := h.svc.${pascal_name}.Create(c, tx, &params)
1919
if err != nil {
2020
renderErrorResponse(c, "Could not create ${sentence_name}", err)
21-
22-
return nil, nil
2321
}
2422
2523
res := ${pascal_name}Response{
@@ -36,8 +34,6 @@ func (h *StrictHandlers) Get${pascal_name}(c *gin.Context, request Get${pascal_n
3634
${camel_name}, err := h.svc.${pascal_name}.ByID(c, tx, request.${pascal_name}ID)
3735
if err != nil {
3836
renderErrorResponse(c, "Could not create ${sentence_name}", err)
39-
40-
return nil, nil
4137
}
4238
4339
res := ${pascal_name}Response{
@@ -56,8 +52,6 @@ func (h *StrictHandlers) Update${pascal_name}(c *gin.Context, request Update${pa
5652
${camel_name}, err := h.svc.${pascal_name}.Update(c, tx, request.${pascal_name}ID, &params)
5753
if err != nil {
5854
renderErrorResponse(c, "Could not update ${sentence_name}", err)
59-
60-
return nil, nil
6155
}
6256
6357
res := ${pascal_name}Response{
@@ -74,8 +68,6 @@ func (h *StrictHandlers) Delete${pascal_name}(c *gin.Context, request Delete${pa
7468
_, err := h.svc.${pascal_name}.Delete(c, tx, request.${pascal_name}ID)
7569
if err != nil {
7670
renderErrorResponse(c, "Could not delete ${sentence_name}", err)
77-
78-
return nil, nil
7971
}
8072
8173
return Delete${pascal_name}204Response{}, nil

bin/templates/crud-repo-tests.go.tmpl.bash

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ $(test -n "$with_project" && echo " projectID := internal.ProjectIDByName[models
5858
},
5959
}
6060
for _, tc := range tests {
61-
tc := tc
6261
t.Run(tc.name, func(t *testing.T) {
6362
t.Parallel()
6463
@@ -112,7 +111,6 @@ func Test${pascal_name}_${delete_method}(t *testing.T) {
112111
},
113112
}
114113
for _, tc := range tests {
115-
tc := tc
116114
t.Run(tc.name, func(t *testing.T) {
117115
t.Parallel()
118116
@@ -154,7 +152,6 @@ func Test${pascal_name}_ByIndexedQueries(t *testing.T) {
154152
},
155153
}
156154
for _, tc := range uniqueTestCases {
157-
tc := tc
158155
runGenericFilterTests(t, tc)
159156
}
160157
}

bin/templates/crud-service-tests.go.tmpl.bash

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ done)
8282
}
8383
8484
for _, tc := range tests {
85-
tc := tc
8685
t.Run(tc.name, func(t *testing.T) {
8786
t.Parallel()
8887

0 commit comments

Comments
 (0)