Skip to content

Commit 92c99b4

Browse files
committed
chore(healthcheck): use .env in dev & remove makefile
Commands are nos documented directly in README
1 parent 7fd2c15 commit 92c99b4

5 files changed

Lines changed: 56 additions & 63 deletions

File tree

tools/healthcheck/.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
.pytest_cache
44
__pycache__
55
htmlcov
6-
.coverage
6+
.coverage
7+
.env*

tools/healthcheck/.env.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
RABBITMQ_HEALTH_URL=http://localhost:15672/api/health/checks/alarms
2+
SHOVEL_STATUS_URL=http://localhost:15672/api/shovels
3+
ANNUAIRE_HEALTH_URL=http://annuaire_test
4+
CONVERTER_HEALTH_URL=http://localhost:8083/health
5+
RABBITMQ_MONITORING_USERNAME=admin
6+
RABBITMQ_MONITORING_PASSWORD=admin
7+
DISPATCHER_CONFIG_FILE_PATH=dispatchers_config_file_path_example.txt
8+
MONGODB_URI=mongodb://localhost:27017

tools/healthcheck/.env.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
RABBITMQ_HEALTH_URL=http://rabbitmq_test
2+
SHOVEL_STATUS_URL=http://shovel_status_test
3+
ANNUAIRE_HEALTH_URL=http://annuaire_test
4+
CONVERTER_HEALTH_URL=http://converter_test
5+
RABBITMQ_MONITORING_USERNAME=user
6+
RABBITMQ_MONITORING_PASSWORD=password
7+
DISPATCHER_CONFIG_FILE_PATH=dispatchers_config_file_path_example.txt
8+
MONGODB_URI=mongodb://mongo_test

tools/healthcheck/Makefile

Lines changed: 0 additions & 36 deletions
This file was deleted.

tools/healthcheck/README.md

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,59 @@ uv venv
99
source .venv/bin/activate # On Windows: .venv\Scripts\activate
1010
```
1111

12-
2. Install the package in development mode:
12+
2. Install dependencies:
1313

1414
```bash
1515
uv sync
1616
```
1717

18-
## Run healthcheck locally
19-
20-
you can run:
18+
3. Create your local `.env` from the committed template, then adjust values if needed:
2119

20+
```bash
21+
cp .env.example .env
2222
```
23-
make run-local
24-
#> RABBITMQ_HEALTH_URL=http://localhost:15672/api/health/checks/alarms \
25-
#> SHOVEL_STATUS_URL=http://shovel_test \
26-
#> ANNUAIRE_HEALTH_URL=http://annuaire_test \
27-
#> CONVERTER_HEALTH_URL=http://localhost:8083/health \
28-
#> RABBITMQ_MONITORING_USERNAME=admin \
29-
#> RABBITMQ_MONITORING_PASSWORD=admin \
30-
#> DISPATCHER_CONFIG_FILE_PATH=dispatchers_config_file_path_example.txt \
31-
#> uv run healthcheck.py --port 8085
23+
24+
The `.env` file is gitignored and only consumed by local commands (via `uv run --env-file .env`). In production the container receives env vars from the orchestration layer, so `.env` is also excluded from the Docker image via `.dockerignore`.
25+
26+
## Run healthcheck locally
27+
28+
```bash
29+
uv run --env-file .env healthcheck.py --port 8085
3230
```
3331

3432
## Tests
3533

36-
To run the tests:
34+
Run the tests:
35+
36+
```bash
37+
uv run --env-file .env.test -m unittest tests/*.py -v
38+
```
39+
40+
Tests use placeholder URLs that only need to satisfy `config.py` validation — they are intentionally kept inline rather than in `.env` so they cannot be confused with real local infra values.
41+
42+
Run the tests with coverage:
3743

44+
```bash
45+
uv run --env-file .env.test coverage run -m unittest tests/*.py
3846
```
39-
RABBITMQ_HEALTH_URL=http://test \
40-
SHOVEL_STATUS_URL=http://shovel_test \
41-
ANNUAIRE_HEALTH_URL=http://annuaire_test \
42-
CONVERTER_HEALTH_URL=http://converter_test \
43-
RABBITMQ_MONITORING_USERNAME=test \
44-
RABBITMQ_MONITORING_PASSWORD=test \
45-
DISPATCHER_CONFIG_FILE_PATH=dispatchers_config_file_path_example.txt \
46-
uv run python -m unittest tests/*.py -v
47+
48+
Display the coverage report summary in the terminal:
49+
50+
```bash
51+
uv run coverage report -m
4752
```
4853

49-
To run the tests and generate a coverage report: `make test`
54+
Generate an HTML coverage report (open [htmlcov/index.html](htmlcov/index.html) afterwards):
5055

51-
To display the coverage report summary in the terminal: `make show-coverage`
56+
```bash
57+
uv run coverage html
58+
```
59+
60+
Coverage doc available [here](https://coverage.readthedocs.io/en/7.8.0/).
5261

53-
To generate a html report from an existing report: `uv run coverage html` & open [htmlcov/index.html](htmlcov/index.html) in a browser.
62+
## Lint and format
5463

55-
Coverage doc available [here](https://coverage.readthedocs.io/en/7.8.0/)
64+
```bash
65+
uv run ruff check --fix
66+
uv run ruff format
67+
```

0 commit comments

Comments
 (0)