From 82a148a99b2e73de7365a8e095b5e7d498e70b5b Mon Sep 17 00:00:00 2001 From: TriplEight Date: Mon, 11 Mar 2019 15:26:35 +0100 Subject: [PATCH] Tests parallelized (#10452) * tests splitted, phase 1 * typo * fix wrong launch commands * typos * rearrangements * use `nproc` function for threads * use nproc for threads * let theads be auto, build-andriod no more in regular run * split val chain and cargo check * renamed some files * wrong phase * check rust files before test jobs * lint error * rust files modivied var * test except changes * add rust_changes except * lint error * fixes * .gitlab-ci.yml can't be excluded * pipeline shouldn't start * pipeline must go * pipeline must go 2 * pipeline must go 3 * pipeline must go 4 * pipeline must go 5 * pipeline must go 6 * pipeline must go 7 * pipeline must not go 1 * pipeline must go 8 * avoid skippng tests yet, reintroducing them after the caching * test theory * parallelized cargo check with combusting helicopters * less uploads * alias for cargo checks * nice template --- .gitlab-ci.yml | 69 +++++++++++----- .../gitlab/{build-unix.sh => build-linux.sh} | 0 .../gitlab/{test-all.sh => rust-changes.sh} | 4 +- scripts/gitlab/test-cpp.sh | 17 ++++ scripts/gitlab/test-linux.sh | 12 +++ .../validate-chainspecs.sh} | 9 ++- test.sh | 79 ------------------- 7 files changed, 87 insertions(+), 103 deletions(-) rename scripts/gitlab/{build-unix.sh => build-linux.sh} (100%) rename scripts/gitlab/{test-all.sh => rust-changes.sh} (87%) create mode 100755 scripts/gitlab/test-cpp.sh create mode 100755 scripts/gitlab/test-linux.sh rename scripts/{validate_chainspecs.sh => gitlab/validate-chainspecs.sh} (51%) delete mode 100755 test.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 198856423..079b8ed8f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,8 +24,7 @@ variables: - tags - schedules - -.collect_artifacts: &collect_artifacts +.collect_artifacts: &collect_artifacts artifacts: name: "${CI_JOB_NAME}_${SCHEDULE_TAG:-${CI_COMMIT_REF_NAME}}" when: on_success @@ -33,34 +32,66 @@ variables: paths: - artifacts/ -test-linux: - stage: test - variables: - RUN_TESTS: all - script: - - scripts/gitlab/test-all.sh +.docker-cache-status: &docker-cache-status + dependencies: [] + before_script: + - sccache -s + after_script: - sccache -s tags: - linux-docker -test-audit: + +cargo-check 0 3: + stage: test + <<: *docker-cache-status + script: + - time cargo check --target $CARGO_TARGET --locked --no-default-features + +cargo-check 1 3: + stage: test + <<: *docker-cache-status + script: + - time cargo check --target $CARGO_TARGET --locked --manifest-path util/io/Cargo.toml --no-default-features + +cargo-check 2 3: + stage: test + <<: *docker-cache-status + script: + - time cargo check --target $CARGO_TARGET --locked --manifest-path util/io/Cargo.toml --features "mio" + +cargo-audit: stage: test script: - - set -e - - set -u - cargo audit tags: - linux-docker +validate-chainspecs: + stage: test + <<: *docker-cache-status + script: + - ./scripts/gitlab/validate-chainspecs.sh + +test-cpp: + stage: build + <<: *docker-cache-status + script: + - ./scripts/gitlab/test-cpp.sh + +test-linux: + stage: build + <<: *docker-cache-status + script: + - ./scripts/gitlab/test-linux.sh + build-linux: &build-linux stage: build only: *releaseable_branches + <<: *docker-cache-status script: - - scripts/gitlab/build-unix.sh - - sccache -s + - scripts/gitlab/build-linux.sh <<: *collect_artifacts - tags: - - linux-docker build-linux-i386: <<: *build-linux @@ -88,7 +119,7 @@ build-darwin: CC: gcc CXX: g++ script: - - scripts/gitlab/build-unix.sh + - scripts/gitlab/build-linux.sh tags: - rust-osx <<: *collect_artifacts @@ -203,14 +234,12 @@ publish-docs: - linux-docker build-android: - stage: optional + stage: build image: parity/rust-android:gitlab-ci variables: CARGO_TARGET: armv7-linux-androideabi - dependencies: [] script: - - scripts/gitlab/build-unix.sh + - scripts/gitlab/build-linux.sh tags: - linux-docker - allow_failure: true <<: *collect_artifacts diff --git a/scripts/gitlab/build-unix.sh b/scripts/gitlab/build-linux.sh similarity index 100% rename from scripts/gitlab/build-unix.sh rename to scripts/gitlab/build-linux.sh diff --git a/scripts/gitlab/test-all.sh b/scripts/gitlab/rust-changes.sh similarity index 87% rename from scripts/gitlab/test-all.sh rename to scripts/gitlab/rust-changes.sh index 925124b7a..236a20d59 100755 --- a/scripts/gitlab/test-all.sh +++ b/scripts/gitlab/rust-changes.sh @@ -1,7 +1,9 @@ #!/bin/bash +echo "________Running rust_changes.sh________" set -e # fail on any error set -u # treat unset variables as error +echo "__________Checking if Rust files were changed__________" git log --graph --oneline --decorate=short -n 10 case ${SCHEDULE_TAG:-${CI_COMMIT_REF_NAME}} in @@ -26,5 +28,3 @@ then fi rustup show - -exec ./test.sh diff --git a/scripts/gitlab/test-cpp.sh b/scripts/gitlab/test-cpp.sh new file mode 100755 index 000000000..9f825ec8c --- /dev/null +++ b/scripts/gitlab/test-cpp.sh @@ -0,0 +1,17 @@ +#!/bin/bash +echo "________Running test-cpp.sh________" +set -e # fail on any error +set -u # treat unset variables as error +#use nproc `linux only +THREADS=$(nproc) + +echo "________Running the C++ example________" +DIR=parity-clib/examples/cpp/build +mkdir -p $DIR +cd $DIR +cmake .. +make -j $THREADS +# Note: we don't try to run the example because it tries to sync Kovan, and we don't want +# that to happen on CI +cd - +rm -rf $DIR diff --git a/scripts/gitlab/test-linux.sh b/scripts/gitlab/test-linux.sh new file mode 100755 index 000000000..6a98d2f7b --- /dev/null +++ b/scripts/gitlab/test-linux.sh @@ -0,0 +1,12 @@ +#!/bin/bash +echo "________Running test-linux.sh________" +set -e # fail on any error +set -u # treat unset variables as error + +FEATURES="json-tests,ci-skip-tests" +OPTIONS="--release" +#use nproc `linux only +THREADS=$(nproc) + +echo "________Running Parity Full Test Suite________" +time cargo test $OPTIONS --features "$FEATURES" --locked --all --target $CARGO_TARGET -- --test-threads $THREADS diff --git a/scripts/validate_chainspecs.sh b/scripts/gitlab/validate-chainspecs.sh similarity index 51% rename from scripts/validate_chainspecs.sh rename to scripts/gitlab/validate-chainspecs.sh index c350445dd..9b7ef39e7 100755 --- a/scripts/validate_chainspecs.sh +++ b/scripts/gitlab/validate-chainspecs.sh @@ -1,7 +1,12 @@ -#!/usr/bin/env sh +#!/bin/bash +set -e # fail on any error +set -u # treat unset variables as error +echo "________Running validate_chainspecs.sh________" ERR=0 -cargo build --release -p chainspec + +echo "________Validate chainspecs________" +time cargo build --release -p chainspec for spec in ethcore/res/*.json; do if ! ./target/release/chainspec "$spec"; then ERR=1; fi diff --git a/test.sh b/test.sh deleted file mode 100755 index e7d8e2a78..000000000 --- a/test.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/sh -# Running Parity Full Test Suite -echo "________Running test.sh________" - -FEATURES="json-tests,ci-skip-tests" -OPTIONS="--release" -VALIDATE=1 -THREADS=8 - -set -e - - -validate () { - if [ "$VALIDATE" -eq "1" ] - then - echo "________Validate build________" - time cargo check $@ --locked --no-default-features - time cargo check $@ --locked --manifest-path util/io/Cargo.toml --no-default-features - time cargo check $@ --locked --manifest-path util/io/Cargo.toml --features "mio" - - # Validate chainspecs - echo "________Validate chainspecs________" - time ./scripts/validate_chainspecs.sh - else - echo "# not validating due to \$VALIDATE!=1" - fi -} - -cpp_test () { - case $CARGO_TARGET in - (x86_64-unknown-linux-gnu) - # Running the C++ example - echo "________Running the C++ example________" - DIR=parity-clib/examples/cpp/build - mkdir -p $DIR - cd $DIR - cmake .. - make -j $THREADS - # Note: we don't try to run the example because it tries to sync Kovan, and we don't want - # that to happen on CI - cd - - rm -rf $DIR - ;; - (*) - echo "________Skipping the C++ example________" - ;; - esac -} - -cargo_test () { - echo "________Running Parity Full Test Suite________" - git submodule update --init --recursive - time cargo test $OPTIONS --features "$FEATURES" --locked --all $@ -- --test-threads $THREADS -} - - -if [ "$CARGO_TARGET" ] -then - validate --target $CARGO_TARGET -else - validate -fi - -test "${RUN_TESTS}" = "all" && cpp_test - -if [ "$CARGO_TARGET" ] -then - - case "${RUN_TESTS}" in - (cargo|all) - cargo_test --target $CARGO_TARGET $@ - ;; - ('') - cargo_test --no-run --target $CARGO_TARGET $@ - ;; - esac -else - cargo_test $@ -fi