-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
122 lines (90 loc) · 3.16 KB
/
Copy pathmakefile
File metadata and controls
122 lines (90 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
.PHONY: build build-prod run test coverage cover-html install db-up db-down db-clean bi fmt fmt-check tidy tidy-check vulncheck vet integration-gen integration-test bench bench-sqlite bench-pg bench-all race lint test-sqlite test-pg test-dbs ci-local index-pkg
index-pkg:
@TAG=$$(git describe --tags --abbrev=0 2>/dev/null); \
if [ -z "$$TAG" ]; then \
echo "No git tag found. Please push a tag first (e.g. git tag v0.1.0 && git push origin v0.1.0)"; \
exit 1; \
fi; \
echo "Indexing $$TAG on pkg.go.dev via proxy.golang.org..."; \
curl -s https://proxy.golang.org/github.com/voidclancy/phi/@v/$$TAG.info; \
echo ""; \
echo "Package $$TAG submitted to pkg.go.dev"
bi: build install
e2e: test integration-test
race:
go test -race ./... && cd integration && go test -race ./...
coverage:
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
cover-html: coverage
go tool cover -html=coverage.out -o coverage.html
bench:
cd benchmark && make bench && cd ..
bench-sqlite:
cd benchmark && make bench/sqlite && cd ..
bench-pg:
cd benchmark && make bench/postgres && cd ..
bench-all:
cd benchmark && make bench/all && cd ..
build:
go build -o bin/phi
build-prod:
go build -ldflags="-s -w" -o bin/phi
install: build
mkdir -p $(HOME)/go/bin
ln -sf $(shell pwd)/bin/phi $(HOME)/go/bin/phi
run:
go build -o bin/phi && ./bin/phi
test:
go test -race -v ./...
fmt:
gofmt -w .
fmt-check:
@if [ -n "$$(gofmt -l .)" ]; then \
echo "Go code is not formatted. Run: make fmt"; \
gofmt -d .; \
exit 1; \
fi
tidy:
go mod tidy
cd integration && go mod tidy
tidy-check:
go mod tidy
cd integration && go mod tidy
@git diff --exit-code go.mod go.sum integration/go.mod integration/go.sum || (echo "go.mod or go.sum is not tidy. Run: make tidy"; exit 1)
vet:
go vet ./...
cd integration && go vet ./...
lint:
$(shell go env GOPATH)/bin/golangci-lint run ./...
cd integration && $(shell go env GOPATH)/bin/golangci-lint run ./...
vulncheck:
govulncheck ./...
cd integration && govulncheck ./...
integration-gen: build
cd integration && ../bin/phi generate
integration-test: integration-gen
cd integration && go test -v ./...
db-up:
docker compose up -d
db-down:
docker compose down
db-clean:
docker compose down -v
db-reset:
docker compose exec -T db psql -U postgres -d postgres -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
test-sqlite: bi test
node integration/prepareSchema.js sqlite
cd integration && ../bin/phi -g
rm -f integration/phi/migrations/*.sql
rm -f integration/dev.db
cd integration && DATABASE_URL="file:./dev.db" DATABASE_DIRECT_URL="file:./dev.db" ../bin/phi -m init
cd integration && go test -race -tags sqlite -v ./...
test-pg: bi db-up db-reset test
node integration/prepareSchema.js postgres
cd integration && ../bin/phi -g
rm -f integration/phi/migrations/*.sql
cd integration && DATABASE_URL="postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" DATABASE_DIRECT_URL="postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable" ../bin/phi -m init
cd integration && go test -race -v ./...
test-dbs: test-sqlite test-pg
ci: bi fmt fmt-check tidy-check vet lint test vulncheck test-dbs