Skip to content

Commit

Permalink
Merge pull request #1916 from lzutao/ci-bash
Browse files Browse the repository at this point in the history
build: Transform most CI scripts to bash
  • Loading branch information
kinnison authored Sep 1, 2019
2 parents 7cd6a2c + ac0463b commit 866e029
Show file tree
Hide file tree
Showing 25 changed files with 83 additions and 95 deletions.
26 changes: 10 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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:

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions ci/build-run-docker.sh → ci/build-run-docker.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ci/deploy.sh → ci/deploy.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions ci/docker/aarch64-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions ci/docker/android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions ci/docker/arm-unknown-linux-gnueabi/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions ci/docker/arm-unknown-linux-gnueabihf/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions ci/docker/mips-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions ci/docker/mipsel-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions ci/docker/powerpc-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions ci/docker/powerpc64-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions ci/docker/s390x-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
4 changes: 2 additions & 2 deletions ci/docker/x86_64-unknown-freebsd/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions ci/docker/x86_64-unknown-linux-musl/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 && \
Expand All @@ -12,4 +12,4 @@ RUN \
perl \
make \
gcc && \
sh /scripts/sccache.sh
bash /scripts/sccache.bash
2 changes: 1 addition & 1 deletion ci/fetch-rust-docker.sh → ci/fetch-rust-docker.bash
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions ci/run.bash
Original file line number Diff line number Diff line change
@@ -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
40 changes: 0 additions & 40 deletions ci/run.sh

This file was deleted.

2 changes: 1 addition & 1 deletion ci/shared.sh → ci/shared.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 0 additions & 1 deletion src/cli/download_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,5 +267,4 @@ mod tests {

assert_eq!(DownloadTracker::from_seconds(222_292), (2, 13, 44, 52));
}

}

0 comments on commit 866e029

Please sign in to comment.