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: ...@@ -32,6 +32,10 @@ variables:
image: $DUNE_ENV_IMAGE image: $DUNE_ENV_IMAGE
# Run pipelines on branches
include:
- template: 'Workflows/Branch-Pipelines.gitlab-ci.yml'
# Move into top-level DUNE directory # Move into top-level DUNE directory
before_script: before_script:
- cd $DUNE_DIR - cd $DUNE_DIR
...@@ -64,13 +68,8 @@ stages: ...@@ -64,13 +68,8 @@ stages:
- test - test
- deploy - deploy
# --- Job Template for Docker in Docker (DinD) Runner Setup ---
# --- Preparation of Docker Images --- .dind:
setup:dune-env: &setup
stage: setup
only:
variables:
- $REBUILD_BASE_IMAGE # must be defined and have non-empty value
tags: tags:
- dind - dind
image: docker:stable image: docker:stable
...@@ -80,6 +79,14 @@ setup:dune-env: &setup ...@@ -80,6 +79,14 @@ setup:dune-env: &setup
DOCKER_DRIVER: overlay2 DOCKER_DRIVER: overlay2
before_script: before_script:
- $DOCKER_LOGIN - $DOCKER_LOGIN
# --- Preparation of Docker Images ---
setup:dune-env: &setup
stage: setup
extends: .dind
rules:
- changes:
- docker/dune-env.dockerfile
script: script:
- docker build -f docker/dune-env.dockerfile - docker build -f docker/dune-env.dockerfile
--build-arg PROCNUM=$CPUS_DIND --build-arg PROCNUM=$CPUS_DIND
...@@ -97,12 +104,17 @@ setup:dune-env-clang: ...@@ -97,12 +104,17 @@ setup:dune-env-clang:
- docker push ${DUNE_ENV_IMAGE}-clang - docker push ${DUNE_ENV_IMAGE}-clang
prep:update-dune: &update prep:update-dune: &update
<<: *setup
stage: prep stage: prep
extends: .dind
allow_failure: true allow_failure: true
only: rules:
- master # Run after pushes to master and tags in original repo, not forks
- tags - 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: script:
- docker build -f docker/dune-env-update.dockerfile - docker build -f docker/dune-env-update.dockerfile
--build-arg DUNE_ENV_IMAGE=$DUNE_ENV_IMAGE --build-arg DUNE_ENV_IMAGE=$DUNE_ENV_IMAGE
...@@ -255,10 +267,9 @@ test:examples: ...@@ -255,10 +267,9 @@ test:examples:
test:python-tests: test:python-tests:
<<: *test <<: *test
# May run immediately
dependencies: [] dependencies: []
# TODO: Make empty once https://gitlab.com/gitlab-org/gitlab/issues/30631 needs: []
# is resolved
needs: ["build:docs"] # Any quick job from previous stage
script: script:
- $DUNECONTROL --only=dorie configure - $DUNECONTROL --only=dorie configure
- $DUNECONTROL --only=dorie make test_python - $DUNECONTROL --only=dorie make test_python
...@@ -266,18 +277,10 @@ test:python-tests: ...@@ -266,18 +277,10 @@ test:python-tests:
# --- Deploy jobs --- # --- Deploy jobs ---
deploy:dockerhub-devel: &deploy deploy:dockerhub-devel: &deploy
stage: deploy stage: deploy
only: extends: .dind
- master@dorie/dorie rules:
tags: # Run after pushes to master in original repo, not forks
- dind - if: '$CI_COMMIT_BRANCH == "master" && $CI_PROJECT_PATH == "dorie/dorie"'
image: docker:stable
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
dependencies: []
before_script:
- $DOCKER_LOGIN
script: script:
- docker build -f docker/dorie.dockerfile - docker build -f docker/dorie.dockerfile
--build-arg BASE_IMG_VERSION=$IMAGE_VERSION --build-arg PROCNUM=$CPUS_DIND --build-arg BASE_IMG_VERSION=$IMAGE_VERSION --build-arg PROCNUM=$CPUS_DIND
...@@ -289,8 +292,9 @@ deploy:dockerhub-devel: &deploy ...@@ -289,8 +292,9 @@ deploy:dockerhub-devel: &deploy
deploy:dockerhub-stable: deploy:dockerhub-stable:
<<: *deploy <<: *deploy
only: rules:
- tags@dorie/dorie # Run after pushes to tags in original repo, not forks
- if: '$CI_COMMIT_TAG && $CI_PROJECT_PATH == "dorie/dorie"'
script: script:
- docker build -f docker/dorie.dockerfile - docker build -f docker/dorie.dockerfile
--build-arg BASE_IMG_VERSION=$IMAGE_VERSION --build-arg PROCNUM=$CPUS_DIND --build-arg BASE_IMG_VERSION=$IMAGE_VERSION --build-arg PROCNUM=$CPUS_DIND
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
* Coding style tools and instructions. * Coding style tools and instructions.
[`clang-format-hook`](https://github.com/barisione/clang-format-hooks) [`clang-format-hook`](https://github.com/barisione/clang-format-hooks)
as Git submodule !203 as Git submodule !203
* Automatically trigger DUNE Docker image builds using `rules` !213
### Changed ### Changed
......
...@@ -25,15 +25,11 @@ Both images are updated by the GitLab CI/CD Pipeline defined in ...@@ -25,15 +25,11 @@ Both images are updated by the GitLab CI/CD Pipeline defined in
[`.gitlab-ci.yml`](../gitlab-ci.yml). [`.gitlab-ci.yml`](../gitlab-ci.yml).
The `setup` build stage is builds a new DUNE environment image "from scratch". 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 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 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 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 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