Skip to content
Snippets Groups Projects
Commit fd7961a6 authored by Corné Lukken's avatar Corné Lukken Committed by Klaas Kliffen
Browse files

Use docker base image across CI steps

parent 4124c594
Branches
No related tags found
No related merge requests found
include:
- local: "{{cookiecutter.project_slug}}/.gitlab-ci.yml"
trigger_prepare:
stage: prepare
trigger:
strategy: depend
include: "{{cookiecutter.project_slug}}/.prepare.gitlab-ci.yml"
default:
before_script:
- python --version # For debugging
- python -m pip install --upgrade pip
- pip install --upgrade cookiecutter tox twine
- cookiecutter --no-input --overwrite-if-exists -output-dir .
FROM python:3.11
RUN python -m pip install --upgrade pip
RUN pip install --upgrade cookiecutter tox twine
default:
image: python:3.10 # use latest for building/linting
image: $CI_REGISTRY_IMAGE/ci-build-runner:$CI_COMMIT_REF_SLUG
before_script:
- python --version # For debugging
- python -m pip install --upgrade pip
- pip install --upgrade tox twine
cache:
paths:
- .cache/pip
# Do not cache .tox, to recreate virtualenvs for every step
stages:
- prepare
- lint
# check if this needs to be a separate step
# - build_extensions
......@@ -22,6 +21,14 @@ stages:
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# Prepare image to run ci on
trigger_prepare:
stage: prepare
trigger:
strategy: depend
include: .prepare.gitlab-ci.yml
run_black:
stage: lint
script:
......@@ -45,9 +52,27 @@ run_pylint:
# script:
# - echo "build fortran/c/cpp extension source code"
# Basic setup for all Python versions for which we don't have a base image
.run_unit_test_version_base:
before_script:
- python --version # For debugging
- python -m pip install --upgrade pip
- pip install --upgrade tox twine
# Run all unit tests for Python versions except the base image
run_unit_tests:
extends: .run_unit_test_version_base
stage: test
image: python:3.${PY_VERSION}
script:
- tox -e py3${PY_VERSION}
parallel:
matrix: # use the matrix for testing
- PY_VERSION: [7, 8, 9, 10]
# Run code coverage on the base image thus also performing unit tests
run_unit_tests_coverage:
stage: test
image: python:3.7
script:
- tox -e coverage
artifacts:
......@@ -58,15 +83,6 @@ run_unit_tests_coverage:
paths:
- htmlcov/*
run_unit_tests:
stage: test
image: python:3.${PY_VERSION}
script:
- tox -e py3${PY_VERSION}
parallel:
matrix: # use the matrix for testing
- PY_VERSION: [7, 8, 9, 10]
package_files:
stage: package
artifacts:
......
stages:
- build
build_ci_runner_image:
stage: build
image: docker:stable
services:
- docker:dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- |
if docker pull $CI_REGISTRY_IMAGE/ci-build-runner:$CI_COMMIT_REF_SLUG; then
docker build --cache-from $CI_REGISTRY_IMAGE/ci-build-runner:$CI_COMMIT_REF_SLUG --tag $CI_REGISTRY_IMAGE/ci-build-runner:$CI_COMMIT_REF_SLUG docker/ci-runner
else
docker pull $CI_REGISTRY_IMAGE/ci-build-runner:latest || true
docker build --cache-from $CI_REGISTRY_IMAGE/ci-build-runner:latest --tag $CI_REGISTRY_IMAGE/ci-build-runner:$CI_COMMIT_REF_SLUG docker/ci-runner
fi
- docker push $CI_REGISTRY_IMAGE/ci-build-runner:$CI_COMMIT_REF_SLUG # push the image
- |
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
docker image tag $CI_REGISTRY_IMAGE/ci-build-runner:$CI_COMMIT_REF_SLUG $CI_REGISTRY_IMAGE/ci-build-runner:latest
docker push $CI_REGISTRY_IMAGE/ci-build-runner:latest
fi
FROM python:3.11
RUN python -m pip install --upgrade pip
RUN pip install --upgrade tox twine
......@@ -19,6 +19,7 @@ classifiers =
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Topic :: Internet :: WWW/HTTP
Topic :: Internet :: WWW/HTTP :: Dynamic Content
Topic :: Scientific/Engineering
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment