.gitlab-ci.yml 3.95 KiB
Newer Older
image: parity/rust:gitlab-ci
variables:
  GIT_DEPTH: "3"
  SIMPLECOV: "true"
  RUST_BACKTRACE: "1"
  RUSTFLAGS: " -C link-arg=-s"
  CARGOFLAGS: ""
  GIT_STRATEGY:                    pull
  GIT_SUBMODULE_STRATEGY:          recursive
  CARGO_TARGET:                    x86_64-unknown-linux-gnu
  key: "$CI_BUILD_STAGE-$CI_BUILD_REF_NAME"
  untracked: true
.test_tags:              &test_tags #branches and tags for test stage
    tags:
      - linux-docker

.no_git:                           &no_git # disable git strategy
  variables:
    GIT_STRATEGY:                  none
    GIT_SUBMODULE_STRATEGY:        none

.releaseable_branches:             # list of git refs for building GitLab artifacts (think "pre-release binaries")
  only:                            &releaseable_branches
    - stable
    - beta
    - tags
    - schedules
    - master

.collect_artifacts:                &collect_artifacts
  artifacts:
    name:                          "${CI_JOB_NAME}_${SCHEDULE_TAG:-${CI_COMMIT_REF_NAME}}"
    when:                          on_success
    expire_in:                     12 mos
    paths:
      - artifacts/

linux-stable-test:
    - rustup default stable
Svyatoslav Nikolsky's avatar
Svyatoslav Nikolsky committed
    - echo 'Building in release mode' && echo -en 'gitlab_fold:start:build.release'
    - time cargo build --release && strip target/release/pbtc
    - echo 'gitlab_fold:end:build.release'
    - echo 'Running regtests from ./tools/regtests.sh' && echo -en 'gitlab_fold:start:regtests'
    - time ./tools/regtests.sh
    - echo -en 'gitlab_fold:end:regtests'
    - echo 'Running bench from ./tools/bench.sh' && echo -en 'gitlab_fold:start:bench'
    - time ./tools/bench.sh
    - echo -en 'gitlab_fold:end:bench'
    - echo 'Running tests' && echo -en 'gitlab_fold:start:tests'
    - echo -en 'gitlab_fold:end:tests'
linux-beta-test:
  script:
    - rustup default beta
    - echo 'Running check'
    - time cargo check
    - echo 'End check'
  allow_failure: true
linux-nightly-test:
    - rustup default nightly
    - echo 'Running check'
    - time cargo check
    - echo 'End check'
  allow_failure: true
  stage: build
  only:                              *releaseable_branches
  script:
    - git submodule update --init
    - echo 'Building in release mode' && echo -en 'gitlab_fold:start:build.release'
    - rustup default stable
    - time cargo build --target $CARGO_TARGET -p pbtc --release
    - md5sum target/$CARGO_TARGET/release/pbtc > pbtc.md5
    - echo -en 'gitlab_fold:end:build.release'
5chdn's avatar
5chdn committed
    - echo 'Running regtests from ./tools/regtests.sh' && echo -en 'gitlab_fold:start:regtests'
    - ./tools/regtests.sh
    - echo -en 'gitlab_fold:end:regtests'
5chdn's avatar
5chdn committed
    - echo 'Running bench from ./tools/bench.sh' && echo -en 'gitlab_fold:start:bench'
    - ./tools/bench.sh
    - echo -en 'gitlab_fold:end:bench'
    - sh tools/deb_build.sh amd64
    - cp target/$CARGO_TARGET/release/pbtc deb/usr/bin/pbtc
    - export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n")
    - dpkg-deb -b deb "pbtc_"$VER"_amd64.deb"
    - md5sum "pbtc_"$VER"_amd64.deb" > "pbtc_"$VER"_amd64.deb.md5"
    - echo "_____ Post-processing binaries _____"
    - rm -rf artifacts/*
    - mkdir -p artifacts/$CARGO_TARGET
    - cd artifacts/$CARGO_TARGET
    - cp -v ../../target/$CARGO_TARGET/release/pbtc pbtc
    - cp -v ../../pbtc_"$VER"_amd64.deb pbtc_"$VER"_amd64.deb
    - cp -v ../../pbtc.md5 pbtc.md5
    - cp -v ../../pbtc_"$VER"_amd64.deb.md5 pbtc_"$VER"_amd64.deb.md5
  tags:
    - linux-docker
  <<: *collect_artifacts

publish-docker:
  stage: publish
  only:                            *releaseable_branches
  <<:                              *no_git
  cache:                           {}
  dependencies:
    - build-linux
    - tools/docker_build.sh