forked from code-golf/code-golf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
119 lines (95 loc) · 3.64 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
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
DATE := $(shell date +%Y-%m-%d)
GOFILES := $(shell find . -name '*.go' ! -path './.go*')
SHELL := /bin/bash
export COMPOSE_PATH_SEPARATOR=:
export COMPOSE_FILE=docker/core.yml:docker/dev.yml
bench:
@go test -bench B -benchmem ./...
bump:
@go get -u
@go mod tidy -compat=1.23
@npm upgrade
cert:
@mkcert -install localhost
@chmod +r localhost-key.pem
.PHONY: db
db:
@ssh -t [email protected] sudo -iu postgres psql code-golf
db-dev:
@docker compose exec db psql -U postgres code-golf
db-diff:
@diff --color --label live --label dev --strip-trailing-cr -su \
<(ssh [email protected] sudo -iu postgres pg_dump -Os code-golf \
| sed -E 's/ \(Debian .+//') \
<(docker compose exec -T db pg_dump -OsU postgres code-golf)
db-dump:
@rm -f sql/*.gz
@ssh [email protected] sudo -iu postgres pg_dump -aZ9 code-golf \
> sql/code-golf-$(DATE).sql.gz
@zcat sql/*.gz | zstd -fqo ~/Dropbox/code-golf/code-golf-$(DATE).sql.zst
dev:
@touch docker/.env
@docker compose rm -f
@docker compose up --build
# e2e-iterate is useful when you have made a small change to test code only
# and want to re-run. Note that logs are not automatically shown when tests
# fail, because they make it harder to see test results and this target isn't
# used by CI.
e2e-iterate: export COMPOSE_FILE=docker/core.yml:docker/e2e.yml
e2e-iterate: export COMPOSE_PROJECT_NAME=code-golf-e2e
e2e-iterate:
@docker compose run --rm e2e
e2e: export COMPOSE_FILE=docker/core.yml:docker/e2e.yml
e2e: export COMPOSE_PROJECT_NAME=code-golf-e2e
e2e:
# TODO Pass arguments to run specific tests.
@./esbuild
@touch docker/.env
@docker compose rm -fsv &>/dev/null
@docker compose build --pull -q
@docker compose run --rm e2e || (docker compose logs; false)
@docker compose rm -fsv &>/dev/null
fmt:
@gofmt -s -w $(GOFILES)
@goimports -w $(GOFILES)
font:
@docker build -t code-golf-font -f docker/font.Dockerfile docker
@id=`docker create code-golf-font`; \
docker cp "$$id:twemoji-colr/build/Twemoji Mozilla.woff2" fonts/twemoji.woff2; \
docker rm $$id
mathjax-fonts:
@rm -rf public/mathjax-fonts
@cp -r node_modules/mathjax/es5/output/chtml/fonts/woff-v2 public/mathjax-fonts
lint:
@docker run --rm -v $(CURDIR):/app -w /app \
golangci/golangci-lint:v1.61.0 golangci-lint run
@node_modules/.bin/eslint js
live:
@docker buildx build --pull --push \
--file docker/live.Dockerfile --tag codegolf/code-golf .
@ssh [email protected] " \
docker pull codegolf/code-golf && \
docker stop code-golf; \
docker rm code-golf; \
docker run \
--detach \
--env-file /etc/code-golf.env \
--init \
--name code-golf \
--network caddy \
--pids-limit 1024 \
--privileged \
--read-only \
--restart always \
--volume /var/run/postgresql:/var/run/postgresql \
codegolf/code-golf && \
docker system prune -f"
logs:
@ssh [email protected] docker logs --tail 5 -f code-golf
svgo:
@node_modules/.bin/svgo -f views/svg
test:
@go test ./...
.PHONY: xt
xt:
@prove6 xt