Skip to content
Merged

Dev #370

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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
export GOBIN=$PWD/bin/tools
export PATH=$GOBIN:$PATH
export PATH=$GOBIN/bin:$PATH
export PATH=$PWD/bin/tools/bin:$PATH
export PATH=$PWD/bin:$PATH
export PATH=$PWD/bin/build:$PATH

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ runs:

- uses: pnpm/action-setup@v2
with:
version: 8.3.1
version: 9.12.0
run_install: false

- name: Setup pnpm cache (1)
Expand Down
11 changes: 1 addition & 10 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
jobs:
run:
timeout-minutes: 60
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -89,15 +89,6 @@ jobs:

project e2e.run

- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: e2e/playwright-report/
retention-days: 5
# TODO: reuse actions/setup:
# https://stackoverflow.com/questions/65242830/in-a-github-actions-workflow-is-there-a-way-to-have-multiple-jobs-reuse-the-sam
# https://github.com/kmadof/github-actions-manual/blob/main/.github/actions/say-hello/action.yml

- name: Build frontend
run: |
Expand Down
12 changes: 6 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# https://github.com/MarioCarrion/todo-api-microservice-example/blob/main/.golangci.yml
run:
skip-files: # ignore yaml error...
- ".*\\.xo\\.go$"
- ".*\\.gen\\.go$"
- ".*\\.pb\\.go$"
# yaml-language-server: $schema=https://raw.githubusercontent.com/golangci/golangci-lint/refs/tags/v1.63.4/jsonschema/golangci.jsonschema.json

