.gitlab-ci.yml 2.38 KiB
Newer Older
Denis_P's avatar
Denis_P committed
# .gitlab-ci.yml
#
# canvas-node
Denis_P's avatar
Denis_P committed
#
# pipelines can be triggered manually in the web


stages:
    - test
Denis_P's avatar
Denis_P committed
    - build
Denis_P's avatar
Denis_P committed
variables:
  GIT_STRATEGY:                    fetch
  GIT_DEPTH:                       100
Denis_P's avatar
Denis_P committed
  CARGO_INCREMENTAL:               0
Denis_P's avatar
Denis_P committed
  CARGO_TARGET_DIR:                "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"

Denis_P's avatar
Denis_P committed
workflow:
  rules:
    - if: $CI_COMMIT_TAG
    - if: $CI_COMMIT_BRANCH

Denis_P's avatar
Denis_P committed
.collect-artifacts:                &collect-artifacts
  artifacts:
    name:                          "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
    when:                          on_success
    expire_in:                     7 days
    paths:
      - artifacts/

.docker-env:                       &docker-env
Denis_P's avatar
Denis_P committed
  image:                           paritytech/ci-linux:production
Denis_P's avatar
Denis_P committed
  before_script:
    - cargo -vV
    - rustc -vV
    - rustup show
    - bash --version
    - mkdir -p ${CARGO_TARGET_DIR}
    - sccache -s
Denis_P's avatar
Denis_P committed
  rules:
    - if: $CI_PIPELINE_SOURCE == "web"
    - if: $CI_PIPELINE_SOURCE == "schedule"
    - if: $CI_COMMIT_REF_NAME == "master"
    - if: $CI_COMMIT_REF_NAME == "tags"
    - if: $CI_COMMIT_BRANCH
    - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/                   # PRs
    - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/        # i.e. v1.0, v2.1rc1
Denis_P's avatar
Denis_P committed
  dependencies:                    []
  interruptible:                   true
  retry:
    max: 2
    when:
      - runner_system_failure
      - unknown_failure
      - api_failure
  tags:
    - linux-docker

### stage:                         test

build-test:
  stage:                           test
  <<:                              *docker-env
  script:
    - cargo build --release
    - cargo test --release --all
Denis_P's avatar
Denis_P committed

build:
  stage:                           build
  <<:                              *docker-env
  <<:                              *collect-artifacts
  rules:
    - if: $CI_PIPELINE_SOURCE == "web"
    - if: $CI_PIPELINE_SOURCE == "schedule"
    - if: $CI_COMMIT_REF_NAME == "tags"
    - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/        # i.e. v1.0, v2.1rc1
    - if: $CI_COMMIT_REF_NAME == "master"
      when: manual
      allow_failure: true
    - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/                   # PRs
      when: manual
      allow_failure: true
  script:
    - cargo build --release
  after_script:
    - mkdir -p ./artifacts/canvas/
    - cp ${CARGO_TARGET_DIR}/release/canvas ./artifacts/canvas/