Skip to content

Commit

Permalink
Update docker file for multiple tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cscollett committed Aug 29, 2024
1 parent 7fe8944 commit 34c630e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/docker-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
image-tag: ['3.12-slim-bullseye']
update-strategy: [default, update, unlocked-install, unpegged-install]
update-strategy: [default, update, unlocked-install, latest-install]

steps:
- name: Checkout code
Expand Down Expand Up @@ -42,11 +42,11 @@ jobs:
elif [[ "${{ matrix.update-strategy }}" == "unlocked-install" ]]; then
echo "Running normal test with updated dependencies"
docker build --no-cache --build-arg IMAGE_TAG=${{ matrix.image-tag }} --target test-unlocked-install -t zephir-api2:test .
docker build --no-cache --build-arg IMAGE_TAG=${{ matrix.image-tag }} --target build-unlocked-test -t zephir-api2:test .
elif [[ "${{ matrix.update-strategy }}" == "unpegged-install" ]]; then
elif [[ "${{ matrix.update-strategy }}" == "latest-install" ]]; then
echo "Running normal test with updated dependencies"
docker build --no-cache --build-arg IMAGE_TAG=${{ matrix.image-tag }} --target test-unpegged-install -t zephir-api2:test .
docker build --no-cache --build-arg IMAGE_TAG=${{ matrix.image-tag }} --target build-latest-test -t zephir-api2:test .
fi
27 changes: 7 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,38 +61,25 @@ USER app
RUN poetry run pytest tests
RUN poetry show

FROM build AS test-unlocked-install
# Uninstall poetry and install it again
RUN pip uninstall -y poetry
# Remove poetry.lock and install dependencies
RUN rm poetry.lock
RUN pip install poetry
RUN poetry install --no-root --without dev && rm -rf ${POETRY_CACHE_DIR};
RUN poetry install --only dev --no-root && rm -rf ${POETRY_CACHE_DIR};
FROM poetry AS build-unlocked-test
COPY pyproject.toml ./
RUN poetry install --no-root && rm -rf ${POETRY_CACHE_DIR};
COPY . .
# Run tests
USER app
RUN poetry run pytest tests

FROM build AS test-unpegged-install
# Uninstall poetry and install it again
RUN pip uninstall -y poetry
# Remove poetry.lock and install dependencies
RUN rm poetry.lock
## Substitute all numbers in pyproject.toml with *
FROM poetry AS build-latest-test
COPY pyproject.toml ./
RUN sed -i 's/\^/>=/g' pyproject.toml
# Print toml file
RUN cat pyproject.toml
RUN pip install poetry
RUN poetry install --no-root --without dev && rm -rf ${POETRY_CACHE_DIR};
RUN poetry install --only dev --no-root && rm -rf ${POETRY_CACHE_DIR};
RUN poetry install --no-root && rm -rf ${POETRY_CACHE_DIR};
COPY . .
# Run tests
USER app
RUN poetry run pytest tests
RUN cat pyproject.toml
RUN poetry show


FROM base AS production
RUN mkdir -p /venv && chown ${UID}:${GID} /venv

Expand Down

0 comments on commit 34c630e

Please sign in to comment.