Skip to content

Commit

Permalink
ci: split jobs into different travis stages
Browse files Browse the repository at this point in the history
  • Loading branch information
yanganto committed Feb 13, 2020
1 parent e30c4d0 commit 5aff91e
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 45 deletions.
5 changes: 0 additions & 5 deletions .maintain/ci/build_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ cargo --version
rustc --version

case $TARGET in
# Format check in stable rust
"rustfmt")
cargo fmt --all
;;

# Without WASM
"native")
rustup target add wasm32-unknown-unknown
Expand Down
7 changes: 0 additions & 7 deletions .maintain/ci/darwinia_test_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ echo -e "Test Darwinia ${1} ..."

set -eux

source ~/.cargo/env

case $TARGET in
# Format check in stable rust
"rustfmt")
echo -e "\e[0;32m +------------+ \n\e[0;32m | No Test | \n\e[0;32m +------------+ \e[0m"
;;

# Without WASM
"native")
rustup target add wasm32-unknown-unknown
Expand Down
25 changes: 25 additions & 0 deletions .maintain/ci/fmt_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -eux

# rustfmt is check as stable rust
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable -y

source ~/.cargo/env

rustup --version
cargo --version
rustc --version

case $TARGET in
# Without WASM
"native")
cargo fmt --all
echo -e "\e[0;32m +-------------+ \n\e[0;32m | Format Pass | \n\e[0;32m +-------------+ \e[0m"
;;

# With WASM fmt only check in native
"wasm")
echo "check in native build always pass in wasm build"
;;
esac
11 changes: 3 additions & 8 deletions .maintain/ci/test_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@

set -eux

source ~/.cargo/env

case $TARGET in
# Format check in stable rust
"rustfmt")
echo -e "\e[0;32m +------------+ \n\e[0;32m | No Test | \n\e[0;32m +------------+ \e[0m"
;;

# Without WASM, build then test
"native")
SKIP_WASM_BUILD=1 cargo test --release --all --locked "$@"
rustup target add wasm32-unknown-unknown
# There is some issue to build on ci server with SKIP_WASM_BUILD=1
cargo test --release --all --locked "$@"
echo -e "\e[0;32m +------------+ \n\e[0;32m | Release OK | \n\e[0;32m +------------+ \e[0m"
;;

Expand Down
56 changes: 31 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Request an environment that provides sudo (that goes with larger containers)
# and a minimal language environment.
sudo: true
language: minimal
language: shell

cache: cargo

Expand All @@ -13,34 +13,40 @@ branches:
env:
global:
- RUST_BACKTRACE=1
matrix:
- RUST_TOOLCHAIN=stable TARGET=rustfmt
- RUST_TOOLCHAIN=nightly TARGET=wasm
- RUST_TOOLCHAIN=nightly TARGET=native

before_install:
# Check how much space we've got on this machine.
- df -h

script:
# The stage of building
- echo 'Building...' && echo -en 'travis_fold:start:build\\r'
- .maintain/ci/build_script.sh
- echo -en 'travis_fold:end:build\\r'

# The stage of test darwinia customize model
- |
for t in kton ring staking;
do
echo 'Test Darwinia '${t}' ...' && echo -en 'travis_fold:start:darwinia_'${t}'\\r'
.maintain/ci/darwinia_test_script.sh ${t}
echo -en 'travis_fold:end:darwinia_'${t}'\\r'
done
# The stage of test all modules including substrates
- echo 'Test All Modules...' && echo -en 'travis_fold:start:all_test\\r'
- .maintain/ci/test_script.sh
- echo -en 'travis_fold:end:all_test\\r'
jobs:
include:
- stage: Fomat Check
env: RUST_TOOLCHAIN=stable TARGET=native
script: .maintain/ci/fmt_script.sh

- stage: Build Native
env: RUST_TOOLCHAIN=nightly TARGET=native
script: .maintain/ci/build_script.sh

- stage: Build Wasm
env: RUST_TOOLCHAIN=nightly TARGET=wasm
script: .maintain/ci/build_script.sh

- stage: Test Kton
env: RUST_TOOLCHAIN=nightly TARGET=native
script: .maintain/ci/darwinia_test_script.sh kton

- stage: Test Ring
env: RUST_TOOLCHAIN=nightly TARGET=native
script: .maintain/ci/darwinia_test_script.sh ring

- stage: Test Staking
env: RUST_TOOLCHAIN=nightly TARGET=native
script: .maintain/ci/darwinia_test_script.sh staking

- stage: Test Everything
env: RUST_TOOLCHAIN=nightly TARGET=native
script: .maintain/ci/test_script.sh

after_script:
# Check how much free disk space left after the build
Expand Down

0 comments on commit 5aff91e

Please sign in to comment.