forked from AbdelStark/deathnote-contributions-feeder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
253 lines (187 loc) · 8.46 KB
/
Makefile
File metadata and controls
253 lines (187 loc) · 8.46 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
ROOT_DIR := $(shell basename $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
RUST_VERSION := $(shell sed -n 's/^ *channel.*=.*"\([^"]*\)".*/\1/p' rust-toolchain.toml)
REMOTE_DB_OWNER_APP := od-hasura-develop
.DEFAULT_GOAL := help
# ----------------------------------------------------------
# Utils
# ----------------------------------------------------------
# Prints the list of available commands
help:
@echo "Available commands:"
@awk '/^# -+/{getline; sub(/^#[ ]+/, ""); section=$$0 "\n\n"; getline;} /^# /{sub(/^# /, ""); desc=$$0; getline; if ($$0 ~ /^[a-zA-Z0-9].*\/.*[^$#\\t=]*:([^=]|$$)|help|install/) {sub(/:.*/, ""); printf "%s%s %-30s %s\n", (section != "" ? "\n" : ""), section, $$0, desc; section=""; getline}}' Makefile
# Setups the dev whole dev environment
install: install/all docker/re db/up hasura/start-refresh-stop
# ----------------------------------------------------------
# Tools installation
# ----------------------------------------------------------
# Install the desired Rust version
rust/install:
rustup install $(RUST_VERSION)
diesel/install: rust/install
cargo install diesel_cli
# ----------------------------------------------------------
# Dependencies installation
# ----------------------------------------------------------
.env:
@cp .env.example .env
# Install all the dependencies
install/all: .env rust/install frontend/install hasura/install playwright/install
node_modules:
yarn
# ----------------------------------------------------------
# Full stack
# ----------------------------------------------------------
# Spins up the full stack in background
app/background-start: docker/up backend/background-start frontend/background-start
# Stops the background full stack, if running
app/background-stop: backend/background-stop frontend/background-stop
# ----------------------------------------------------------
# Docker stack
# ----------------------------------------------------------
# Spins up the docker stack
docker/up:
docker compose up -d --wait
# Removes all the docker stack including volumes (!)
docker/clean:
docker compose down -v
# Removes the docker stack, the playwright fixtures, then restarts the docker stack
docker/re: docker/clean playwright/clean docker/up
# Spins up the database
db/up:
docker compose up -d --wait db
# ----------------------------------------------------------
# Database
# ----------------------------------------------------------
# Interactive postgres shell on the database
db/connect: db/up
docker compose exec -u postgres db psql marketplace_db
# Runs the migrations
db/migrate: db/up diesel/install
diesel migration run
# Creates and downloads a remote database dump
db/update-remote-dump:
heroku pg:backups:capture --app $(REMOTE_DB_OWNER_APP)
heroku pg:backups:download --app $(REMOTE_DB_OWNER_APP) --output ./scripts/fixtures/latest.dump
# Loads the latest remote dump in
db/load-fixtures: SHELL:=/bin/bash
db/load-fixtures: db/up
PGPASSWORD=postgres pg_restore -L <(pg_restore -l ./scripts/fixtures/latest.dump | grep -Ev 'auth|migrations|hdb_catalog|SCHEMA - auth') --no-owner --disable-triggers --data-only -h localhost -U postgres -d marketplace_db ./scripts/fixtures/latest.dump
@echo ""
@echo "Dump loaded ✅"
@echo ""
@echo "It was generated on the `GIT_PAGER=cat git log -1 --format=%cd ./scripts/fixtures/latest.dump`"
@echo "To have a fresh dump, you can use db/update-remote-dump"
# ----------------------------------------------------------
# Backend
# ----------------------------------------------------------
# Starts the backend stack in background
backend/background-start: event-store/background-start event-listeners/background-start action-dequeuer/background-start api/background-start github-indexer/background-start github-proxy/background-start dusty-bot/background-start
# Stops the background backend stack, if running
backend/background-stop: event-store/background-stop event-listeners/background-stop action-dequeuer/background-stop api/background-stop github-indexer/background-stop github-proxy/background-stop dusty-bot/background-stop
api.pid:
@./scripts/cargo-run.sh api
@./scripts/wait-for-port.sh 8000
# Starts the API in background
api/background-start: api.pid
# Stops the background API, if running
api/background-stop:
@./scripts/stop-app.sh api
# Starts the API interactively
api/start: docker/up
@./scripts/cargo-run.sh api
github-proxy.pid:
@./scripts/cargo-run.sh github-proxy
@./scripts/wait-for-port.sh 8001
# Starts the Github proxy in background
github-proxy/background-start: github-proxy.pid
# Stops the background Github proxy, if running
github-proxy/background-stop:
@./scripts/stop-app.sh github-proxy
dusty-bot.pid:
@./scripts/cargo-run.sh dusty-bot
@./scripts/wait-for-port.sh 8002
# Starts the Dusty bot in background
dusty-bot/background-start: dusty-bot.pid
# Stops the background Dusty bot, if running
dusty-bot/background-stop:
@./scripts/stop-app.sh dusty-bot
event-listeners.pid:
@./scripts/cargo-run.sh event-listeners
# Starts the event listeners in background
event-listeners/background-start: event-listeners.pid
# Stops the background event listeners, if running
event-listeners/background-stop:
@./scripts/stop-app.sh event-listeners
event-store.pid:
@./scripts/cargo-run.sh event-store
# Starts the event store in background
event-store/background-start: event-store.pid
# Stops the background event store, if running
event-store/background-stop:
@./scripts/stop-app.sh event-store
action-dequeuer.pid:
@cargo run --bin action-dequeuer > action-dequeuer.log 2>&1 & echo $$! > action-dequeuer.pid
@echo "App action-dequeuer started with PID: `cat action-dequeuer.pid`"
# Starts the action dequeuer in background
action-dequeuer/background-start: action-dequeuer.pid
# Stops the background action dequeuer, if running
action-dequeuer/background-stop:
@./scripts/stop-app.sh action-dequeuer
github-indexer.pid:
@cargo run --bin github-indexer > github-indexer.log 2>&1 & echo $$! > github-indexer.pid
@echo "App github-indexer started with PID: `cat github-indexer.pid`"
# Starts the github indexer in background
github-indexer/background-start: github-indexer.pid
# Stops the background github indexer, if running
github-indexer/background-stop:
@./scripts/stop-app.sh github-indexer
# ----------------------------------------------------------
# Frontend
# ----------------------------------------------------------
# Installs the frontend dependencies
frontend/install: node_modules
frontend.pid:
@yarn dev > frontend.log 2>&1 & echo $$! > frontend.pid
@./scripts/wait-for-port.sh 5173
# Starts the frontend in background
frontend/background-start: frontend.pid
# Stops the frontend, if running
frontend/background-stop:
@./scripts/stop-app.sh frontend
# ----------------------------------------------------------
# Hasura
# ----------------------------------------------------------
hasura/node_modules:
yarn --cwd ./hasura
# Installs the Hasura CLI dependencies
hasura/install: hasura/node_modules
# Starts the Hasura CLI in interactive mode
hasura/start:
yarn --cwd ./hasura start
# Refreshes the local Hasura metadata running the backend stack and stopping it afterwards
hasura/start-refresh-stop: backend/background-start hasura/refresh backend/background-stop
# Refreshes the local Hasura metadata
hasura/refresh:
docker compose exec -u postgres db psql marketplace_db -c "DELETE FROM hdb_catalog.hdb_metadata"
yarn --cwd ./hasura hasura --skip-update-check md apply
yarn --cwd ./hasura hasura --skip-update-check md ic drop
yarn --cwd ./hasura hasura --skip-update-check md export
# ----------------------------------------------------------
# End-to-end tests
# ----------------------------------------------------------
# Install the browsers needed by Playwright
playwright/install:
yarn playwright install
# Runs the e2e tests, starting and stopping the whole stack afterwards
playwright/start-test-stop: app/background-start playwright/test app/background-stop
# Runs the e2e tests
playwright/test:
yarn playwright test
# Removes the Playwright generated fixtures
playwright/clean:
rm -f "playwright/marketplace_db_dump"
rm -rf "playwright/fixtures/__generated"
# Update snapshots for both local and CI
playwright/update-snapshots:
yarn playwright test __populate
yarn playwright test --update-snapshots responsive