diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e748a08bf9c7e39f047d05fdf64b563bf51afff1..c6b424fc3d12a20fc7e22c099251685cee1cc1d3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,17 @@ -image: registry.gitlab.com/arkindex/backend/base:django-3.1.1 stages: - test - build - deploy +# GitLab provides a template to ensure pipelines run only for branches and tags, not for merge requests +# This prevents duplicate pipelines in merge requests. +# See https://docs.gitlab.com/ee/ci/troubleshooting.html#job-may-allow-multiple-pipelines-to-run-for-a-single-action +include: + - template: 'Workflows/Branch-Pipelines.gitlab-ci.yml' + # For jobs that run backend scripts directly .backend-setup: + image: registry.gitlab.com/arkindex/backend/base:django-3.1.1 cache: paths: - .cache/pip @@ -19,6 +25,13 @@ stages: - pip install -r tests-requirements.txt codecov - "echo 'database: {host: postgres, port: 5432}' > $CONFIG_PATH" + # Those jobs require the base image; they might fail if the image is not up to date. + # Allow them to fail when building a new base image, to prevent them from blocking a new base image build + rules: + - if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^base-.*/' + allow_failure: true + - when: on_success + variables: # For the postgres image POSTGRES_DB: arkindex_dev @@ -154,6 +167,7 @@ backend-build-binary: backend-static-deploy: stage: deploy + image: python:3-slim # Run this on any version tag except base images rules: @@ -174,6 +188,7 @@ backend-static-deploy: backend-openapi-deploy: stage: deploy + image: python:3-slim # Run on master updates only only: @@ -190,8 +205,8 @@ backend-openapi-deploy: - aws s3 cp output/schema.yml s3://teklia-assets-release/arkindex/openapi.yml sentry-release: - image: getsentry/sentry-cli stage: deploy + image: getsentry/sentry-cli rules: - if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG !~ /^base-.*/'