https://gitlab.com/tezos/tezos
Raw File
Tip revision: 7dfdff4236e5834a08f49c71aca82dd905bc782c authored by Ole Krüger on 19 January 2023, 18:51:05 UTC
WIP: Tree kind
Tip revision: 7dfdff4
.gitlab-ci.yml
---

# General setup
default:
  interruptible: true

# Basic configuration to guard against double-pipelines
workflow:
  rules:
    # This workflow entry allows pipelines for schedules events in which case it checks the
    # CI_PIPELINE_SOURCE which is automatically set by Gitlab.
    # See https://docs.gitlab.com/ee/ci/yaml/README.html#workflow for additional
    # details.
    - if: '$CI_PIPELINE_SOURCE == "schedule" && $TZ_SCHEDULE_KIND == "EXTENDED_TESTS"'
      when: always
    # Switch between branch pipelines and merge request pipelines.
    # https://docs.gitlab.com/13.12/ee/ci/yaml/README.html#switch-between-branch-pipelines-and-merge-request-pipelines
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
    - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
      when: never
    # No branch pipelines outside of the tezos namespace, except for testing releases.
    # The goal is to avoid triggering two pipelines for each MR:
    # - one when pushing the branch, before the MR exists;
    # - and one when the MR is created.
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != "latest-release-test" && $CI_PROJECT_NAMESPACE != "tezos"'
      when: never
    # This workflow entry allows pipelines for push events (including force-push, push of fixup commits, rebase, etc.)
    - if: '$CI_PIPELINE_SOURCE == "push"'
      when: always
    - when: never # default

variables:
  # /!\ CI_REGISTRY is overriden to use a private Docker registry mirror in AWS ECR
  # in GitLab namespaces `nomadic-labs` and `tezos`
  ## This value MUST be the same as `opam_repository_tag` in `scripts/version.sh`
  build_deps_image_version: fb2c027f2a7ccc71d8f8b0f974ee8cdb9f86743e
  build_deps_image_name: "${CI_REGISTRY}/tezos/opam-repository"
  GIT_STRATEGY: fetch
  GIT_DEPTH: "1"
  GET_SOURCES_ATTEMPTS: "2"
  ARTIFACT_DOWNLOAD_ATTEMPTS: "2"
  # Sets the number of tries before failing opam downloads.
  OPAMRETRIES: "5"

  # An addition to working around a bug in gitlab-runner's default
  # unzipping implementation (https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27496),
  # this setting cuts cache creation time.
  FF_USE_FASTZIP: "true"

# Image templates
.image_template__runtime_build_test_dependencies_template:
  image: ${build_deps_image_name}:runtime-build-test-dependencies--${build_deps_image_version}

.image_template__runtime_build_dependencies_template:
  image: ${build_deps_image_name}:runtime-build-dependencies--${build_deps_image_version}

.image_template__runtime_prebuild_dependencies_template:
  image: ${build_deps_image_name}:runtime-prebuild-dependencies--${build_deps_image_version}

# Match GitLab executors version and directly use the Docker socket
# The Docker daemon is already configured, experimental features are enabled
# The following environment variables are already set:
# - BUILDKIT_PROGRESS
# - DOCKER_DRIVER
# - DOCKER_VERSION
# https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-socket-binding
.image_template__docker:
  # https://gitlab.com/tezos/docker-images/ci-docker
  image: "${CI_REGISTRY}/tezos/docker-images/ci-docker:v1.6.0"

.image_template__alpine:
  image: alpine:3.15

# The "manual" stage exists to fix a UI problem that occurs when mixing
# manual and non-manual jobs.
stages:
  - trigger
  - sanity
  - build
  - test
  - test_coverage
  - packaging
  - doc
  - prepare_release
  - publish_release_gitlab
  - publish_release
  - manual

# Trigger
#
# §1: The purpose of this job is to launch the CI manually in certain cases.
# The objective is not to run computing when it is not
# necessary and the decision to do so belongs to the developer
#
# §2: Gitlab CI needs at least one job definition, otherwise we're stuck with
# this error: 'Jobs config should contain at least one visible job'
trigger:
  extends:
    - .image_template__runtime_build_test_dependencies_template
  stage: trigger
  rules:
    - if: '($CI_PIPELINE_SOURCE == "merge_request_event") && ($CI_PROJECT_NAMESPACE == "tezos") && ($CI_MERGE_REQUEST_ASSIGNEES !~ /nomadic-margebot/)'
      when: manual
    - when: always
  allow_failure: false
  timeout: "10m"
  script:
    - echo 'Trigger pipeline 🤠'

include:

  # Common templates
  - local: .gitlab/ci/jobs/shared/templates.yml

  # Before merging
  - local: .gitlab/ci/pipelines/before_merging.yml
    rules:
      - if: '($CI_PIPELINE_SOURCE == "merge_request_event") && ($CI_PROJECT_NAMESPACE == "tezos")'

  # Latest release and test latest release
  - local: .gitlab/ci/pipelines/latest_release.yml
    rules:
      - if: '($CI_COMMIT_BRANCH == "latest-release") && ($CI_PROJECT_NAMESPACE == "tezos")'

  # Test latest release
  - local: .gitlab/ci/pipelines/latest_release_test.yml
    rules:
      - if: '($CI_COMMIT_BRANCH  == "latest-release-test") && ($CI_PROJECT_NAMESPACE != "tezos")'

  # Master branch
  - local: .gitlab/ci/pipelines/master_branch.yml
    rules:
      - if: '($CI_PROJECT_NAMESPACE == "tezos") && ($CI_COMMIT_BRANCH == "master")'

  # Release tag
  - local: .gitlab/ci/pipelines/release_tag.yml
    rules:
      - if: '($CI_COMMIT_TAG =~ /^v\d+\.\d+(?:\-rc\d+)?$/) && ($CI_PROJECT_NAMESPACE == "tezos")'

  # Test release tag
  - local: .gitlab/ci/pipelines/release_tag_test.yml
    rules:
      - if: '($CI_COMMIT_TAG =~ /^v\d+\.\d+(?:\-rc\d+)?$/) && ($CI_PROJECT_NAMESPACE != "tezos")'

  # Scheduled pipeline for extended tests
  - local: .gitlab/ci/pipelines/schedule_extended_test.yml
    rules:
      - if: '($CI_PIPELINE_SOURCE == "schedule") && ($TZ_SCHEDULE_KIND == "EXTENDED_TESTS")'
back to top