Skip to content

Commit 3d3db11

Browse files
committed
Replace make, dotenv, honcho with mise
**Breaking change:** To migrate from an existing local `.env`, add `[env]` to the top of the file and rename it to `mise.local.toml`. `mise` can be used to simplify our existing dev setup by replacing other dependencies. Running the project is now two commands: ```sh mise install mise dev ``` `mise dev` will automatically re-run bundler scripts, build scripts, only when relevant files change, as the tasks specify relevant `sources` and `outputs`. This was previously accomplished using a `sentinel` file which is no longer necessary. (Technical detail: mise automatically creates sentinels in `~/.mise` as necessary) `mise tasks` lists available tasks: ```sh $ mise tasks Name Description build Build all assets build:css Build CSS from SCSS build:favicons Copy NHS UK frontend favicons build:js Build JavaScript bundles bundle Install all dependencies ci Run CI checks in parallel clean Clean build artifacts and dependencies dev Start development servers dev:flask Run Flask development server dev:js Watch and build JS files dev:scss Watch and build SCSS files docker Build and run Docker container docker:build Build Docker image docker:run Run Docker container gitleaks Detect secrets with gitleaks lint Run code linting lint:fix Run code linting with autofix npm:install Install Node.js dependencies test Run all tests test:coverage Run tests with coverage reporting uv:sync Sync Python dependencies with uv ``` Notable cool new tasks: `mise ci` which runs all the CI checks in parallel. Local dev-only environment variables are now declared via `mise.local.toml`. **Breaking change:** To migrate from an existing local `.env`, add `[env]` to the top of the file and rename it to `mise.local.toml`. ```sh $ mise env set -gx CLIENT_ID deadbabe set -gx CLIENT_SECRET cafebabe set -gx DOCKER_IMAGE 'mavis-reporting:latest' set -gx FLASK_APP 'mavis.reporting:create_app' set -gx FLASK_ENV development set -gx HOST_PORT 4001 set -gx MAVIS_ROOT_URL 'http://localhost:4000/' set -gx PATH '/Users/...' set -gx PYTHONPYCACHEPREFIX tmp/pycache set -gx SECRET_KEY deadbeef set -gx SESSION_TTL_SECONDS 600 ``` - Removal of `.tool-versions` in favour of declaring them in `mise.toml` - `mise clean` now thoroughly cleans ~everything - New `tmp` folder, and `__PYCACHE__` bytecode directories will spawn there instead of polluting `./mavis/`. This is a quality of life improvement when using tools like `tree`
1 parent a788850 commit 3d3db11

File tree

13 files changed

+192
-200
lines changed

13 files changed

+192
-200
lines changed

.env.example

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

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: jdx/mise-action@v3
1313
with:
1414
cache: true
15-
- run: gitleaks detect --verbose --redact
15+
- run: mise gitleaks
1616

1717
pytest:
1818
runs-on: ubuntu-latest
@@ -23,7 +23,7 @@ jobs:
2323
cache: true
2424
- env:
2525
SECRET_KEY: "${{ secrets.SECRET_KEY_FOR_TESTS }}"
26-
run: make test
26+
run: mise test
2727

2828
ruff:
2929
runs-on: ubuntu-latest
@@ -32,7 +32,7 @@ jobs:
3232
- uses: jdx/mise-action@v3
3333
with:
3434
cache: true
35-
- run: make lint
35+
- run: mise lint
3636

