Skip to content

Commit 1d746b9

Browse files
authored
fix(Makefile): add dbmock to swagger deps and improve performance (#8332)
1 parent 3f058f2 commit 1d746b9

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

Makefile

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ endif
5252
FIND_EXCLUSIONS= \
5353
-not \( \( -path '*/.git/*' -o -path './build/*' -o -path './vendor/*' -o -path './.coderv2/*' -o -path '*/node_modules/*' -o -path './site/out/*' -o -path './coderd/apidoc/*' \) -prune \)
5454
# Source files used for make targets, evaluated on use.
55-
GO_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.go')
55+
GO_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.go' -not -name '*_test.go')
5656
# All the shell files in the repo, excluding ignored files.
5757
SHELL_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.sh')
5858

@@ -427,11 +427,20 @@ lint/helm:
427427
make lint
428428
.PHONY: lint/helm
429429

430+
# All files generated by the database should be added here, and this can be used
431+
# as a target for jobs that need to run after the database is generated.
432+
DB_GEN_FILES := \
433+
coderd/database/querier.go \
434+
coderd/database/unique_constraint.go \
435+
coderd/database/dbfake/dbfake.go \
436+
coderd/database/dbmetrics/dbmetrics.go \
437+
coderd/database/dbauthz/dbauthz.go \
438+
coderd/database/dbmock/dbmock.go
439+
430440
# all gen targets should be added here and to gen/mark-fresh
431441
gen: \
432442
coderd/database/dump.sql \
433-
coderd/database/querier.go \
434-
coderd/database/dbmock/dbmock.go \
443+
$(DB_GEN_FILES) \
435444
provisionersdk/proto/provisioner.pb.go \
436445
provisionerd/proto/provisionerd.pb.go \
437446
site/src/api/typesGenerated.ts \
@@ -452,8 +461,7 @@ gen: \
452461
gen/mark-fresh:
453462
files="\
454463
coderd/database/dump.sql \
455-
coderd/database/querier.go \
456-
coderd/database/dbmock/dbmock.go \
464+
$(DB_GEN_FILES) \
457465
provisionersdk/proto/provisioner.pb.go \
458466
provisionerd/proto/provisionerd.pb.go \
459467
site/src/api/typesGenerated.ts \
@@ -489,7 +497,6 @@ coderd/database/dump.sql: coderd/database/gen/dump/main.go $(wildcard coderd/dat
489497
coderd/database/querier.go: coderd/database/sqlc.yaml coderd/database/dump.sql $(wildcard coderd/database/queries/*.sql)
490498
./coderd/database/generate.sh
491499

492-
493500
coderd/database/dbmock/dbmock.go: coderd/database/db.go coderd/database/querier.go
494501
go generate ./coderd/database/dbmock/
495502

@@ -532,22 +539,22 @@ docs/admin/audit-logs.md: scripts/auditdocgen/main.go enterprise/audit/table.go
532539
cd site
533540
yarn run format:write:only ../docs/admin/audit-logs.md
534541

535-
coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen $(FIND_EXCLUSIONS) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) $(wildcard enterprise/wsproxy/wsproxysdk/*.go) coderd/database/querier.go .swaggo docs/manifest.json coderd/rbac/object_gen.go
542+
coderd/apidoc/swagger.json: $(shell find ./scripts/apidocgen $(FIND_EXCLUSIONS) -type f) $(wildcard coderd/*.go) $(wildcard enterprise/coderd/*.go) $(wildcard codersdk/*.go) $(wildcard enterprise/wsproxy/wsproxysdk/*.go) $(DB_GEN_FILES) .swaggo docs/manifest.json coderd/rbac/object_gen.go
536543
./scripts/apidocgen/generate.sh
537544
yarn run --cwd=site format:write:only ../docs/api ../docs/manifest.json ../coderd/apidoc/swagger.json
538545

539546
update-golden-files: cli/testdata/.gen-golden helm/tests/testdata/.gen-golden scripts/ci-report/testdata/.gen-golden enterprise/cli/testdata/.gen-golden
540547
.PHONY: update-golden-files
541548

542-
cli/testdata/.gen-golden: $(wildcard cli/testdata/*.golden) $(wildcard cli/*.tpl) $(GO_SRC_FILES)
549+
cli/testdata/.gen-golden: $(wildcard cli/testdata/*.golden) $(wildcard cli/*.tpl) $(GO_SRC_FILES) $(wildcard cli/*_test.go)
543550
go test ./cli -run="Test(CommandHelp|ServerYAML)" -update
544551
touch "$@"
545552

546-
enterprise/cli/testdata/.gen-golden: $(wildcard enterprise/cli/testdata/*.golden) $(wildcard cli/*.tpl) $(GO_SRC_FILES)
553+
enterprise/cli/testdata/.gen-golden: $(wildcard enterprise/cli/testdata/*.golden) $(wildcard cli/*.tpl) $(GO_SRC_FILES) $(wildcard enterprise/cli/*_test.go)
547554
go test ./enterprise/cli -run="TestEnterpriseCommandHelp" -update
548555
touch "$@"
549556

550-
helm/tests/testdata/.gen-golden: $(wildcard helm/tests/testdata/*.yaml) $(wildcard helm/tests/testdata/*.golden) $(GO_SRC_FILES)
557+
helm/tests/testdata/.gen-golden: $(wildcard helm/tests/testdata/*.yaml) $(wildcard helm/tests/testdata/*.golden) $(GO_SRC_FILES) $(wildcard helm/tests/*_test.go)
551558
go test ./helm/tests -run=TestUpdateGoldenFiles -update
552559
touch "$@"
553560

0 commit comments

Comments
 (0)