feat(CI): add custom docker for CI

Refs: #4
Signed-off-by: Klagarge <remi@heredero.ch>
This commit is contained in:
2025-03-19 21:55:06 +01:00
parent 9897526b14
commit eda58ace70
2 changed files with 38 additions and 17 deletions

View File

@@ -1,27 +1,25 @@
variables:
DOCKER_IMAGE: registry.forge.hefr.ch/klagarge/mse2425-grp09/python-pdm:latest
default: default:
image: python:3.9 image: $DOCKER_IMAGE
stages: stages:
- lint - lint
- build - test
build job: test job:
stage: build stage: test
script: script:
- cd src - cd src
# - apt-get update -qy - cp -r /app/__pypackages__ .
# - apt-get install -y python3-dev python3-pip python3.12-venv curl
- python3 -V
# - pip3 install --break-system-packages -r requirements.txt
- curl -sSL https://pdm-project.org/install-pdm.py | python3 -
- export PATH=/root/.local/bin:$PATH
- pdm install
# Set environment variables for the tests # Set environment variables for the tests
- export FLASK_SECRET_KEY=$FLASK_SECRET_KEY - export FLASK_SECRET_KEY=$FLASK_SECRET_KEY
# launch tests # launch tests
- export PYTHONPATH=. - export PYTHONPATH="/builds/Klagarge/mse2425-grp09/src:/builds/Klagarge/mse2425-grp09/src/__pypackages__/3.9/lib"
- export PATH="/builds/Klagarge/mse2425-grp09/src/__pypackages__/3.9/bin:$PATH"
- export FLASK_APP=app - export FLASK_APP=app
- pdm run pytest tests --cov --cov-report term --cov-report html - pdm run pytest tests --cov --cov-report term --cov-report html
@@ -38,10 +36,10 @@ lint job:
allow_failure: true # Linter can fail, fixing it is for now outside of the projects scope allow_failure: true # Linter can fail, fixing it is for now outside of the projects scope
pages: pages:
stage: build stage: test
dependencies: dependencies:
- build job - test job
needs: ["build job"] needs: ["test job"]
script: script:
- mv src/htmlcov/ public/ - mv src/htmlcov/ public/
artifacts: artifacts:

23
Dockerfile Normal file
View File

@@ -0,0 +1,23 @@
FROM python:3.9-slim
LABEL maintener="Rémi Heredero <remi.heredero@hevs.ch>"
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
rm -rf /var/lib/apt/lists/*
RUN curl -sSL https://pdm-project.org/install-pdm.py | python3 -
ENV PATH="/root/.local/bin:$PATH" \
PDM_USE_VENV=false
WORKDIR /app
COPY src/pyproject.toml src/pdm.lock ./
RUN pdm config python.use_venv false && \
pdm install -G:all
ENV PATH="/root/.local/bin:$PATH" \
PDM_USE_VENV=false \
PYTHONPATH="/app/__pypackages__/3.9/lib" \
PATH="/app/__pypackages__/3.9/bin:$PATH"