linters:
enable-all: true
disable:
Expand Down Expand Up @@ -65,7 +62,6 @@ linters-settings:
json: goCamel
yaml: goCamel
staticcheck:
go: "1.22"
checks:
- "all"
gci:
Expand Down Expand Up @@ -117,6 +113,10 @@ linters-settings:
ignorePackageGlobs:
- github.com/danicc097/openapi-go-gin-postgres-sqlc/*
issues:
exclude-files:
- ".*\\.xo\\.go$"
- ".*\\.gen\\.go$"
- ".*\\.pb\\.go$"
exclude-rules:
- path: "internal/testutil/*" # doesn't work with internal/... for some reason
linters:
Expand Down
2 changes: 1 addition & 1 deletion bin/.project.dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ install.bin.column() {
cp .libs/column ../bin/tools/
cd ..
rm -rf util-linux-2.*
column --version
column --version || column -v
} 2>&4 | xlog >&3; } 4>&1 | xerr >&3; } 3>&1
}

Expand Down
11 changes: 8 additions & 3 deletions bin/project
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ x.install-tools() {
commands=(
"go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@v4.15.2"
"go install github.com/sqlc-dev/sqlc/cmd/sqlc@v1.24.0"
"go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2"
"go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.63.4"
"go install github.com/tufin/oasdiff@v1.10.9"
"go install golang.org/x/tools/cmd/goimports@latest"
"go install mvdan.cc/gofumpt@latest"
Expand Down Expand Up @@ -1250,14 +1250,19 @@ x.lint.go() {
# golangci-lint run --config=.golangci.yml --allow-parallel-runners --fast --fix &>/dev/null || true
}

exhaustruct_lint() {
exhaustive_lint() {
local lint_config=$(
cat <<EOF
linters:
disable-all: true
enable:
- exhaustruct
- exhaustive
linters-settings:
exhaustive:
explicit-exhaustive-switch: true
explicit-exhaustive-map: true
default-case-required: true
exhaustruct:
# lint struct usage in all packages that use them
include:
Expand Down Expand Up @@ -1359,7 +1364,7 @@ x.test.backend.setup() {
x.test.backend() {
xsetup.backup
{ { {
exhaustruct_lint
exhaustive_lint

x.test.xo

Expand Down
2 changes: 0 additions & 2 deletions bin/templates/crud-api-tests.go.tmpl.bash
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ $(test -n "$with_project" && echo " pj := models.ProjectNameDemo
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
ufixture := ff.CreateUser(context.Background(), servicetestutil.CreateUserParams{
Expand Down Expand Up @@ -217,7 +216,6 @@ done)
// },
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
8 changes: 0 additions & 8 deletions bin/templates/crud-api.go.tmpl.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ $(test -n "$with_project" && echo " params.ProjectID = internal.ProjectIDByName[
${camel_name}, err := h.svc.${pascal_name}.Create(c, tx, &params)
if err != nil {
renderErrorResponse(c, "Could not create ${sentence_name}", err)

return nil, nil
}

res := ${pascal_name}Response{
Expand All @@ -36,8 +34,6 @@ func (h *StrictHandlers) Get${pascal_name}(c *gin.Context, request Get${pascal_n
${camel_name}, err := h.svc.${pascal_name}.ByID(c, tx, request.${pascal_name}ID)
if err != nil {
renderErrorResponse(c, "Could not create ${sentence_name}", err)

return nil, nil
}

res := ${pascal_name}Response{
Expand All @@ -56,8 +52,6 @@ func (h *StrictHandlers) Update${pascal_name}(c *gin.Context, request Update${pa
${camel_name}, err := h.svc.${pascal_name}.Update(c, tx, request.${pascal_name}ID, &params)
if err != nil {
renderErrorResponse(c, "Could not update ${sentence_name}", err)

return nil, nil
}

res := ${pascal_name}Response{
Expand All @@ -74,8 +68,6 @@ func (h *StrictHandlers) Delete${pascal_name}(c *gin.Context, request Delete${pa
_, err := h.svc.${pascal_name}.Delete(c, tx, request.${pascal_name}ID)
if err != nil {
renderErrorResponse(c, "Could not delete ${sentence_name}", err)

return nil, nil
}

return Delete${pascal_name}204Response{}, nil
Expand Down
3 changes: 0 additions & 3 deletions bin/templates/crud-repo-tests.go.tmpl.bash
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ $(test -n "$with_project" && echo " projectID := internal.ProjectIDByName[models
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -112,7 +111,6 @@ func Test${pascal_name}_${delete_method}(t *testing.T) {
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -154,7 +152,6 @@ func Test${pascal_name}_ByIndexedQueries(t *testing.T) {
},
}
for _, tc := range uniqueTestCases {
tc := tc
runGenericFilterTests(t, tc)
}
}
Expand Down
1 change: 0 additions & 1 deletion bin/templates/crud-service-tests.go.tmpl.bash
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ done)
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
10 changes: 10 additions & 0 deletions cmd/oapi-codegen/oapi-templates/strict/strict-gin.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ func (sh *strictHandlers) authMiddlewares(opID OperationID) []gin.HandlerFunc {
{{$opid := .OperationId}}
// {{$opid}} operation middleware
func (sh *strictHandlers) {{.OperationId}}(ctx *gin.Context{{genParamArgs .PathParams}}{{if .RequiresParamObject}}, params externalRef0.{{.OperationId}}Params{{end}}) {
defer func() {
if r := recover(); r != nil {
// handler() may panic to notify early handler exit
if _, ok := r.(*HandlerExitError); !ok {
panic(r)
}
// swallow panic, assume error response was rendered already to gin context
}
}()

var request {{$opid | ucFirst}}RequestObject

{{range .PathParams -}}
Expand Down
18 changes: 0 additions & 18 deletions db/migrations/0000001_audit.up.sql

This file was deleted.

38 changes: 38 additions & 0 deletions db/migrations/0000001_extension.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
create schema if not exists extensions;

-- make sure everybody can use everything in the extensions schema
grant usage on schema extensions to public;

grant execute on all functions in schema extensions to public;

-- include future extensions
alter default privileges in schema extensions grant execute on functions to public;

alter default privileges in schema extensions grant usage on types to public;

create extension if not exists plpgsql_check schema extensions;

create extension if not exists "uuid-ossp" schema extensions;

-- https://github.com/supabase/supa_audit
-- not available in supabase itself, rather pgaudit
do $$
begin
create extension if not exists supa_audit schema extensions;
exception
when others then
raise notice 'supa_audit extension not available';
end
$$;

create extension if not exists pg_stat_statements schema extensions;

create extension if not exists hypopg schema extensions;

create extension if not exists index_advisor schema extensions;

create extension if not exists pg_trgm schema extensions;

create extension if not exists btree_gin schema extensions;

create extension if not exists rum schema extensions;
23 changes: 6 additions & 17 deletions db/migrations/0000002_init.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@ create schema if not exists v;

create schema if not exists "cache";

create extension if not exists pg_stat_statements schema extensions;

create extension if not exists hypopg schema extensions;

create extension if not exists index_advisor schema extensions;

create extension if not exists pg_trgm schema extensions;

create extension if not exists btree_gin schema extensions;

create extension if not exists rum schema extensions;

-- alter database postgres_test set timezone to 'America/New_York';
create or replace function jsonb_set_deep (target jsonb , path text[] , val jsonb)
returns jsonb
Expand Down Expand Up @@ -846,18 +834,19 @@ create trigger sync_user_projects
--
-- audit
--
/*
select
audit.enable_tracking ('public.kanban_steps');
audit.enable_tracking ('public.kanban_steps');

select
audit.enable_tracking ('public.projects');
audit.enable_tracking ('public.projects');

select
audit.enable_tracking ('public.teams');
audit.enable_tracking ('public.teams');

select
audit.enable_tracking ('public.work_items');

audit.enable_tracking ('public.work_items');
*/
----
create or replace function project_exists (project_name text)
returns boolean
Expand Down
Loading
Loading