-
Notifications
You must be signed in to change notification settings - Fork 607
chore: use makefiles #3453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: use makefiles #3453
Changes from all commits
4fdac11
cbfc389
558fb09
ab13738
ee8462d
a7c146c
b9c3eaf
26feb93
31dba4b
7303653
b0f7030
1297aa6
b091cf4
b73ecb4
a969578
119f75d
4d55f46
ba42153
7f929e8
28a7798
483979a
6b95dbf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| .PHONY: pull build down migrate-clickhouse migrate-clickhouse-reset integration generate-sql nuke-docker | ||
|
|
||
| pull: | ||
| docker compose -f ./deployment/docker-compose.yaml pull | ||
|
|
||
| build: pull | ||
| docker compose -f ./deployment/docker-compose.yaml build | ||
|
|
||
| down: | ||
| docker compose -f ./deployment/docker-compose.yaml down | ||
|
|
||
| up: down build | ||
| docker compose -f ./deployment/docker-compose.yaml up -d | ||
|
|
||
| migrate-clickhouse: | ||
| @export GOOSE_DRIVER=clickhouse && \ | ||
| export GOOSE_DBSTRING="tcp://default:password@127.0.0.1:9000" && \ | ||
| export GOOSE_MIGRATION_DIR=./internal/clickhouse/schema && \ | ||
| goose up | ||
|
Comment on lines
+16
to
+19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid hardcoded database connection strings. The ClickHouse connection string is hardcoded with credentials. Consider using environment variables or a configuration file. migrate-clickhouse:
- @export GOOSE_DRIVER=clickhouse && \
- export GOOSE_DBSTRING="tcp://default:password@127.0.0.1:9000" && \
- export GOOSE_MIGRATION_DIR=./internal/clickhouse/schema && \
- goose up
+ @export GOOSE_DRIVER=clickhouse && \
+ export GOOSE_DBSTRING="$${CLICKHOUSE_URL:-tcp://default:password@127.0.0.1:9000}" && \
+ export GOOSE_MIGRATION_DIR=./internal/clickhouse/schema && \
+ goose up🤖 Prompt for AI Agents |
||
|
|
||
| migrate-clickhouse-reset: | ||
| @export GOOSE_DRIVER=clickhouse && \ | ||
| export GOOSE_DBSTRING="tcp://default:password@127.0.0.1:9000" && \ | ||
| export GOOSE_MIGRATION_DIR=./internal/clickhouse/schema && \ | ||
| goose down-to 0 | ||
|
|
||
| integration: up | ||
| @cd apps/api && \ | ||
| $(MAKE) seed && \ | ||
| pnpm test:integration | ||
|
|
||
| generate-sql: | ||
| @cd internal/db && \ | ||
| pnpm drizzle-kit generate --dialect=mysql | ||
|
|
||
| nuke-docker: | ||
| docker stop $$(docker ps -aq) | ||
| docker system prune -af | ||
| docker volume prune --all -f | ||
|
Comment on lines
+36
to
+39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Make the nuke-docker target safer. The nuke-docker:
- docker stop $$(docker ps -aq)
- docker system prune -af
- docker volume prune --all -f
+ @echo "WARNING: This will stop ALL containers and remove ALL unused Docker data!"
+ @read -p "Are you sure? [y/N] " -n 1 -r && echo && \
+ if [[ $$REPLY =~ ^[Yy]$$ ]]; then \
+ docker stop $$(docker ps -aq) 2>/dev/null || true; \
+ docker system prune -af; \
+ docker volume prune --all -f; \
+ fi🤖 Prompt for AI Agents |
||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||||||||||||||||
| .PHONY: install fmt test build race lint generate | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
+1
to
+2
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Missing standard phony entry points (
-.PHONY: install fmt test build race lint generate
+.PHONY: all clean install fmt test build race lint generate
+
+# Default target
+all: build
+
+# Remove build artefacts
+clean:
+ @rm -f unkey📝 Committable suggestion
Suggested change
🧰 Tools🪛 checkmake (0.2.2)[warning] 1-1: Missing required phony target "all" (minphony) [warning] 1-1: Missing required phony target "clean" (minphony) 🤖 Prompt for AI Agents |
||||||||||||||||||||
| install: | ||||||||||||||||||||
| go mod tidy | ||||||||||||||||||||
|
|
||||||||||||||||||||
| fmt: lint | ||||||||||||||||||||
| go fmt ./... | ||||||||||||||||||||
|
|
||||||||||||||||||||
| test: | ||||||||||||||||||||
| go test -cover -json -failfast ./... | tparse -all -progress | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
+9
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Either vendor test: | tools
go test -cover -json -failfast ./... | tparse -all -progress
+# Ensure helpers are present
+tools:
+ go install github.com/mfridman/tparse@latest🤖 Prompt for AI Agents |
||||||||||||||||||||
| build: | ||||||||||||||||||||
| go build -o unkey ./cmd/main.go | ||||||||||||||||||||
|
|
||||||||||||||||||||
| race: | ||||||||||||||||||||
| go install github.com/amit-davidson/Chronos/cmd/chronos | ||||||||||||||||||||
| ~/go/bin/chronos --file=./cmd/main.go --mod=$$(pwd) | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
Comment on lines
+15
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Hard-coded Derive the bin path from - ~/go/bin/chronos --file=./cmd/main.go --mod=$$(pwd)
+ $$(go env GOPATH)/bin/chronos --file=./cmd/main.go --mod=$$(pwd)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| lint: | ||||||||||||||||||||
| golangci-lint run | ||||||||||||||||||||
|
|
||||||||||||||||||||
| generate: | ||||||||||||||||||||
| go get github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen | ||||||||||||||||||||
| mkdir -p ./pkg/openapi | ||||||||||||||||||||
| go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=./pkg/openapi/config.yaml ./pkg/openapi/openapi.json | ||||||||||||||||||||
| buf generate | ||||||||||||||||||||
|
Comment on lines
+22
to
+26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion
Since Go 1.20 - go get github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen
+ go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@v2.8.0🤖 Prompt for AI Agents |
||||||||||||||||||||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,34 @@ | ||||||||||||||||||||||
| .PHONY: install fmt test-unit test-full build generate lint pull build-docker | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Add standard Makefile targets for better convention compliance. Consider adding these standard targets to improve Makefile conventions: -.PHONY: install fmt test-unit test-full build generate lint pull build-docker
+.PHONY: all clean test install fmt test-unit test-full build generate lint pull build-docker
+
+all: build
+
+clean:
+ go clean
+ rm -f unkey
+
+test: test-unit📝 Committable suggestion
Suggested change
🧰 Tools🪛 checkmake (0.2.2)[warning] 1-1: Missing required phony target "all" (minphony) [warning] 1-1: Missing required phony target "clean" (minphony) [warning] 1-1: Missing required phony target "test" (minphony) 🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| install: | ||||||||||||||||||||||
| go mod tidy | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| fmt: lint | ||||||||||||||||||||||
| @go fmt ./... | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| pull: | ||||||||||||||||||||||
| docker pull mysql:latest | ||||||||||||||||||||||
| docker pull redis:latest | ||||||||||||||||||||||
| docker pull grafana/otel-lgtm:latest | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| build-docker: | ||||||||||||||||||||||
| docker build -t apiv2:latest . | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| test-full: pull build-docker | ||||||||||||||||||||||
| @export INTEGRATION_TEST=true && \ | ||||||||||||||||||||||
| export SIMULATION_TEST=false && \ | ||||||||||||||||||||||
| echo "Running full tests... this can take more than 30min... run 'make test-unit' for faster tests" && \ | ||||||||||||||||||||||
| go test -failfast -timeout=60m -shuffle=on -v -json ./... | tparse -all -progress -smallscreen | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| test-unit: | ||||||||||||||||||||||
| go test -json -race -failfast -timeout=30m ./... | tparse -all -progress -smallscreen | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| build: | ||||||||||||||||||||||
| go build -o unkey ./main.go | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| generate: | ||||||||||||||||||||||
| go generate ./... | ||||||||||||||||||||||
| # buf generate | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| lint: | ||||||||||||||||||||||
| @golangci-lint run | ||||||||||||||||||||||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add standard Makefile targets.
The static analysis correctly identifies missing standard targets. Consider adding them for better Makefile conventions.
🧰 Tools
🪛 checkmake (0.2.2)
[warning] 1-1: Missing required phony target "all"
(minphony)
[warning] 1-1: Missing required phony target "clean"
(minphony)
[warning] 1-1: Missing required phony target "test"
(minphony)
🤖 Prompt for AI Agents