Files
ETPlot/.gitlab-ci.yml
T

79 lines
2.3 KiB
YAML

# GitLab CI/CD Pipeline for Gallery Generator
# Builds Apptainer container and runs tests inside it
stages:
- build
- test
variables:
CONTAINER_IMAGE: "gallery-generator.sif"
APPTAINER_CACHE_DIR: "$CI_PROJECT_DIR/.apptainer-cache"
# Cache to speed up builds
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- .apptainer-cache/
# Build the Apptainer container
build:container:
stage: build
image: ubuntu:22.04
before_script:
- apt-get update -qq
- apt-get install -y wget curl gpg
- wget -O /tmp/apptainer.deb https://github.com/apptainer/apptainer/releases/download/v1.2.5/apptainer_1.2.5_amd64.deb
- apt-get install -y /tmp/apptainer.deb
- mkdir -p $APPTAINER_CACHE_DIR
script:
- echo "Building Apptainer container..."
- apptainer --version
- apptainer build --fakeroot $CONTAINER_IMAGE Singularity.def
- ls -lh $CONTAINER_IMAGE
artifacts:
paths:
- $CONTAINER_IMAGE
expire_in: 1 hour
# Run tests inside the container
test:pytest:
stage: test
image: ubuntu:22.04
dependencies:
- build:container
before_script:
- apt-get update -qq
- apt-get install -y wget curl gpg
- wget -O /tmp/apptainer.deb https://github.com/apptainer/apptainer/releases/download/v1.2.5/apptainer_1.2.5_amd64.deb
- apt-get install -y /tmp/apptainer.deb
script:
- echo "Running pytest inside container..."
- apptainer exec $CONTAINER_IMAGE pytest /src/tests/ -v
artifacts:
when: always
# Run tests with coverage
test:coverage:
stage: test
image: ubuntu:22.04
dependencies:
- build:container
before_script:
- apt-get update -qq
- apt-get install -y wget curl gpg
- wget -O /tmp/apptainer.deb https://github.com/apptainer/apptainer/releases/download/v1.2.5/apptainer_1.2.5_amd64.deb
- apt-get install -y /tmp/apptainer.deb
script:
- echo "Running coverage analysis inside container..."
- apptainer exec $CONTAINER_IMAGE pytest /src/tests/ --cov=/src --cov-report=xml --cov-report=term
- apptainer exec $CONTAINER_IMAGE cat /src/coverage.xml > coverage.xml || echo "No coverage.xml found"
coverage: '/TOTAL.*\s+(\d+%)$/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
paths:
- coverage.xml
expire_in: 30 days