From bc98d68414e8a15d4423f056523124718f6920ab Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Mon, 25 Jun 2018 12:41:52 +0300 Subject: [PATCH] Refactor travis: Build on minimal image (#243) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Attempt 1 * minimal → generic * Add -y to rustup script * Remove clang * Refactor. * Remove CARGO_TARGET_DIR for now * Display versions of tools from the rust toolchain * Fix --- .travis.yml | 38 ++++++++++++++++++--------- publish-wasm.sh => ci/publish-wasm.sh | 2 +- ci/script.sh | 28 ++++++++++++++++++++ 3 files changed, 54 insertions(+), 14 deletions(-) rename publish-wasm.sh => ci/publish-wasm.sh (97%) create mode 100755 ci/script.sh diff --git a/.travis.yml b/.travis.yml index 2b392c798aced..040523096e323 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,33 @@ -sudo: false -language: rust +# Request an environment that provides sudo (that goes with larger containers) +# and a minimal language environment. +sudo: true +language: minimal + +cache: cargo + branches: only: - master -cache: cargo +env: + global: + - RUST_BACKTRACE=1 + matrix: + - RUST_TOOLCHAIN=nightly TARGET=wasm + - RUST_TOOLCHAIN=stable TARGET=native -matrix: - fast_finish: false - include: - - rust: stable +before_install: + # Check how much space we've got on this machine. + - df -h script: - - cargo test --all - - cargo clean - - ./init.sh - - ./build.sh - - if [ "$TRAVIS_PULL_REQUEST" != "true" ] && [ "$TRAVIS_BRANCH" == "master" ]; then - ./publish-wasm.sh; + - ./ci/script.sh + +after_success: + - if [ "$TARGET" == "wasm" ] && [ "$TRAVIS_PULL_REQUEST" != "true" ] && [ "$TRAVIS_BRANCH" == "master" ]; then + ./ci/publish-wasm.sh; fi + +after_script: + # Check how much free disk space left after the build + - df -h diff --git a/publish-wasm.sh b/ci/publish-wasm.sh similarity index 97% rename from publish-wasm.sh rename to ci/publish-wasm.sh index de60ad69c54c9..3b9ffa07bdba1 100755 --- a/publish-wasm.sh +++ b/ci/publish-wasm.sh @@ -6,7 +6,7 @@ set -e -source `dirname "$0"`/common.sh +source ./common.sh if [ -z ${GH_TOKEN+x} ]; then echo "GH_TOKEN environment variable is not set" diff --git a/ci/script.sh b/ci/script.sh new file mode 100755 index 0000000000000..4c67182987d8b --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -eux + +# Install rustup and the specified rust toolchain. +curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=$RUST_TOOLCHAIN -y + +# Load cargo environment. Specifically, put cargo into PATH. +source ~/.cargo/env + +rustc --version +rustup --version +cargo --version + +case $TARGET in + "native") + sudo apt-get -y update + sudo apt-get install -y cmake pkg-config libssl-dev + + cargo test --all + ;; + + "wasm") + # Install prerequisites and build all wasm projects + ./init.sh + ./build.sh + ;; +esac