-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathjustfile
More file actions
80 lines (60 loc) · 1.98 KB
/
justfile
File metadata and controls
80 lines (60 loc) · 1.98 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
dbname := "pgledger"
psql:
docker compose exec postgres env PGPASSWORD={{ dbname }} psql -U {{ dbname }} {{ dbname }}
dbversion:
docker compose exec postgres env PGPASSWORD={{ dbname }} psql -U {{ dbname }} {{ dbname }} -c 'select version();'
dbclean:
docker compose exec postgres dropdb --force -U {{ dbname }} {{ dbname }} || echo "db doesn't exist"
docker compose exec postgres createdb -U {{ dbname }} {{ dbname }}
dbload:
docker compose exec --no-TTY postgres psql \
-U {{ dbname }} \
--single-transaction \
-f /code/vendor/scoville-pgsql-ulid/ulid-to-uuid.sql \
-f /code/vendor/scoville-pgsql-ulid/uuid-to-ulid.sql \
-f /code/pgledger.sql \
{{ dbname }}
dbreset: dbclean dbload
clean:
cd go && go clean -testcache
tidy:
cd go && go mod tidy
test:
cd go && go test -v ./...
benchmark:
cd go/test && go test -bench=. -benchtime=10s
performance_check duration='10s':
cd go && go run performance_check.go --duration {{ duration }}
lint: deadcode lint-sql golangci-lint
deadcode:
#!/usr/bin/env bash
set -euo pipefail
out=$(cd go && go tool deadcode -test ./...)
echo "$out"
if [[ $? != 0 ]]; then
exit $?
elif [[ $out ]]; then
echo "Failing due to deadcode output"
exit 1
else
echo "No dead code"
fi
golangci-lint:
cd go && golangci-lint run --verbose
lint-sql:
uvx sqlfluff@4.0.0 lint --verbose
format-sql:
uvx sqlfluff@4.0.0 format
check: dbreset clean tidy format-sql test lint
run-examples: dbreset
#!/usr/bin/env bash
set -euo pipefail
for file in $(ls examples/*.sql); do
out="${file}.out"
echo '-- This file contains the sql queries plus their output, but we set the filetype to sql for better syntax highlighting' > $out
echo "-- vim: set filetype=sql:" >> $out
echo >> $out
cat "$file" | \
docker compose exec --no-TTY postgres psql -U pgledger --echo-all --no-psqlrc \
>> $out 2>&1
done