diff --git a/.github/workflows/docker-matrix.yml b/.github/workflows/docker-matrix.yml new file mode 100644 index 0000000..92ba847 --- /dev/null +++ b/.github/workflows/docker-matrix.yml @@ -0,0 +1,39 @@ +name: Compatibility Matrix + +on: + workflow_dispatch: + +jobs: + CompatibilityMatrix: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + image-tag: ['3.12-slim-bullseye'] + update-strategy: [default, minor] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Build + uses: docker/setup-buildx-action@v3.4.0 + + - name: Build current Docker image with tests + run: | + docker build --target test -t zephir-api2:test . + + - name: Install and update dependencies + run: | + if [[ "${{ matrix.update-strategy }}" == "default" ]]; then + + echo "Running normal test suite" + docker build --build-arg IMAGE_TAG=${{ matrix.image-tag }} --target test -t zephir-api2:test . + + elif [[ "${{ matrix.update-strategy }}" == "minor" ]]; then + + echo "Minor version update" + docker build --build-arg IMAGE_TAG=${{ matrix.image-tag }} --target test-minor-update -t zephir-api2:test . + + fi \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a009f3a..0d0ef04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ -FROM python:3.12-slim-bullseye AS base +ARG IMAGE_TAG=3.12-slim-bullseye + +FROM python:${IMAGE_TAG} AS base # Allowing the argumenets to be read into the dockerfile. Ex: .env > compose.yml > Dockerfile ARG UID=1000 ARG GID=1000 @@ -35,6 +37,10 @@ FROM poetry AS build COPY pyproject.toml poetry.lock ./ RUN poetry install --no-root --without dev && rm -rf ${POETRY_CACHE_DIR}; +# FROM poetry AS build-minor-update +# # Install minor version updates in the absence of poetry.lock file +# COPY pyproject.toml poetry.lock ./ +# RUN poetry install --no-root --without dev && rm -rf ${POETRY_CACHE_DIR}; FROM build AS test # Install dev dependencies @@ -44,6 +50,15 @@ COPY . . USER app RUN poetry run pytest tests +FROM build AS test-minor-update +# Install dev dependencies +RUN poetry install --only dev --no-root && rm -rf ${POETRY_CACHE_DIR}; +RUN poetry update +COPY . . +# Run tests +USER app +RUN poetry run pytest tests + FROM base AS production RUN mkdir -p /venv && chown ${UID}:${GID} /venv