From af1d9345e01b6120417a814efe042fa49b99c5dd Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Mon, 26 Nov 2018 17:39:20 -0800 Subject: [PATCH] De-dup ci book build --- book/build.sh | 30 ++++++++++++++++++++++++++++++ ci/publish-book.sh | 5 +---- ci/test-stable.sh | 23 +---------------------- 3 files changed, 32 insertions(+), 26 deletions(-) create mode 100755 book/build.sh diff --git a/book/build.sh b/book/build.sh new file mode 100755 index 0000000000..012607fa00 --- /dev/null +++ b/book/build.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +set -e + +cd "$(dirname "$0")" + +_() { + echo "--- $*" + "$@" +} + +maybe_cargo_install() { + declare cmd=$1 + declare crate=$2 + + if [[ -z $crate ]]; then + crate=$cmd + fi + + "$cmd" --help > /dev/null 2>&1 + declare exitcode=$? + if [[ $exitcode -ne 0 ]]; then + _ cargo install "$crate" + fi +} + +export PATH=$CARGO_HOME/bin:$PATH +maybe_cargo_install mdbook +maybe_cargo_install svgbob svgbob_cli + +_ make diff --git a/ci/publish-book.sh b/ci/publish-book.sh index 11d69a69c5..46ac841e05 100755 --- a/ci/publish-book.sh +++ b/ci/publish-book.sh @@ -20,10 +20,7 @@ maybe_install() { done } -export PATH=$CARGO_HOME/bin:$PATH -maybe_install mdbook -maybe_install svgbob_cli -_ make -C book +book/build.sh echo --- create book repo ( diff --git a/ci/test-stable.sh b/ci/test-stable.sh index 3ed99e72ab..fea2cb0492 100755 --- a/ci/test-stable.sh +++ b/ci/test-stable.sh @@ -12,23 +12,6 @@ _() { "$@" } -maybe_install() { - declare cmd=$1 - declare crate=$2 - - if [[ -z $crate ]]; then - crate=$cmd - fi - - set +e - "$cmd" --help > /dev/null 2>&1 - declare exitcode=$? - set -e - if [[ $exitcode -ne 0 ]]; then - _ cargo install "$crate" - fi -} - _ cargo build --all --verbose _ cargo test --verbose --lib @@ -49,11 +32,7 @@ for program in programs/native/*; do ) done -# Build the HTML -export PATH=$CARGO_HOME/bin:$PATH -maybe_install mdbook -maybe_install svgbob svgbob_cli -_ make -C book +book/build.sh echo --- ci/localnet-sanity.sh (