diff --git a/.travis.yml b/.travis.yml index f61203c279..2cd81ac59b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -73,15 +73,14 @@ matrix: if: branch != master env: MACOSX_DEPLOYMENT_TARGET=10.7 TARGET=i686-apple-darwin - - name: clippy/rustup-init.sh + - name: rustfmt/clippy/rustup-init.sh/shellcheck language: minimal install: - | sh ./rustup-init.sh --default-toolchain=beta -y; . "$HOME"/.cargo/env; - rustup component add clippy; + rustup component add rustfmt clippy; script: - - cargo clippy --all --all-targets - | docker run \ --volume "$TRAVIS_BUILD_DIR":/checkout:ro \ @@ -90,6 +89,11 @@ matrix: -it \ centos:6 \ sh ./ci/raw_init.sh; + - shellcheck -s dash -- rustup-init.sh; + - git ls-files -- '*.sh' | xargs shellcheck -s dash -e SC1090; + - git ls-files -- '*.bash' | xargs shellcheck -s bash -e SC1090; + - cargo fmt --all -- --check; + - cargo clippy --all --all-targets before_deploy: deploy: @@ -120,23 +124,13 @@ script: esac - | if [ -n "$DOCKER" ]; then - sh ci/build-run-docker.sh "$DOCKER" "$TARGET" "$SKIP_TESTS"; + bash ci/build-run-docker.bash "$DOCKER" "$TARGET" "$SKIP_TESTS"; else - sh ci/run.sh; - fi - - # Check the formatting last because test failures are more interesting to have - # discovered for contributors lacking some platform access for testing beforehand - - | - if [ "${TARGET}" = x86_64-unknown-linux-gnu ]; then - shellcheck -s dash -e SC1090 -- rustup-init.sh ci/*.sh; - rustup component add rustfmt; - rustfmt -vV; - cargo fmt --all -- --check; + bash ci/run.bash; fi before_deploy: - - sh ci/prepare-deploy-travis.sh + - bash ci/prepare-deploy-travis.bash deploy: - provider: s3 diff --git a/ci/build-run-docker.sh b/ci/build-run-docker.bash similarity index 91% rename from ci/build-run-docker.sh rename to ci/build-run-docker.bash index 230addbcb7..905987c1ab 100644 --- a/ci/build-run-docker.sh +++ b/ci/build-run-docker.bash @@ -3,7 +3,7 @@ script_dir=$(cd "$(dirname "$0")" && pwd) root_dir="${script_dir}/.." -. "${script_dir}/shared.sh" +. "${script_dir}/shared.bash" set -e # Disable cause it makes shared script not to work properly @@ -19,7 +19,7 @@ SKIP_TESTS="$3" travis_fold start "fetch.image.${TARGET}" travis_time_start -travis_do_cmd sh ci/fetch-rust-docker.sh "${TARGET}" +travis_do_cmd bash ci/fetch-rust-docker.bash "${TARGET}" travis_time_finish travis_fold end "fetch.image.${TARGET}" @@ -52,7 +52,7 @@ docker run \ --init \ --rm \ "${DOCKER}" \ - -c 'PATH="${PATH}":/rustc-sysroot/bin sh ci/run.sh' + -c 'PATH="${PATH}":/rustc-sysroot/bin bash ci/run.bash' # check that rustup-init was built with ssl support # see https://github.com/rust-lang/rustup.rs/issues/1051 diff --git a/ci/deploy.sh b/ci/deploy.bash similarity index 95% rename from ci/deploy.sh rename to ci/deploy.bash index 6707345223..cef0f95f11 100755 --- a/ci/deploy.sh +++ b/ci/deploy.bash @@ -5,13 +5,13 @@ # Usage: # # 1. Deploy the release on the dev environment: -# ./deploy.sh dev VERSION_NUMBER +# ./deploy.bash dev VERSION_NUMBER # # 2. Test everything works correctly: # RUSTUP_UPDATE_ROOT=https://dev-static.rust-lang.org/rustup rustup self update # # 3. Deploy the release to the prod environment: -# ./deploy.sh prod VERSION_NUMBER +# ./deploy.bash prod VERSION_NUMBER set -euo pipefail IFS=$'\n\t' diff --git a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile index 5f87638cab..87ee2fcf6b 100644 --- a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ FROM rust-aarch64-unknown-linux-gnu -ENV CC_aarch64_unknown_linux_gnu=aarch64-unknown-linux-gnueabi-gcc -ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-unknown-linux-gnueabi-gcc +ENV CC_aarch64_unknown_linux_gnu=aarch64-unknown-linux-gnueabi-gcc \ + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-unknown-linux-gnueabi-gcc diff --git a/ci/docker/android/Dockerfile b/ci/docker/android/Dockerfile index 99a540a3ef..a86dfcaaa0 100644 --- a/ci/docker/android/Dockerfile +++ b/ci/docker/android/Dockerfile @@ -11,8 +11,8 @@ RUN apt-get update && \ make \ pkg-config -COPY ci/docker/scripts/sccache.sh /scripts/ -RUN sh /scripts/sccache.sh +COPY ci/docker/scripts/sccache.bash /scripts/ +RUN bash /scripts/sccache.bash RUN apt-get install -y --no-install-recommends \ unzip \ diff --git a/ci/docker/arm-unknown-linux-gnueabi/Dockerfile b/ci/docker/arm-unknown-linux-gnueabi/Dockerfile index ca5ab1f78a..bfe97f9481 100644 --- a/ci/docker/arm-unknown-linux-gnueabi/Dockerfile +++ b/ci/docker/arm-unknown-linux-gnueabi/Dockerfile @@ -1,4 +1,4 @@ FROM rust-arm-unknown-linux-gnueabi -ENV CC_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-gcc -ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER=arm-unknown-linux-gnueabi-gcc +ENV CC_arm_unknown_linux_gnueabi=arm-unknown-linux-gnueabi-gcc \ + CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER=arm-unknown-linux-gnueabi-gcc diff --git a/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile b/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile index f03bb79d36..a185c0b836 100644 --- a/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile @@ -1,4 +1,4 @@ FROM rust-arm-unknown-linux-gnueabihf -ENV CC_arm_unknown_linux_gnueabihf=arm-unknown-linux-gnueabihf-gcc -ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-unknown-linux-gnueabihf-gcc +ENV CC_arm_unknown_linux_gnueabihf=arm-unknown-linux-gnueabihf-gcc \ + CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-unknown-linux-gnueabihf-gcc diff --git a/ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile b/ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile index 8efe61856f..be14c039c0 100644 --- a/ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile +++ b/ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile @@ -1,4 +1,4 @@ FROM rust-armv7-unknown-linux-gnueabihf -ENV CC_armv7_unknown_linux_gnueabihf=armv7-unknown-linux-gnueabihf-gcc -ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=armv7-unknown-linux-gnueabihf-gcc +ENV CC_armv7_unknown_linux_gnueabihf=armv7-unknown-linux-gnueabihf-gcc \ + CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=armv7-unknown-linux-gnueabihf-gcc diff --git a/ci/docker/mips-unknown-linux-gnu/Dockerfile b/ci/docker/mips-unknown-linux-gnu/Dockerfile index d64552a1f9..fee887b174 100644 --- a/ci/docker/mips-unknown-linux-gnu/Dockerfile +++ b/ci/docker/mips-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ FROM rust-mips-unknown-linux-gnu -ENV CC_mips_unknown_linux_gnu=mips-linux-gnu-gcc -ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc +ENV CC_mips_unknown_linux_gnu=mips-linux-gnu-gcc \ + CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc diff --git a/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile b/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile index 6076122385..18aaafb432 100644 --- a/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile +++ b/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile @@ -1,4 +1,4 @@ FROM rust-mips64-unknown-linux-gnuabi64 -ENV CC_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-gcc -ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc +ENV CC_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-gcc \ + CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc diff --git a/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile b/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile index 0d0138220a..8eaf5281e8 100644 --- a/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile +++ b/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile @@ -1,4 +1,4 @@ FROM rust-mips64el-unknown-linux-gnuabi64 -ENV CC_mips64el_unknown_linux_gnuabi64=mips64el-linux-gnuabi64-gcc -ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc +ENV CC_mips64el_unknown_linux_gnuabi64=mips64el-linux-gnuabi64-gcc \ + CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc diff --git a/ci/docker/mipsel-unknown-linux-gnu/Dockerfile b/ci/docker/mipsel-unknown-linux-gnu/Dockerfile index 25857c4d84..48eb00bbc5 100644 --- a/ci/docker/mipsel-unknown-linux-gnu/Dockerfile +++ b/ci/docker/mipsel-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ FROM rust-mipsel-unknown-linux-gnu -ENV CC_mipsel_unknown_linux_gnu=mipsel-linux-gnu-gcc -ENV CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER=mipsel-linux-gnu-gcc +ENV CC_mipsel_unknown_linux_gnu=mipsel-linux-gnu-gcc \ + CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER=mipsel-linux-gnu-gcc diff --git a/ci/docker/powerpc-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc-unknown-linux-gnu/Dockerfile index c96f43e36a..8c8df97ecb 100644 --- a/ci/docker/powerpc-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ FROM rust-powerpc-unknown-linux-gnu -ENV CC_powerpc_unknown_linux_gnu=powerpc-unknown-linux-gnu-gcc -ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-unknown-linux-gnu-gcc +ENV CC_powerpc_unknown_linux_gnu=powerpc-unknown-linux-gnu-gcc \ + CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-unknown-linux-gnu-gcc diff --git a/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile index 9ba83377ea..5327b1bba0 100644 --- a/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ FROM rust-powerpc64-unknown-linux-gnu -ENV CC_powerpc64_unknown_linux_gnu=powerpc64-unknown-linux-gnu-gcc -ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-unknown-linux-gnu-gcc +ENV CC_powerpc64_unknown_linux_gnu=powerpc64-unknown-linux-gnu-gcc \ + CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-unknown-linux-gnu-gcc diff --git a/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile index 0cc0432700..167b78e593 100644 --- a/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ FROM rust-powerpc64le-unknown-linux-gnu -ENV CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc -ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc +ENV CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc \ + CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc diff --git a/ci/docker/s390x-unknown-linux-gnu/Dockerfile b/ci/docker/s390x-unknown-linux-gnu/Dockerfile index 653cb5c763..4b438acb7d 100644 --- a/ci/docker/s390x-unknown-linux-gnu/Dockerfile +++ b/ci/docker/s390x-unknown-linux-gnu/Dockerfile @@ -1,4 +1,4 @@ FROM rust-s390x-unknown-linux-gnu -ENV CC_s390x_unknown_linux_gnu=s390x-ibm-linux-gnu-gcc -ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-ibm-linux-gnu-gcc +ENV CC_s390x_unknown_linux_gnu=s390x-ibm-linux-gnu-gcc \ + CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-ibm-linux-gnu-gcc diff --git a/ci/docker/scripts/sccache.sh b/ci/docker/scripts/sccache.bash similarity index 100% rename from ci/docker/scripts/sccache.sh rename to ci/docker/scripts/sccache.bash diff --git a/ci/docker/x86_64-unknown-freebsd/Dockerfile b/ci/docker/x86_64-unknown-freebsd/Dockerfile index 46fa32c434..9bb6af918d 100644 --- a/ci/docker/x86_64-unknown-freebsd/Dockerfile +++ b/ci/docker/x86_64-unknown-freebsd/Dockerfile @@ -1,4 +1,4 @@ FROM rust-x86_64-unknown-freebsd -ENV CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd10-clang -ENV CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd10-clang +ENV CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd10-clang \ + CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd10-clang diff --git a/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/ci/docker/x86_64-unknown-linux-musl/Dockerfile index e287786430..e2d43bc0a1 100644 --- a/ci/docker/x86_64-unknown-linux-musl/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:18.04 -COPY ci/docker/scripts/sccache.sh /scripts/ +COPY ci/docker/scripts/sccache.bash /scripts/ RUN \ apt-get update && \ @@ -12,4 +12,4 @@ RUN \ perl \ make \ gcc && \ - sh /scripts/sccache.sh + bash /scripts/sccache.bash diff --git a/ci/fetch-rust-docker.sh b/ci/fetch-rust-docker.bash similarity index 98% rename from ci/fetch-rust-docker.sh rename to ci/fetch-rust-docker.bash index 47efa3034d..19eb4108ce 100644 --- a/ci/fetch-rust-docker.sh +++ b/ci/fetch-rust-docker.bash @@ -1,7 +1,7 @@ #!/bin/bash script_dir=$(cd "$(dirname "$0")" && pwd) -. "$script_dir/shared.sh" +. "$script_dir/shared.bash" set -e # Disable cause it makes shared script not to work properly diff --git a/ci/prepare-deploy-travis.sh b/ci/prepare-deploy-travis.bash similarity index 91% rename from ci/prepare-deploy-travis.sh rename to ci/prepare-deploy-travis.bash index 16dd22f8f5..99e7abd2eb 100644 --- a/ci/prepare-deploy-travis.sh +++ b/ci/prepare-deploy-travis.bash @@ -7,7 +7,7 @@ if [ "$TRAVIS_PULL_REQUEST" = "true" ] || [ "$TRAVIS_BRANCH" = "auto" ]; then fi # Copy rustup-init to rustup-setup for backwards compatibility -cp target/"$TARGET"/release/rustup-init$EXE_EXT target/"$TARGET"/release/rustup-setup$EXE_EXT +cp target/"$TARGET"/release/rustup-init"${EXE_EXT}" target/"$TARGET"/release/rustup-setup"${EXE_EXT}" # Generate hashes if [ "$TRAVIS_OS_NAME" = "osx" ]; then diff --git a/ci/run.bash b/ci/run.bash new file mode 100644 index 0000000000..f594f6cbef --- /dev/null +++ b/ci/run.bash @@ -0,0 +1,35 @@ +#!/bin/bash + +set -ex + +export RUST_BACKTRACE=1 + +rustc -vV +cargo -vV + +FEATURES=() +if [ "$TRAVIS_OS_NAME" != "windows" ]; then + FEATURES=('--features' 'vendored-openssl') +fi + +cargo build --locked -v --release --target "$TARGET" "${FEATURES[@]}" + +runtest () { + cargo test --release --target "$TARGET" "${FEATURES[@]}" "$@" +} + +if [ -z "$SKIP_TESTS" ]; then + cargo run --locked --release --target "$TARGET" "${FEATURES[@]}" -- --dump-testament + runtest -p download + runtest --bin rustup-init + runtest --lib --all + runtest --doc --all + + runtest --test dist -- --test-threads 1 + + find ./tests -maxdepth 1 -type f ! -path '*/dist.rs' -name '*.rs' \ + | sed -E 's@\./tests/(.+)\.rs@\1@g' \ + | while read -r test; do + runtest --test "${test}" + done +fi diff --git a/ci/run.sh b/ci/run.sh deleted file mode 100644 index 649c2ea961..0000000000 --- a/ci/run.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -set -ex - -RUST_BACKTRACE=1 -export RUST_BACKTRACE - -rustc -vV -cargo -vV - -if [ "$TRAVIS_OS_NAME" = "windows" ]; then - FEATURES="" -else - FEATURES="--features vendored-openssl" -fi - -# Sadly we need word splitting for $FEATURES -# shellcheck disable=SC2086 -cargo build --locked -v --release --target "$TARGET" $FEATURES - -runtest () { - # shellcheck disable=SC2086 - cargo test --release --target "$TARGET" $FEATURES "$@" -} - -if [ -z "$SKIP_TESTS" ]; then - # shellcheck disable=SC2086 - cargo run --locked --release --target "$TARGET" $FEATURES -- --dump-testament - runtest -p download - runtest --bin rustup-init - runtest --lib --all - runtest --doc --all - for TEST in $(cd tests; ls *.rs | cut -d. -f1); do - if [ "x$TEST" = "xdist" ]; then - runtest --test "$TEST" -- --test-threads 1 - else - runtest --test "$TEST" - fi - done -fi diff --git a/ci/shared.sh b/ci/shared.bash similarity index 98% rename from ci/shared.sh rename to ci/shared.bash index 6ab46bc08e..f4972d62ea 100644 --- a/ci/shared.sh +++ b/ci/shared.bash @@ -49,7 +49,7 @@ travis_nanoseconds() { local cmd='date' local format='+%s%N' - if command -v gdate >/dev/null 2>&1; then + if command -v gdate >/dev/null; then cmd='gdate' elif [ "$(uname)" = Darwin ]; then format='+%s000000000' diff --git a/src/cli/download_tracker.rs b/src/cli/download_tracker.rs index 57e3250506..59fd32d051 100644 --- a/src/cli/download_tracker.rs +++ b/src/cli/download_tracker.rs @@ -267,5 +267,4 @@ mod tests { assert_eq!(DownloadTracker::from_seconds(222_292), (2, 13, 44, 52)); } - }