[cicd] Run tests with multiples Python/Django combinations

This commit is contained in:
Antoine Lorence 2025-03-31 21:50:30 +02:00
parent 1571cd33ea
commit 1a9801ae95
3 changed files with 18 additions and 8 deletions

View file

@ -11,13 +11,20 @@ jobs:
run_tests:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.10", "3.11", "3.12"]
django: ["4.2", "5.0", "5.1"]
name: Tests - python ${{ matrix.python }} × django ${{ matrix.django }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Build
run: |
docker build -f dev/docker/Dockerfile -t cotton-test-app dev/example_project
docker build -f dev/docker/Dockerfile --build-arg PYTHON_VERSION=${{ matrix.python }} --build-arg DJANGO_VERSION=${{ matrix.django }} -t cotton-test-app dev/example_project
- name: Start Container
run: |
@ -27,4 +34,4 @@ jobs:
run: docker exec -t cotton-dev-app python manage.py test
- name: Stop and Remove Services
run: docker compose -f dev/docker/docker-compose.yaml down
run: docker compose -f dev/docker/docker-compose.yaml down

View file

@ -1,6 +1,8 @@
ARG PYTHON_VERSION=3.12
# Use an official Python runtime as a base image
FROM python:3.12-slim-bookworm
FROM python:${PYTHON_VERSION}-slim-bookworm
ARG DJANGO_VERSION=4.2
# Setup env
ENV PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_NO_CACHE_DIR=off \
@ -20,6 +22,7 @@ COPY . /app/
# Install project dependencies
RUN poetry config virtualenvs.create false \
&& poetry install
&& poetry install \
&& pip install -U "django==$DJANGO_VERSION.*"
CMD [ "python", "manage.py", "runserver", "0.0.0.0:8000" ]
CMD [ "python", "manage.py", "runserver", "0.0.0.0:8000" ]

View file

@ -9,5 +9,5 @@ description = "Development and test app for the django package."
authors = ["Will Abbott <willabb83@gmail.com>"]
[tool.poetry.dependencies]
python = "^3.10"
Django = "^5.1"
python = ">=3.10"
Django = "^5.1"