Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
CI: Un-travis-ify our scripting for linux/mac
With the switch away from Travis to Github actions, the scripts
we use for CI have to be updated.

Signed-off-by: Daniel Silverstone <[email protected]>
  • Loading branch information
kinnison committed Jan 7, 2020
commit 9672db385690c0bd34b276371336f9ac8382f06c
2 changes: 1 addition & 1 deletion ci/fetch-rust-docker.bash
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ if [ -z "$(docker images -q "${LOCAL_DOCKER_TAG}")" ]; then
echo "Attempting to download $url"
rm -f "$cache"
set +e
travis_retry curl -y 30 -Y 10 --connect-timeout 30 -f -L -C - -o "$cache" "$url"
command_retry curl -y 30 -Y 10 --connect-timeout 30 -f -L -C - -o "$cache" "$url"
set -e
docker load --quiet -i "$cache"
docker tag "$digest" "${LOCAL_DOCKER_TAG}"
Expand Down
33 changes: 33 additions & 0 deletions ci/prepare-deploy.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -u -e

# Copy rustup-init to rustup-setup for backwards compatibility
cp target/"$TARGET"/release/rustup-init target/"$TARGET"/release/rustup-setup

# Generate hashes
if [ "$(uname -s)" = "Darwin" ]; then
find target/"$TARGET"/release/ -maxdepth 1 -type f -exec sh -c 'fn="$1"; shasum -a 256 -b "$fn" > "$fn".sha256' sh {} \;
else
find target/"$TARGET"/release/ -maxdepth 1 -type f -exec sh -c 'fn="$1"; sha256sum -b "$fn" > "$fn".sha256' sh {} \;
fi

# The directory for deployment artifacts
dest="deploy"

# Prepare bins for upload
bindest="$dest/dist/$TARGET"
mkdir -p "$bindest/"
cp target/"$TARGET"/release/rustup-init "$bindest/"
cp target/"$TARGET"/release/rustup-init.sha256 "$bindest/"
cp target/"$TARGET"/release/rustup-setup "$bindest/"
cp target/"$TARGET"/release/rustup-setup.sha256 "$bindest/"

if [ "$TARGET" != "x86_64-unknown-linux-gnu" ]; then
exit 0
fi

cp rustup-init.sh "$dest/"

# Prepare website for upload
cp -R www "$dest/www"
75 changes: 7 additions & 68 deletions ci/shared.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,17 @@
# This file is intended to be sourced, so it is not being marked as
# an executable file in git.

# This is from
# This is modified from
# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/travis_setup_env.bash
travis_setup_env() {
export ANSI_RED='\033[31;1m'
export ANSI_GREEN='\033[32;1m'
export ANSI_YELLOW='\033[33;1m'
export ANSI_RESET='\033[0m'
export ANSI_CLEAR='\033[0K'
}

# This is from
# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/travis_fold.bash
travis_fold() {
local action="${1}"
local name="${2}"
printf 'travis_fold:%s:%s\r'"${ANSI_CLEAR}" "${action}" "${name}"
}
export ANSI_RED='\033[31;1m'
export ANSI_GREEN='\033[32;1m'
export ANSI_YELLOW='\033[33;1m'
export ANSI_RESET='\033[0m'
export ANSI_CLEAR='\033[0K'

# This is modified loop version of
# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/travis_retry.bash
travis_retry() {
command_retry() {
local result=0
local count=1
local max=5
Expand All @@ -43,54 +33,3 @@ travis_retry() {
return "${result}"
}

# This is from
# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/
travis_nanoseconds() {
local cmd='date'
local format='+%s%N'

if command -v gdate >/dev/null; then
cmd='gdate'
elif [ "$(uname)" = Darwin ]; then
format='+%s000000000'
fi

"${cmd}" -u "${format}"
}

# Generate random integer like bash's `$RANDOM`.
travis_generate_rand() {
shuf -i 0-$((0xffffffff)) -n 1
}

travis_time_start() {
TRAVIS_TIMER_ID="$(printf '%08x' "$(travis_generate_rand)")"
TRAVIS_TIMER_START_TIME="$(travis_nanoseconds)"
export TRAVIS_TIMER_ID TRAVIS_TIMER_START_TIME
printf 'travis_time:start:%s\r'"${ANSI_CLEAR}" "${TRAVIS_TIMER_ID}"
}

travis_time_finish() {
travis_timer_end_time="$(travis_nanoseconds)"
local duration="$((travis_timer_end_time - TRAVIS_TIMER_START_TIME))"
printf '\ntravis_time:end:%s:start=%s,finish=%s,duration=%s\r'"${ANSI_CLEAR}" \
"${TRAVIS_TIMER_ID}" "${TRAVIS_TIMER_START_TIME}" \
"${travis_timer_end_time}" "${duration}"
}

travis_do_cmd() {
echo "$ ${*}"
"${@}"
local result="$?"
export TRAVIS_TEST_RESULT=$((${TRAVIS_TEST_RESULT:-0} | $((result != 0))))

if [ "${result}" -eq 0 ]; then
printf '%b' "${ANSI_GREEN}"
else
printf '%b' "${ANSI_RED}"
fi
printf 'The command "%s" exited with %d.'"${ANSI_RESET}"'\n' "${*}" "${result}"
return "$result"
}

travis_setup_env