diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ec12f2c..7e18b61 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,3 +24,15 @@ just test ``` If you don't have `just` installed, you can look in the `justfile` for the commands that are run. + +To help with testing on Docker, there's a `docker-compose.yml` file to run PostgreSQL and MySQL in Docker, as well as some additional `just` commands for testing: + +```sh +just start-dbs +just test-postgres +just test-mysql +just test-sqlite + +# To run all of the above: +just test-dbs +``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1abd92e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +services: + postgresql: + image: postgres:16-alpine + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + ports: + - 15432:5432 + + mysql: + image: mysql:8.4 + environment: + MYSQL_ROOT_PASSWORD: django + MYSQL_DATABASE: django + ports: + - 13306:3306 diff --git a/justfile b/justfile index 4923d86..b0a226a 100644 --- a/justfile +++ b/justfile @@ -17,3 +17,18 @@ lint: python -m ruff check django_tasks tests python -m ruff format django_tasks tests --check python -m mypy django_tasks tests + +start-dbs: + docker-compose pull + docker-compose up -d + +test-sqlite *ARGS: + python -m manage test --shuffle --noinput {{ ARGS }} + +test-postgres *ARGS: + DATABASE_URL=postgres://postgres:postgres@localhost:15432/postgres python -m manage test --shuffle --noinput {{ ARGS }} + +test-mysql *ARGS: + DATABASE_URL=mysql://root:django@127.0.0.1:13306/django python -m manage test --shuffle --noinput {{ ARGS }} + +test-dbs *ARGS: start-dbs test-postgres test-mysql test-sqlite