# .gitlab-ci.yml # # substrate # # pipelines can be triggered manually in the web # # Currently the file is divided into subfiles. Each stage has a different file which # can be found here: scripts/ci/gitlab/pipeline/.yml # # Instead of YAML anchors "extends" is used. # Useful links: # https://docs.gitlab.com/ee/ci/yaml/index.html#extends # https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html#reference-tags # # SAMPLE JOB TEMPLATE - This is not a complete example but is enough to build a # simple CI job. For full documentation, visit https://docs.gitlab.com/ee/ci/yaml/ # # my-example-job: # stage: test # One of the stages listed below this job (required) # image: paritytech/tools:latest # Any docker image (required) # allow_failure: true # Allow the pipeline to continue if this job fails (default: false) # needs: # - job: test-linux # Any jobs that are required to run before this job (optional) # variables: # MY_ENVIRONMENT_VARIABLE: "some useful value" # Environment variables passed to the job (optional) # script: # - echo "List of shell commands to run in your job" # - echo "You can also just specify a script here, like so:" # - ./scripts/ci/gitlab/my_amazing_script.sh stages: - check - test - build - publish - deploy - notify workflow: rules: - if: $CI_COMMIT_TAG - if: $CI_COMMIT_BRANCH variables: GIT_STRATEGY: fetch GIT_DEPTH: 100 CARGO_INCREMENTAL: 0 DOCKER_OS: "debian:stretch" ARCH: "x86_64" CI_IMAGE: "paritytech/ci-linux:production" RUSTY_CACHIER_SINGLE_BRANCH: master RUSTY_CACHIER_DONT_OPERATE_ON_MAIN_BRANCH: "true" default: retry: max: 2 when: - runner_system_failure - unknown_failure - api_failure interruptible: true cache: {} .collect-artifacts: artifacts: name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}" when: on_success expire_in: 7 days paths: - artifacts/ .collect-artifacts-short: artifacts: name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}" when: on_success expire_in: 3 hours paths: - artifacts/ .kubernetes-env: image: "${CI_IMAGE}" tags: - kubernetes-parity-build .rust-info-script: script: - rustup show - cargo --version - rustup +nightly show - cargo +nightly --version .pipeline-stopper-vars: script: - echo "Collecting env variables for the cancel-pipeline job" - echo "FAILED_JOB_URL=${CI_JOB_URL}" > pipeline-stopper.env - echo "FAILED_JOB_NAME=${CI_JOB_NAME}" >> pipeline-stopper.env - echo "PR_NUM=${CI_COMMIT_REF_NAME}" >> pipeline-stopper.env .pipeline-stopper-artifacts: artifacts: reports: dotenv: pipeline-stopper.env .docker-env: image: "${CI_IMAGE}" before_script: - !reference [.rust-info-script, script] - !reference [.rusty-cachier, before_script] - !reference [.pipeline-stopper-vars, script] after_script: - !reference [.rusty-cachier, after_script] tags: - linux-docker # rusty-cachier's hidden job. Parts of this job are used to instrument the pipeline's other real jobs with rusty-cachier # Description of the commands is available here - https://gitlab.parity.io/parity/infrastructure/ci_cd/rusty-cachier/client#description .rusty-cachier: before_script: - curl -s https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.parity.io/parity/infrastructure/ci_cd/rusty-cachier/client/-/raw/release/util/install.sh | bash - rusty-cachier environment check --gracefully - $(rusty-cachier environment inject) - rusty-cachier project mtime after_script: - env RUSTY_CACHIER_SUPRESS_OUTPUT=true rusty-cachier snapshot destroy .test-refs: rules: - if: $CI_PIPELINE_SOURCE == "web" - if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_COMMIT_REF_NAME == "master" - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 # handle the specific case where benches could store incorrect bench data because of the downstream staging runs # exclude cargo-check-benches from such runs .test-refs-check-benches: rules: - if: $CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "parent_pipeline" && $CI_IMAGE =~ /staging$/ when: never - if: $CI_PIPELINE_SOURCE == "web" - if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_COMMIT_REF_NAME == "master" - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 .test-refs-no-trigger: rules: - if: $CI_PIPELINE_SOURCE == "pipeline" when: never - if: $CI_PIPELINE_SOURCE == "web" - if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_COMMIT_REF_NAME == "master" - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 - if: $CI_COMMIT_REF_NAME =~ /^ci-release-.*$/ .test-refs-no-trigger-prs-only: rules: - if: $CI_PIPELINE_SOURCE == "pipeline" when: never - if: $CI_PIPELINE_SOURCE == "web" - if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs .test-refs-wasmer-sandbox: rules: - if: $CI_PIPELINE_SOURCE == "web" - if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_COMMIT_REF_NAME == "master" changes: - client/executor/**/* - frame/contracts/**/* - primitives/sandbox/**/* - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs changes: - client/executor/**/* - frame/contracts/**/* - primitives/sandbox/**/* - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 changes: - client/executor/**/* - frame/contracts/**/* - primitives/sandbox/**/* .build-refs: rules: - if: $CI_PIPELINE_SOURCE == "pipeline" when: never - if: $CI_PIPELINE_SOURCE == "web" - if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_COMMIT_REF_NAME == "master" - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 .nightly-pipeline: rules: # this job runs only on nightly pipeline with the mentioned variable, against `master` branch - if: $CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "schedule" && $PIPELINE == "nightly" #### stage: .pre skip-if-draft: extends: .kubernetes-env variables: CI_IMAGE: "paritytech/tools:latest" stage: .pre rules: - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs script: - echo "Commit message is ${CI_COMMIT_MESSAGE}" - echo "Ref is ${CI_COMMIT_REF_NAME}" - echo "pipeline source is ${CI_PIPELINE_SOURCE}" - ./scripts/ci/gitlab/skip_if_draft.sh allow_failure: true include: # check jobs - scripts/ci/gitlab/pipeline/check.yml # tests jobs - scripts/ci/gitlab/pipeline/test.yml # build jobs - scripts/ci/gitlab/pipeline/build.yml # publish jobs - scripts/ci/gitlab/pipeline/publish.yml #### stage: deploy deploy-prometheus-alerting-rules: stage: deploy needs: - job: test-prometheus-alerting-rules artifacts: false allow_failure: true trigger: project: parity/infrastructure/cloud-infra variables: SUBSTRATE_CI_COMMIT_NAME: "${CI_COMMIT_REF_NAME}" SUBSTRATE_CI_COMMIT_REF: "${CI_COMMIT_SHORT_SHA}" UPSTREAM_TRIGGER_PROJECT: "${CI_PROJECT_PATH}" rules: - if: $CI_PIPELINE_SOURCE == "pipeline" when: never - if: $CI_COMMIT_REF_NAME == "master" changes: - .gitlab-ci.yml - ./scripts/ci/monitoring/**/* #### stage: notify # This job notifies rusty-cachier about the latest commit with the cache. # This info is later used for the cache distribution and an overlay creation. # Note that we don't use any .rusty-cachier references as we assume that a pipeline has reached this stage with working rusty-cachier. rusty-cachier-notify: stage: notify extends: .kubernetes-env variables: CI_IMAGE: paritytech/rusty-cachier-env:latest GIT_STRATEGY: none dependencies: [] script: - curl -s https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.parity.io/parity/infrastructure/ci_cd/rusty-cachier/client/-/raw/release/util/install.sh | bash - rusty-cachier cache notify #### stage: .post # This job cancels the whole pipeline if any of provided jobs fail. # In a DAG, every jobs chain is executed independently of others. The `fail_fast` principle suggests # to fail the pipeline as soon as possible to shorten the feedback loop. .cancel-pipeline-template: stage: .post rules: - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs when: on_failure variables: PROJECT_ID: "${CI_PROJECT_ID}" PROJECT_NAME: "${CI_PROJECT_NAME}" PIPELINE_ID: "${CI_PIPELINE_ID}" FAILED_JOB_URL: "${FAILED_JOB_URL}" FAILED_JOB_NAME: "${FAILED_JOB_NAME}" PR_NUM: "${PR_NUM}" trigger: project: "parity/infrastructure/ci_cd/pipeline-stopper" # need to copy jobs this way because otherwise gitlab will wait # for all 3 jobs to finish instead of cancelling if one fails cancel-pipeline-test-linux-stable1: extends: .cancel-pipeline-template needs: - job: "test-linux-stable 1/3" cancel-pipeline-test-linux-stable2: extends: .cancel-pipeline-template needs: - job: "test-linux-stable 2/3" cancel-pipeline-test-linux-stable3: extends: .cancel-pipeline-template needs: - job: "test-linux-stable 3/3" cancel-pipeline-cargo-check-benches1: extends: .cancel-pipeline-template needs: - job: "cargo-check-benches 1/2" cancel-pipeline-cargo-check-benches2: extends: .cancel-pipeline-template needs: - job: "cargo-check-benches 2/2" cancel-pipeline-test-linux-stable-int: extends: .cancel-pipeline-template needs: - job: test-linux-stable-int cancel-pipeline-cargo-check-subkey: extends: .cancel-pipeline-template needs: - job: cargo-check-subkey cancel-pipeline-check-tracing: extends: .cancel-pipeline-template needs: - job: check-tracing