Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test docker matrix #8

Merged
merged 12 commits into from
Aug 26, 2024
39 changes: 39 additions & 0 deletions .github/workflows/docker-matrix.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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
17 changes: 16 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down