Unverified Commit e28160a1 authored by Denis_P's avatar Denis_P 🏑 Committed by GitHub
Browse files

CI improvements (#228)

* change (CI): cache pre-population script; use of cargo home and cargo target caches; rules instead only

* fix (CI): wrong pasta

* fix (CI): persimmons to the pre_pop script
parent 934bc35a
Pipeline #110813 passed with stages
in 17 minutes and 3 seconds
......@@ -7,19 +7,16 @@ stages:
variables:
GIT_STRATEGY: fetch
CARGO_INCREMENTAL: 0
GIT_DEPTH: 3
GIT_DEPTH: "100"
CARGO_HOME: "/ci-cache/${CI_PROJECT_NAME}/cargo/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
CARGO_INCREMENTAL: 0
CI_SERVER_NAME: "GitLab CI"
.only: &only
only:
- triggers
- tags
- master
- schedules
- web
- /^[0-9]+$/
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
.docker-env: &docker-env
image: paritytech/ci-linux:production
......@@ -27,9 +24,17 @@ variables:
- cargo -vV
- rustc -vV
- rustup show
- cargo --version
- bash --version
- ./scripts/pre_cache.sh
- sccache -s
dependencies: []
rules:
- if: $CI_PIPELINE_SOURCE == "trigger"
- 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
interruptible: true
retry:
max: 2
......@@ -44,7 +49,6 @@ variables:
test-rust-stable:
stage: test
<<: *only
<<: *docker-env
script:
- time cargo test --verbose --all --features bit-vec,generic-array,derive
......@@ -52,7 +56,6 @@ test-rust-stable:
test-rust-stable-no_derive:
stage: test
<<: *only
<<: *docker-env
script:
- time cargo test --verbose --features bit-vec,generic-array
......@@ -60,7 +63,6 @@ test-rust-stable-no_derive:
check-rust-stable-no_derive_no_std_full:
stage: test
<<: *only
<<: *docker-env
script:
- time cargo check --verbose --no-default-features --features bit-vec,generic-array,full
......@@ -68,7 +70,6 @@ check-rust-stable-no_derive_no_std_full:
check-rust-stable-no_derive_no_std:
stage: test
<<: *only
<<: *docker-env
script:
- time cargo check --verbose --no-default-features --features bit-vec,generic-array
......@@ -76,7 +77,6 @@ check-rust-stable-no_derive_no_std:
check-rust-stable-no_derive_full:
stage: test
<<: *only
<<: *docker-env
script:
- time cargo check --verbose --features bit-vec,generic-array,full
......@@ -84,7 +84,6 @@ check-rust-stable-no_derive_full:
bench-rust-nightly:
stage: test
<<: *only
<<: *docker-env
script:
- time cargo +nightly bench --features bit-vec,generic-array,derive
......@@ -95,10 +94,11 @@ bench-rust-nightly:
build-linux-ubuntu-amd64:
stage: build
<<: *docker-env
only:
- master
- tags
- web
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME == "tags"
script:
- cargo build --verbose --release --features bit-vec,generic-array,derive
- sccache -s
#!/bin/bash
set -u
# if there is no directory for this $CI_COMMIT_REF_NAME/$CI_JOB_NAME
# create such directory and
# copy recursively all the files from the newest dir which has $CI_JOB_NAME, if it exists
# caches are in /ci-cache/${CI_PROJECT_NAME}/${2}/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}
function prepopulate {
if [[ ! -d $1 ]]; then
mkdir -p "/ci-cache/$CI_PROJECT_NAME/$2/$CI_COMMIT_REF_NAME";
FRESH_CACHE=$(find "/ci-cache/$CI_PROJECT_NAME/$2" -mindepth 2 -maxdepth 2 \
-type d -name "$CI_JOB_NAME" -exec stat --printf="%Y\t%n\n" {} \; |sort -n -r |head -1 |cut -f2);
if [[ -d $FRESH_CACHE ]]; then
echo "____Using" "$FRESH_CACHE" "to prepopulate the cache____";
time cp -r "$FRESH_CACHE" "$1";
else
echo "_____No such $2 dir, proceeding from scratch_____";
fi
else
echo "____No need to prepopulate $2 cache____";
fi
}
# CARGO_HOME cache was moved to the same "project/cache_type/branch_name/job_name" level as
# CARGO_TARGET_DIR because of frequent weird data-race issues. This just means that the same cache that
# would have been used for the entire pipeline will be duplicated for the each job.
prepopulate "$CARGO_HOME" cargo
prepopulate "$CARGO_TARGET_DIR" targets
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment