Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
126 lines (104 loc) · 4.01 KB
/
Copy pathMakefile
File metadata and controls
126 lines (104 loc) · 4.01 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
# Supabase
start_supabase:
# Use nuxt envrc to start supabase (APP_URL)
# direnv exec DIR COMMAND [...ARGS] : Executes a command after loading the first .envrc or .env found in DIR.
direnv exec nuxt supabase start
# Django
clean_django:
rm -Rf django/.venv
install_django:
cd django && uv venv && . .venv/bin/activate && uv sync
START_DJANGO_CMD := cd django && . .venv/bin/activate && direnv exec . ./manage.py runserver
start_django:
$(START_DJANGO_CMD)
setup_test_db:
./docker/test_db/setup_test_db.sh && cd django && direnv exec . django-admin migrate --settings config.settings.test
clean_test_db:
docker compose down test_db
run_tests_django:
cd django && pytest . -vv
# Nuxt
clean_nuxt:
rm -Rf nuxt/{.nuxt,node_modules}
install_nuxt:
. ${HOME}/.nvm/nvm.sh && cd nuxt && nvm install && nvm use && npm install
START_NUXT_CMD := . ${HOME}/.nvm/nvm.sh && cd nuxt && nvm use && direnv exec . npm run dev
start_nuxt:
$(START_NUXT_CMD)
# All
clean: clean_django clean_nuxt
install: install_django install_nuxt
start: start_supabase
@trap 'kill $$DJANGO_PID $$NUXT_PID 2>/dev/null; exit 1' SIGINT SIGTERM; \
echo "=== Starting Development Environment ==="; \
\
echo "Starting django..."; \
( $(START_DJANGO_CMD) 2>&1 | sed 's/^/[django] /' ) & \
DJANGO_PID=$$!; \
echo "django running with PID: $$DJANGO_PID"; \
\
echo "Starting nuxt..."; \
( $(START_NUXT_CMD) 2>&1 | sed 's/^/[nuxt] /' ) & \
NUXT_PID=$$!; \
echo "nuxt running with PID: $$NUXT_PID"; \
\
wait $$DJANGO_PID $$NUXT_PID; \
echo "=== One process exited. Cleaning up ==="; \
kill $$DJANGO_PID $$NUXT_PID 2>/dev/null; \
exit 0
database_restore: start_supabase
cd django && direnv exec . ./scripts/restore_database.sh postgresql://postgres:postgres@127.0.0.1:54322/postgres
move_exports_to_outscale:
cd django && direnv exec . rclone --config scripts/rclone.conf move --s3-chunk-size=20M exports/ docurba_exports:/docurba-exports
copy_exports_from_outscale:
cd django && direnv exec . rclone --config scripts/rclone.conf copy --s3-chunk-size=20M docurba_exports:/docurba-exports exports/
move_exports_from_outscale:
cd django && direnv exec . rclone --config scripts/rclone.conf move --s3-chunk-size=20M docurba_exports:/docurba-exports exports/
update_snapshots:
@find django/tests -name '*.ambr' | sort | while read -r ambr; do \
py=$$(printf '%s' "$$ambr" | sed 's#/__snapshots__/#/#; s#\.ambr$$#.py#'); \
if [ -f "$$py" ]; then \
printf '%s\n' "$$py"; \
else \
printf '⚠ orphaned snapshot, no test module: %s\n' "$$ambr" >&2; \
fi; \
done | sort -u | xargs --no-run-if-empty \
pytest --snapshot-update
start_rj:
@if [[ ! -n "$(PR)" ]]; then \
echo "PR is not specified. Usage: PR=XXXX make start_rj"; \
exit 0; \
fi; \
scalingo --format json apps \
| jq -r '.apps[] | select(.status == "stopped") | .name' \
| sed -n "/\(docurba-demo-pr$(PR)\|docurba-nuxt-demo-pr$(PR)\|docurba-django-demo-pr$(PR)\)/p" \
| while read app; do \
echo "Starting review app : $$app"; \
scalingo --app "$$app" scale web:1; \
done; \
supabase branches list --output json \
| jq -r '.[] | select(.preview_project_status == "INACTIVE") | .name' \
| sed -n '/supabase-pr$(PR)/p' \
| while read branch; do \
echo "Unpausing supabase branche : $$branch"; \
supabase branches unpause "$$branch" --yes; \
done
stop_rj:
@if [[ ! -n "$(PR)" ]]; then \
echo "PR is not specified. Usage: PR=XXXX make stop_rj"; \
exit 0; \
fi; \
scalingo --format json apps \
| jq -r '.apps[] | select(.status == "running") | .name' \
| sed -n "/\(docurba-demo-pr$(PR)\|docurba-nuxt-demo-pr$(PR)\|docurba-django-demo-pr$(PR)\)/p" \
| while read app; do \
echo "Stopping review app : $$app"; \
scalingo --app "$$app" scale web:0; \
done; \
supabase branches list --output json \
| jq -r '.[] | select(.preview_project_status == "ACTIVE_HEALTHY") | .name' \
| sed -n '/supabase-pr$(PR)/p' \
| while read branch; do \
echo "Pausing supabase branche : $$branch"; \
supabase branches pause "$$branch" --yes; \
done