forked from code-golf/code-golf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
114 lines (92 loc) · 3.3 KB
/
Copy pathMakefile
File metadata and controls
114 lines (92 loc) · 3.3 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
GOFILES := $(shell find . -name '*.go' ! -path './.go*')
POSTGRES := postgres:13.5-alpine
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.17
@npm upgrade
cert:
@mkcert -install localhost
@chmod +r localhost-key.pem
.PHONY: db
db:
@ssh -t rancher@code.golf docker run -it --rm \
--env-file /etc/code-golf.env $(POSTGRES) psql
db-admin:
@ssh -t rancher@code.golf docker run -it --rm \
--env-file /etc/code-golf.env $(POSTGRES) psql -W code-golf doadmin
db-dev:
@docker-compose exec db psql -U postgres code-golf
db-diff:
@diff --color --label live --label dev --strip-trailing-cr -su \
<(ssh rancher@code.golf "docker run --rm \
--env-file /etc/code-golf.env $(POSTGRES) pg_dump -Os") \
<(docker-compose exec db pg_dump -OsU postgres code-golf)
db-dump:
@rm -f db/*.gz
@ssh rancher@code.golf "docker run --env-file /etc/code-golf.env \
--rm $(POSTGRES) sh -c 'pg_dump -a | gzip -9'" \
> db/code-golf-`date +%Y-%m-%d`.sql.gz
@cp db/*.gz ~/Dropbox/code-golf/
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 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 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
lint:
@docker run --rm -v $(CURDIR):/app -w /app \
golangci/golangci-lint:v1.43.0 golangci-lint run
live:
@docker build --pull -f docker/live.Dockerfile -t codegolf/code-golf .
@docker push codegolf/code-golf
@ssh rancher@code.golf " \
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 \
--pids-limit 1024 \
--privileged \
--publish 80:1080 \
--publish 443:1443 \
--read-only \
--restart always \
--volume certs:/certs \
codegolf/code-golf && \
docker system prune -f"
logs:
@ssh rancher@code.golf docker logs --tail 5 -f code-golf
test:
@go test ./...