-
Notifications
You must be signed in to change notification settings - Fork 124
/
justfile
45 lines (36 loc) · 1.79 KB
/
justfile
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
default:
just --list --unsorted
db-host := env_var_or_default('DB_HOST', "localhost")
db-port := env_var_or_default('DB_PORT', "5432")
db-user := env_var_or_default('DB_USER', "postgres")
db-password := env_var_or_default('DB_PASSWORD', "admin")
db-name := env_var_or_default('DB_NAME', "stats")
export DATABASE_URL := "postgres://" + db-user + ":" + db-password + "@" + db-host + ":" + db-port + "/" + db-name
docker-name := env_var_or_default('DOCKER_NAME', "stats-postgres")
test-db-port := env_var_or_default('TEST_DB_PORT', "9433")
start-postgres:
# we run it in --rm mode, so all data will be deleted after stopping
docker run -p {{db-port}}:5432 --name {{docker-name}} -e POSTGRES_PASSWORD={{db-password}} -e POSTGRES_USER={{db-user}} --rm -d postgres -N 500
sleep 3
# wait for postgres to start, but only if db_name is not empty
$SHELL -c '[[ -z "{{db-name}}" ]] || docker exec -it {{docker-name}} psql -U postgres -c "create database {{db-name}};"'
stop-postgres:
docker kill {{docker-name}}
test *args:
cargo test {{args}} -- --include-ignored --nocapture
test-with-db *args:
# remove db from previous run (if failed)
-just docker-name="{{docker-name}}-test" stop-postgres 2> /dev/null
-just db-port="{{test-db-port}}" db-name="" docker-name="{{docker-name}}-test" start-postgres
just db-port="{{test-db-port}}" db-name="" test {{args}}
just docker-name="{{docker-name}}-test" stop-postgres
check-envs:
VALIDATE_ONLY=true cargo run --bin env-docs-generation
generate-envs:
cargo run --bin env-docs-generation
restart-generate-entities:
-just stop-postgres
just start-postgres
just stats/migrate-up
just stats/generate-entities
just stop-postgres