3737
coverage:
3838
needs: [pytest]
@@ -49,7 +49,7 @@ jobs:
4949
- env:
5050
SECRET_KEY: "${{ secrets.SECRET_KEY_FOR_TESTS }}"
5151
COVERAGE_THRESHOLD: 80
52-
run: make test-coverage
52+
run: mise test:coverage
5353
- uses: actions/upload-artifact@v4
5454
id: upload-html-report-artifact-step
5555
if: always()

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
# Please, add your custom content below!
99
.DS_Store
1010
.env
11+
mise.local.toml
12+
mise.*.local.toml
1113
.venv/
1214
__pycache__/
1315
.ruff_cache/
@@ -22,9 +24,11 @@ mavis/reporting/static/js/*
2224
mavis/reporting/static/favicons/*
2325
!mavis/reporting/static/favicons/.keep
2426

25-
sentinel
26-
2727
.coverage
2828
htmlcov
2929
coverage.svg
3030
coverage.xml
31+
32+
.pytest_cache
33+
tmp
34+
!tmp/.keep

.tool-versions

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

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM python:3.13.7-alpine AS builder
22

33
WORKDIR /app
44

5-
ADD package.json package-lock.json pyproject.toml uv.lock Makefile /app/
5+
ADD package.json package-lock.json pyproject.toml uv.lock /app/
66

77
RUN apk add build-base libffi-dev npm bash curl
88

@@ -18,7 +18,9 @@ FROM builder
1818

1919
WORKDIR /app
2020

21-
RUN make build-assets
21+
RUN mkdir -p mavis/reporting/static/favicons && \
22+
cp -r node_modules/nhsuk-frontend/dist/nhsuk/assets/images/* mavis/reporting/static/favicons/ && \
23+
npm run build:scss && npm run build:js
2224

2325
RUN addgroup --gid 1000 app
2426
RUN adduser app -h /app -u 1000 -G app -DH

Makefile

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

Procfile.dev

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

README.md

Lines changed: 38 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,97 +2,52 @@
22

33
A Flask-based web application for the commissioner reporting component of Mavis.
44

5-
## Prerequisites
6-
7-
- Mise
8-
- Make
9-
105
## Installation
116

12-
1. **Install Mise**
13-
14-
Please see the main Mavis repository for [how to install mise](https://github.com/nhsuk/manage-vaccinations-in-schools?tab=readme-ov-file#mise).
15-
16-
Once mise is installed, run the following command to install the project dependencies:
17-
18-
```bash
19-
mise install
20-
```
21-
22-
2. **Install project dependencies**
23-
24-
This will install the project dependencies using uv and NPM.
25-
26-
Note that the uv virtual environment will be created in the `.venv` directory to allow IDEs to use the correct Python interpreter.
27-
28-
```bash
29-
make install
30-
```
31-
32-
3. **Create an environment file**
33-
34-
Create a `.env` file in the root of the project following the example provided in `.env.example`.
35-
36-
4. **Run the application in development mode**
37-
38-
```bash
39-
make dev
40-
```
41-
42-
The application will be available at <http://localhost:5001>.
43-
You will need a version of Mavis running which supports the OAuth 2.0 token authentication method - please see [Runtime Dependencies](#runtime-dependencies) below for details.
44-
45-
## Linting
7+
Please see the main Mavis repository for [how to install
8+
mise](https://github.com/nhsuk/manage-vaccinations-in-schools?tab=readme-ov-file#mise).
469

47-
We use Ruff to lint the code. To run the linter, run the following command:
48-
49-
```bash
50-
make lint
10+
```sh
11+
mise install # Install dev tools
12+
cp mise.local.toml.example mise.local.toml # Fill in shared secrets
13+
mise dev # Run dev server
14+
mise ci # Run CI tests
5115
```
5216

53-
To run the linter with autofix, run the following command:
54-
55-
```bash
56-
make lint-fix
57-
```
58-
59-
To configure VSCode or variants thereof to use Ruff in your IDE, install the Ruff extension and it should be used automatically.
60-
61-
## Building & Running a Docker container
17+
The application will be available at <http://localhost:4001>.
6218

63-
The application can be built and run via Docker, to support deployment to AWS.
64-
By default, the docker container listens on port 5000, but as Mac OS typically has an existing system application (Control Center) listening on port 5000, we use Docker's port mapping to map port 5001 on the host (your laptop) to 5000 on the container.
19+
You will need a version of Mavis running which supports the OAuth 2.0 token
20+
authentication method - please see [Runtime Dependencies](#runtime-dependencies)
21+
below for details.
6522

66-
### Build
23+
## Other tasks
6724

68-
`make build-docker`
69-
70-
This will build a container image tagged with `mavis/reporting:latest`, which will listen on port 5000. To use a different tag, supply the `DOCKER_IMAGE` environment variable (e.g. `DOCKER_IMAGE=reporting-component:spike-11 make build-docker`)
71-
72-
Note that it will not push the image to any repository - you must do that manually if you want to.
73-
74-
### Run
75-
76-
`make run-docker`
25+
```sh
26+
mise tasks # See all available tasks
27+
mise env # See all available environment variables
28+
```
7729

78-
This will run the container image tagged with `mavis/reporting:latest` and listen on the host port 5000.
79-
To use a different tag, supply the `DOCKER_IMAGE` environment variable .
80-
To map a different host port (for instance if you have something else running on port 5000) supply the `HOST_PORT` environment variable
30+
### Docker
8131

82-
Example:
32+
To build and run the app in a Docker container, mimicking the production
33+
environment:
8334

84-
`DOCKER_IMAGE=reporting-component:spike-11 HOST_PORT=5001 make run-docker` will run the container image tagged with `reporting-component:spike-11` and map port 5001 on the host to port 5000 on the container.
35+
```sh
36+
mise docker
37+
```
8538

86-
You could then access the running app with <http://localhost:5001> on your browser.
39+
Different environment variables can be overwritten in `mise.local.toml`.
8740

8841
### Gunicorn arguments
8942

90-
Additional parameters to the `gunicorn` executable (for instance, the number of workers) can be passed through with the `GUNICORN_CMD_ARGS` environment variable.
43+
Additional parameters to the `gunicorn` executable (for instance, the number of
44+
workers) can be passed through with the `GUNICORN_CMD_ARGS` environment
45+
variable.
9146

9247
Example:
9348

9449
```bash
95-
% HOST_PORT=5555 GUNICORN_CMD_ARGS="--workers=5" make run-docker
50+
% HOST_PORT=5555 GUNICORN_CMD_ARGS="--workers=5" mise docker:run
9651
docker run --rm -p 5555:5000 -e GUNICORN_CMD_ARGS=--workers=5 mavis-reporting:latest
9752
[2025-07-17 10:32:01 +0000] [1] [INFO] Starting gunicorn 23.0.0
9853
[2025-07-17 10:32:01 +0000] [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
@@ -106,12 +61,19 @@ docker run --rm -p 5555:5000 -e GUNICORN_CMD_ARGS=--workers=5 mavis-reporting:la
10661

10762
## Runtime dependencies
10863

109-
This application authenticates with the main Mavis application using the [OAuth 2.0 Authorization Code flow](https://datatracker.ietf.org/doc/html/rfc6749#section-4.1).
64+
This application authenticates with the main Mavis application using the [OAuth
65+
2.0 Authorization Code
66+
flow](https://datatracker.ietf.org/doc/html/rfc6749#section-4.1).
11067

11168
To do this, it requires:
11269

113-
1. A copy of the main Mavis app must be running and available at the URL given in the `MAVIS_ROOT_URL` env var
70+
1. A copy of the main Mavis app must be running and available at the URL given
71+
in the `MAVIS_ROOT_URL` env var
11472
2. That copy of Mavis must:
11573
- have the `reporting_api` feature flag enabled
116-
- have a value for `Settings.reporting_api.client_app.client_id` (..which can also be set via the `MAVIS__REPORTING_API__CLIENT_APP__CLIENT_ID` environment variable) which matches this application's `CLIENT_ID` value
117-
- have a value for `Settings.reporting_api.client_app.secret` (..which can also be set via the `MAVIS__REPORTING_API__CLIENT_APP__SECRET` environment variable) which matches this application's `CLIENT_SECRET` value
74+
- have a value for `Settings.reporting_api.client_app.client_id` (..which can
75+
also be set via the `MAVIS__REPORTING_API__CLIENT_APP__CLIENT_ID`
76+
environment variable) which matches this application's `CLIENT_ID` value
77+
- have a value for `Settings.reporting_api.client_app.secret` (..which can
78+
also be set via the `MAVIS__REPORTING_API__CLIENT_APP__SECRET` environment
79+
variable) which matches this application's `CLIENT_SECRET` value

mavis/reporting/config/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import os
2-
from dotenv import load_dotenv
3-
4-
load_dotenv()
52

63

74
def str2bool(v):

mise.local.toml.example

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Local development environment variables
2+
# Copy this file to mise.local.toml and customize the values
3+
# mise.local.toml should NOT be committed to version control
4+
5+
[env]
6+
FLASK_APP = "mavis.reporting:create_app"
7+
SECRET_KEY = "(some random hex string)"
8+
CLIENT_ID = "(some random hex string)"
9+
CLIENT_SECRET = "(some random hex string)"
10+
11+
# Optional overrides for local development
12+
# FLASK_ENV = "development" # Already set in mise.toml
13+
# MAVIS_ROOT_URL = "http://localhost:4000/" # Already set in mise.toml
14+
# SESSION_TTL_SECONDS = "600" # Already set in mise.toml
15+
# ROOT_URL = "" # Only needed in production
16+
# FAKE_LOGIN_ENABLED = "true" # Uncomment to bypass OAuth

0 commit comments

Comments
 (0)