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
This commit is contained in:
TriplEight 2019-03-11 15:26:35 +01:00 committed by GitHub
parent 4320c9bc4f
commit 82a148a99b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 87 additions and 103 deletions

View File

@ -24,7 +24,6 @@ variables:
- tags
- schedules
.collect_artifacts: &collect_artifacts
artifacts:
name: "${CI_JOB_NAME}_${SCHEDULE_TAG:-${CI_COMMIT_REF_NAME}}"
@ -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

View File

@ -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

17
scripts/gitlab/test-cpp.sh Executable file
View File

@ -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

12
scripts/gitlab/test-linux.sh Executable file
View File

@ -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

View File

@ -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

79
test.sh
View File

@ -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