-
Notifications
You must be signed in to change notification settings - Fork 67
/
Makefile
41 lines (31 loc) · 1.34 KB
/
Makefile
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
.PHONY: pgroll generate format lint examples test
pgroll:
go build
clean:
go clean
format:
# Format JSON schema
docker run --rm -v $$PWD/schema.json:/mnt/schema.json node:alpine npx prettier /mnt/schema.json --parser json --tab-width 2 --single-quote --trailing-comma all --no-semi --arrow-parens always --print-width 120 --write
# Format embedded SQL
docker run --rm -v $$PWD/pkg/state/init.sql:/mnt/init.sql node:alpine npx sql-formatter -l postgresql -o /mnt/init.sql /mnt/init.sql
generate: format
# Generate the types from the JSON schema
# Temporarily use the `surjection/go-jsonschema` image because we need https://github.com/omissis/go-jsonschema/pull/220
# Use the official `omissis/gojsonschema` image once 0.17.0 is released.
docker run --rm -v $$PWD/schema.json:/mnt/schema.json surjection/go-jsonschema:0.16.1 --only-models -p migrations --tags json /mnt/schema.json > pkg/migrations/types.go
# Add the license header
echo "// SPDX-License-Identifier: Apache-2.0" | cat - pkg/migrations/types.go > pkg/migrations/types.go.tmp
mv pkg/migrations/types.go.tmp pkg/migrations/types.go
lint:
golangci-lint --config=.golangci.yml run
ledger:
cd examples && ls > .ledger
examples: ledger
@go build
@./pgroll init
@./pgroll bootstrap examples
@go clean
test:
go test ./...
bench:
go test ./internal/benchmarks -v -benchtime=1x -bench .