From cf37c10432013049fe7da21496fbbc8c272db05d Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Fri, 30 Apr 2021 12:19:11 +0200 Subject: [PATCH] feat/ci: add our gitlab-ci.yml --- .gitlab-ci.yml | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..a07f6d18 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,104 @@ +# .gitlab-ci.yml +# +# sccache + +stages: + - check + - test + - deploy + +variables: + GIT_STRATEGY: fetch + GIT_DEPTH: 100 + CARGO_INCREMENTAL: 0 + RUST_BACKTRACE: 1 + # this var is changed to "-:staging" when the CI image gets rebuilt + # read more https://github.com/paritytech/scripts/pull/244 + CI_IMAGE: "paritytech/sccache-ci-ubuntu:staging" # temporary override + +workflow: + rules: + - if: $CI_COMMIT_TAG + - if: $CI_COMMIT_BRANCH + +.docker-env: &docker-env + image: "${CI_IMAGE}" + before_script: + - which gcc && gcc --version + - which clang && clang --version + - rustc +stable --version + - rustc +nightly --version + - sccache -s + retry: + max: 2 + when: + - runner_system_failure + - unknown_failure + - api_failure + interruptible: true + tags: + - linux-docker + 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_REF_NAME =~ /^[0-9]+$/ # PRs + - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 + +.collect-artifacts: &collect-artifacts + artifacts: + name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}" + when: on_success + expire_in: 7 days + paths: + - artifacts/ + +#### stage: check + +fmt: + <<: *docker-env + stage: check + script: + - cargo fmt -- --check + allow_failure: true + +clippy: + <<: *docker-env + stage: check + script: + - cargo clippy --all-targets + allow_failure: true + +#### stage: test + +nightly-test: + <<: *docker-env + stage: test + variables: + FEATURES: "unstable" + script: + - cargo +nightly build --verbose --features="${FEATURES}" || exit 1 + - cargo +nightly test --workspace --verbose --features="${FEATURES}" + +stable-test: + <<: *docker-env + stage: test + variables: + FEATURES: "" + script: + - cargo +stable build --verbose --features="${FEATURES}" || exit 1 + - cargo +stable test --workspace --verbose --features="${FEATURES}" + +# For now simply collect artifacts +artifacts: + <<: *docker-env + <<: *collect-artifacts + stage: deploy + variables: + FEATURES: "dist-client,dist-server" + script: + - cargo +stable build --release --features="${FEATURES}" + # collect artifacts + - mkdir -p ./artifacts/sccache/ + - mv ./target/release/sccache ./artifacts/sccache/.