-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
89 lines (78 loc) · 3.04 KB
/
Taskfile.yaml
File metadata and controls
89 lines (78 loc) · 3.04 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
version: '3'
env:
TESTING_DOCKER_COMPOSE: docker-compose.testing.yaml
TESTING_ENV_FILE: .env.testing
tasks:
format:
desc: "Formats the code using cargo fmt."
cmds:
- cargo fmt --all
format:check:
desc: "Checks if the code is formatted using cargo fmt."
cmds:
- cargo fmt --all -- --check
lint:
desc: "Runs cargo clippy for linting."
deps:
- task: format:check
cmds:
- cargo clippy --all-targets --all-features --locked -- -D warnings
teardown-test-env:
desc: "Stops and removes the testing Docker containers."
cmds:
- docker compose -f $TESTING_DOCKER_COMPOSE down
start-test-env-api-deps:
desc: "Starts the API dependencies for testing."
env:
NO_BUILD: 0
IMAGE: deadlock-api-rust:latest
cmds:
- "if [[ $NO_BUILD = 1 ]]; then docker compose -f $TESTING_DOCKER_COMPOSE up -d --wait --remove-orphans clickhouse minio postgres redis; fi"
- "if [[ $NO_BUILD = 0 ]]; then docker compose -f $TESTING_DOCKER_COMPOSE up -d --wait --remove-orphans --build clickhouse minio postgres redis; fi"
start-test-env:
desc: "Starts the testing Docker environment."
dotenv: [ '{{.TESTING_ENV_FILE}}' ]
env:
NO_BUILD: 0
IMAGE: deadlock-api-rust:latest
cmds:
- task: start-test-env-api-deps
- task: import-test-data
- "if [[ $NO_BUILD = 1 ]]; then docker compose -f $TESTING_DOCKER_COMPOSE up -d --wait --remove-orphans; fi"
- "if [[ $NO_BUILD = 0 ]]; then docker compose -f $TESTING_DOCKER_COMPOSE up -d --wait --remove-orphans --build; fi"
import-test-data-postgres:
desc: "Imports test data into PostgreSQL."
dotenv: [ '{{.TESTING_ENV_FILE}}' ]
preconditions:
- '[[ $(docker compose -f $TESTING_DOCKER_COMPOSE ps --format json postgres | jq ".Health") != "healthy" ]]'
vars:
FILE:
sh: find tests/data/postgres/ -type f -name '*.sql' | sort
cmds:
- for: { var: FILE }
cmd: docker compose -f $TESTING_DOCKER_COMPOSE exec -T postgres psql -U $POSTGRES_USERNAME -d $POSTGRES_DBNAME < {{.ITEM}}
import-test-data-clickhouse:
desc: "Imports test data into ClickHouse."
dotenv: [ '{{.TESTING_ENV_FILE}}' ]
preconditions:
- '[[ $(docker compose -f $TESTING_DOCKER_COMPOSE ps --format json clickhouse | jq ".Health") != "healthy" ]]'
vars:
FILE:
sh: find tests/data/clickhouse/ -type f -name '*.sql' | sort
cmds:
- for: { var: FILE }
cmd: docker compose -f $TESTING_DOCKER_COMPOSE exec -T clickhouse clickhouse-client -u $CLICKHOUSE_USERNAME --password $CLICKHOUSE_PASSWORD < {{.ITEM}}
import-test-data:
desc: "Sets up the testing Docker environment."
dotenv: [ '{{.TESTING_ENV_FILE}}' ]
deps:
- task: import-test-data-postgres
- task: import-test-data-clickhouse
test:
desc: "Runs the cargo tests after setting up the test environment."
dotenv: [ '{{.TESTING_ENV_FILE}}' ]
deps:
- task: start-test-env
cmds:
- cargo nextest run --locked --status-level fail
- task: teardown-test-env