-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-commit
executable file
·55 lines (50 loc) · 3.36 KB
/
pre-commit
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
#!/bin/sh
# TBD: move environment file to a place, where frontend and backend can access it - maybe in the root folder. Or check if multiple env files are possible?
# TBD: consider moving most of this into pre-push?
# TBD: move into a script directory, commit to repo and then call from here / symlink here?
## SINGLE CONTAINER TESTS:
# docker compose -f compose.yml -f compose.override.test.yml --env-file backendAPI/src/tests/.env build
# docker compose -f compose.yml -f compose.override.test.yml --env-file backendAPI/src/tests/.env run -T --rm backend_api sh -c "black ."
# docker compose -f compose.yml -f compose.override.test.yml --env-file backendAPI/src/tests/.env run -T --rm backend_api sh -c "ruff format ."
# docker compose -f compose.yml -f compose.override.test.yml --env-file backendAPI/src/tests/.env run -T --rm backend_api sh -c "pytest -v"
# Get the build back in, when having less frequent changes and closer to release:
COMPOSE_PROJECT_NAME=test-fssb23 docker compose -f compose.yml -f compose.override.test.yml --env-file backendAPI/src/tests/.env build
COMPOSE_PROJECT_NAME=test-fssb23 docker compose -f compose.yml -f compose.override.test.yml --env-file backendAPI/src/tests/.env up -d
# TBD: put back in, when frontend is further developed:
COMPOSE_PROJECT_NAME=test-fssb23 docker compose -f compose.yml -f compose.override.test.yml --env-file backendAPI/src/tests/.env exec -T backend_api sh -c "isort --profile black ."
ISORT_EXIT_CODE=$?
COMPOSE_PROJECT_NAME=test-fssb23 docker compose -f compose.yml -f compose.override.test.yml --env-file backendAPI/src/tests/.env exec -T backend_api sh -c "ruff check --fix ."
RUFF_EXIT_CODE=$?
COMPOSE_PROJECT_NAME=test-fssb23 docker compose -f compose.yml -f compose.override.test.yml --env-file backendAPI/src/tests/.env exec -T backend_api sh -c "black ."
BLACK_EXIT_CODE=$?
git add ./backendAPI/
COMPOSE_PROJECT_NAME=test-fssb23 docker compose -f compose.yml -f compose.override.test.yml --env-file backendAPI/src/tests/.env exec -T backend_api sh -c "pytest"
PYTEST_EXIT_CODE=$?
COMPOSE_PROJECT_NAME=test-fssb23 docker compose -f compose.yml -f compose.override.test.yml --env-file backendAPI/src/tests/.env exec -T frontend_svelte sh -c "npm run format"
NPM_FORMAT_EXIT_CODE=$?
COMPOSE_PROJECT_NAME=test-fssb23 docker compose -f compose.yml -f compose.override.test.yml --env-file backendAPI/src/tests/.env exec -T frontend_svelte sh -c "npm run lint"
NPM_LINT_EXIT_CODE=$?
git add ./frontend_svelte/
COMPOSE_PROJECT_NAME=test-fssb23 docker compose -f compose.yml -f compose.override.test.yml --env-file backendAPI/src/tests/.env exec -T frontend_svelte sh -c "npm run test:unit"
NPM_UNITTEST_EXIT_CODE=$?
COMPOSE_PROJECT_NAME=test-fssb23 docker compose -f compose.yml -f compose.override.test.yml --env-file backendAPI/src/tests/.env down
cd infrastructure
COMPOSE_PROJECT_NAME=test-fssb23 docker compose build
COMPOSE_PROJECT_NAME=test-fssb23 docker compose run --rm --no-TTY tofu fmt
TOFU_FMT_EXIT_CODE=$?
git add .
print_result() {
if [ $1 -eq 0 ]; then
echo "✅ $2"
else
echo "🔥 $2"
fi
}
print_result $ISORT_EXIT_CODE "isort"
print_result $RUFF_EXIT_CODE "ruff"
print_result $BLACK_EXIT_CODE "black"
print_result $PYTEST_EXIT_CODE "pytest"
print_result $NPM_FORMAT_EXIT_CODE "npm format"
print_result $NPM_LINT_EXIT_CODE "npm lint"
print_result $NPM_UNITTEST_EXIT_CODE "npm unit test"
print_result $TOFU_FMT_EXIT_CODE "tofu fmt"