From 39c77976335ef8e56a9739bf06a1af453dd95a26 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 31 Jan 2017 09:17:33 -0800 Subject: [PATCH] Allow running travis build locally --- .travis.yml | 2 +- Cargo.toml | 9 ++++ test_suite/deps/Cargo.toml | 2 + travis.sh | 86 +++++++++++++++++++++++++++++--------- 4 files changed, 78 insertions(+), 21 deletions(-) create mode 100644 Cargo.toml mode change 100644 => 100755 travis.sh diff --git a/.travis.yml b/.travis.yml index c415551e..8f492748 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ before_script: - pip install 'travis-cargo<0.2' --user - export PATH=$HOME/.local/bin:$PATH -script: sh travis.sh +script: ./travis.sh env: global: diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..601a709e --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,9 @@ +[workspace] +members = [ + "serde", + "serde_codegen_internals", + "serde_derive", + "serde_test", + "test_suite", + "test_suite/no_std", +] diff --git a/test_suite/deps/Cargo.toml b/test_suite/deps/Cargo.toml index 40bd1bb5..fbe2f2cd 100644 --- a/test_suite/deps/Cargo.toml +++ b/test_suite/deps/Cargo.toml @@ -4,6 +4,8 @@ version = "0.0.0" authors = ["David Tolnay "] publish = false +[workspace] + [dependencies] serde = { path = "../../serde" } serde_derive = { path = "../../serde_derive" } diff --git a/travis.sh b/travis.sh old mode 100644 new mode 100755 index 225869ee..f37a7a07 --- a/travis.sh +++ b/travis.sh @@ -1,24 +1,70 @@ #!/bin/bash -set -ev -if [ "${CLIPPY}" = "true" ]; then - if cargo install clippy -f; then - (cd serde && cargo clippy --features unstable-testing -- -Dclippy) - (cd serde_derive && cargo clippy --features unstable-testing -- -Dclippy) - (cd test_suite && cargo clippy --features unstable-testing -- -Dclippy) - (cd test_suite/deps && cargo clippy -- -Dclippy) - (cd test_suite/no_std && cargo clippy -- -Dclippy) + +set -e + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +channel() { + if [ -n "${TRAVIS}" ]; then + if [ "${TRAVIS_RUST_VERSION}" = "${CHANNEL}" ]; then + pwd + (set -x; cargo "$@") + fi else - echo "could not compile clippy, ignoring clippy tests" + pwd + (set -x; cargo "+${CHANNEL}" "$@") fi +} + +if [ -n "${CLIPPY}" ]; then + if [ -n "${TRAVIS}" ]; then + # cached installation will not work on a later nightly + cargo install clippy --force + fi + + cd "$DIR/serde" + cargo clippy --features unstable-testing -- -Dclippy + + cd "$DIR/serde_derive" + cargo clippy --features unstable-testing -- -Dclippy + + cd "$DIR/test_suite" + cargo clippy --features unstable-testing -- -Dclippy + + cd "$DIR/test_suite/no_std" + cargo clippy -- -Dclippy else - (cd serde && travis-cargo build) - (cd serde && travis-cargo --only beta test) - (cd serde && travis-cargo --only nightly test -- --features unstable-testing) - (cd serde && travis-cargo build -- --no-default-features) - (cd serde && travis-cargo --only nightly build -- --no-default-features --features alloc) - (cd serde && travis-cargo --only nightly build -- --no-default-features --features collections) - (cd test_suite && travis-cargo --only beta test) - (cd test_suite/deps && travis-cargo --only nightly build) - (cd test_suite travis-cargo --only nightly test -- --features unstable-testing) - (cd test_suite/no_std && travis-cargo --only nightly build) -fi \ No newline at end of file + CHANNEL=nightly + cargo clean + cd "$DIR/serde" + channel build + channel build --no-default-features + channel build --no-default-features --features alloc + channel build --no-default-features --features collections + channel test --features unstable-testing + cd "$DIR/test_suite/deps" + channel build + cd "$DIR/test_suite" + channel test --features unstable-testing + cd "$DIR/test_suite/no_std" + channel build + + CHANNEL=beta + cargo clean + cd "$DIR/serde" + channel build + cd "$DIR/test_suite" + channel test + + CHANNEL=stable + cargo clean + cd "$DIR/serde" + channel build + channel build --no-default-features + + CHANNEL=1.13.0 + cargo clean + cd "$DIR/serde" + channel build + channel build --no-default-features +fi