Commit 350d6a57 authored by Santiago Ospina De Los Ríos's avatar Santiago Ospina De Los Ríos

Merge branch '203-use-more-elaborate-rules-in-gitlab-ci-cd-configuration' into 'master'

Resolve "Use more elaborate "rules" in GitLab CI/CD configuration"

Closes #203

See merge request !213
parents 52d601b3 bd386e4a
......@@ -32,6 +32,10 @@ variables:
image: $DUNE_ENV_IMAGE
# Run pipelines on branches
include:
- template: 'Workflows/Branch-Pipelines.gitlab-ci.yml'
# Move into top-level DUNE directory
before_script:
- cd $DUNE_DIR
......@@ -64,13 +68,8 @@ stages:
- test
- deploy
# --- Preparation of Docker Images ---
setup:dune-env: &setup
stage: setup
only:
variables:
- $REBUILD_BASE_IMAGE # must be defined and have non-empty value
# --- Job Template for Docker in Docker (DinD) Runner Setup ---
.dind:
tags:
- dind
image: docker:stable
......@@ -80,6 +79,14 @@ setup:dune-env: &setup
DOCKER_DRIVER: overlay2
before_script:
- $DOCKER_LOGIN
# --- Preparation of Docker Images ---
setup:dune-env: &setup
stage: setup
extends: .dind
rules:
- changes:
- docker/dune-env.dockerfile
script:
- docker build -f docker/dune-env.dockerfile
--build-arg PROCNUM=$CPUS_DIND
......@@ -97,12 +104,17 @@ setup:dune-env-clang:
- docker push ${DUNE_ENV_IMAGE}-clang
prep:update-dune: &update
<<: *setup
stage: prep
extends: .dind
allow_failure: true
only:
- master
- tags
rules:
# Run after pushes to master and tags in original repo, not forks
- if: '$CI_COMMIT_BRANCH == "master" && $CI_PROJECT_PATH == "dorie/dorie"'
- if: '$CI_COMMIT_TAG && $CI_PROJECT_PATH == "dorie/dorie"'
# Run after Dockerfile changed. Do not allow failure then.
- changes:
- docker/dune-env-update.dockerfile
allow_failure: false
script:
- docker build -f docker/dune-env-update.dockerfile
--build-arg DUNE_ENV_IMAGE=$DUNE_ENV_IMAGE
......@@ -255,10 +267,9 @@ test:examples:
test:python-tests:
<<: *test
# May run immediately
dependencies: []
# TODO: Make empty once https://gitlab.com/gitlab-org/gitlab/issues/30631
# is resolved
needs: ["build:docs"] # Any quick job from previous stage
needs: []
script:
- $DUNECONTROL --only=dorie configure
- $DUNECONTROL --only=dorie make test_python
......@@ -266,18 +277,10 @@ test:python-tests:
# --- Deploy jobs ---
deploy:dockerhub-devel: &deploy
stage: deploy
only:
- master@dorie/dorie
tags:
- dind
image: docker:stable
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
dependencies: []
before_script:
- $DOCKER_LOGIN
extends: .dind
rules:
# Run after pushes to master in original repo, not forks
- if: '$CI_COMMIT_BRANCH == "master" && $CI_PROJECT_PATH == "dorie/dorie"'
script:
- docker build -f docker/dorie.dockerfile
--build-arg BASE_IMG_VERSION=$IMAGE_VERSION --build-arg PROCNUM=$CPUS_DIND
......@@ -289,8 +292,9 @@ deploy:dockerhub-devel: &deploy
deploy:dockerhub-stable:
<<: *deploy
only:
- tags@dorie/dorie
rules:
# Run after pushes to tags in original repo, not forks
- if: '$CI_COMMIT_TAG && $CI_PROJECT_PATH == "dorie/dorie"'
script:
- docker build -f docker/dorie.dockerfile
--build-arg BASE_IMG_VERSION=$IMAGE_VERSION --build-arg PROCNUM=$CPUS_DIND
......
......@@ -8,6 +8,7 @@
* Coding style tools and instructions.
[`clang-format-hook`](https://github.com/barisione/clang-format-hooks)
as Git submodule !203
* Automatically trigger DUNE Docker image builds using `rules` !213
### Changed
......
......@@ -25,15 +25,11 @@ Both images are updated by the GitLab CI/CD Pipeline defined in
[`.gitlab-ci.yml`](../gitlab-ci.yml).
The `setup` build stage is builds a new DUNE environment image "from scratch".
It is triggered by running a pipeline with the CI variable `REBUILD_BASE_IMAGE`
set to a non-empty value. This is achieved by manually starting the pipeline
from the GitLab web interface ("CI/CD" - "Pipelines" - "Run Pipeline") and
entering the variable as well as an arbitrary value. This should only be
necessary if dependencies or their required versions change.
The `prep` stage updates all APT and DUNE packages in the DUNE environment image
and is run whenever a pipeline includes the deployment of a new application
image.
image. Both stages are automatically triggered if the respective Dockerfiles
are changed. The `prep` stage is additionally executed for every push to
the `master` branch or a tag.
The `deploy` stage deploys DORiE application images. It compiles DORiE into the
DUNE environment image. This stage is only run if tags are pushed or commits
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment