Skip to content

Commit d848663

Browse files
authored
Merge pull request #360 from spl/travis-cleanup
Neaten the dist/travis.sh presentation
2 parents e186cbb + bf7622c commit d848663

File tree

1 file changed

+67
-33
lines changed

1 file changed

+67
-33
lines changed

dist/travis.sh

+67-33
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,50 @@
1818
#
1919
# So, it's complicated.
2020

21+
# Exit immediately if a command exits with a non-zero status.
2122
set -e
2223

24+
echo ""
25+
26+
# We use `travis_fold` commands to hide chunks of the Travis-CI log. Follow the
27+
# usage documentation below and put `travis_fold_start`/`travis_fold_end` pairs
28+
# _inside_ `if` blocks to reduce the log noise. (For example, after `set -x`,
29+
# `if` statements print out as `+ false`, which is not very useful.)
30+
31+
# Usage: travis_fold_start <fold-name> <title> [<verbose>]
32+
#
33+
# Start a fold with a name and title and (optionally) enable Bash verbose
34+
# logging.
35+
#
36+
# <fold-name> string to use with travis_fold_end to close the fold
37+
# <title> string that appears alone when the fold is closed
38+
# <verbose> (optional) if non-empty, enables Bash verbose echoing
39+
#
40+
function travis_fold_start() {
41+
echo "travis_fold:start:$1"
42+
echo -e "\033[33;1m$2\033[0m"
43+
if [ -n "$3" ]; then
44+
set -x
45+
fi
46+
}
47+
48+
# Usage: travis_fold_end <fold-name>
49+
#
50+
# End a fold started with the given name and disable Bash verbose logging in
51+
# case it was enabled by `travis_fold_start`.
52+
#
53+
# <fold-name> string that should have been used with travis_fold_start to
54+
# open the fold
55+
#
56+
function travis_fold_end() {
57+
set +x
58+
echo ""
59+
echo "travis_fold:end:$1"
60+
}
61+
2362
# Helpful context.
2463

64+
travis_fold_start env "Environment variables"
2565
echo "TRAVIS_ALLOW_FAILURE: $TRAVIS_ALLOW_FAILURE"
2666
echo "TRAVIS_BRANCH: $TRAVIS_BRANCH"
2767
echo "TRAVIS_BUILD_ID: $TRAVIS_BUILD_ID"
@@ -72,42 +112,27 @@ else
72112
is_release_build=false
73113
fi
74114
echo "is_release_build: $is_release_build"
75-
76-
# Start being verbose. We use Travis "fold" commands to provide a bit more
77-
# context, partially because in `set -x` mode the "if" statements just print
78-
# out as `+ false`.
79-
80-
function travis_start_fold() {
81-
echo -e "\ntravis_fold:start:$1\033[33;1m$2\033[0m"
82-
set -x
83-
}
84-
85-
function travis_end_fold() {
86-
set +x
87-
echo -e "\ntravis_fold:end:$1\r"
88-
}
89-
90-
echo ""
115+
travis_fold_end env
91116

92117
# The special tag "continuous" is used to maintain a GitHub "release" that
93118
# tracks `master`. If we've been triggered for that, that means that something
94119
# *else* was triggered that caused the continuous deployment code to fire.
95120
# So we should do nothing.
96121

97-
travis_start_fold continuous_abort "Abort if special continuous release tag?"
98122
if [[ "$TRAVIS_TAG" == continuous ]] ; then
123+
echo -e "\033[34;1mThis is a 'continuous' release. Exiting.\033[0m"
99124
exit 0
100125
fi
101-
travis_end_fold continuous_abort
102126

103-
# Pre-build setup.
127+
# Install dependencies
104128

105-
travis_start_fold pre_build "Pre-build setup for OS = $TRAVIS_OS_NAME"
106129
if [[ "$TRAVIS_OS_NAME" == osx ]]; then
130+
travis_fold_start install_deps "Install dependencies" verbose
107131
export OPENSSL_INCLUDE_DIR=$(brew --prefix openssl)/include
108132
export OPENSSL_LIB_DIR=$(brew --prefix openssl)/lib
109133
export DEP_OPENSSL_INCLUDE=$(brew --prefix openssl)/include
110134
export PKG_CONFIG_PATH=/usr/local/opt/icu4c/lib/pkgconfig
135+
travis_fold_end install_deps
111136
elif [[ "$TRAVIS_OS_NAME" == linux ]] ; then
112137
if $is_docker_build ; then
113138
: # Don't need the deps here; all the action is in the container.
@@ -119,6 +144,7 @@ elif [[ "$TRAVIS_OS_NAME" == linux ]] ; then
119144
# https://unix.stackexchange.com/questions/315502/how-to-disable-apt-daily-service-on-ubuntu-cloud-vm-image
120145
# . We adopt the workaround from the StackExchange post.
121146

147+
travis_fold_start install_deps "Install dependencies" verbose
122148
sudo systemctl stop apt-daily.timer
123149
sudo systemctl stop apt-daily.service
124150
sudo systemctl kill --kill-who=all apt-daily.service
@@ -130,47 +156,55 @@ elif [[ "$TRAVIS_OS_NAME" == linux ]] ; then
130156
sudo add-apt-repository -y ppa:k-peter/tectonic-ci
131157
sudo apt-get update
132158
sudo apt-get install -y libharfbuzz-dev
159+
travis_fold_end install_deps
133160
fi
134161
fi
135162

136-
travis_end_fold pre_build
137-
138163
# Check that the code is properly rustfmt'd and clippy'd.
139164

140-
travis_start_fold check_rustfmt_clippy "Maybe rustfmt and clippy? ($is_main_build)"
141165
if $is_main_build ; then
142-
rustup component add rustfmt clippy
166+
travis_fold_start cargo_fmt "cargo fmt" verbose
167+
rustup component add rustfmt
143168
cargo fmt --all -- --check
169+
travis_fold_end cargo_fmt
170+
travis_fold_start cargo_clippy "cargo clippy" verbose
171+
rustup component add clippy
144172
cargo clippy --all --all-targets --all-features -- --deny warnings
173+
travis_fold_end cargo_clippy
145174
fi
146-
travis_end_fold check_rustfmt_clippy
147175

148176
# OK, the biggie: does it compile and pass the test suite?
149177

150-
travis_start_fold build_and_test "Build and test"
151178
if $is_docker_build ; then
179+
travis_fold_start docker_build "docker build" verbose
152180
docker build -t ttci-$IMAGE dist/docker/$IMAGE/
181+
travis_fold_end docker_build
182+
travis_fold_start docker_test "docker test" verbose
153183
docker run -v $(pwd):/tectonic ttci-$IMAGE
184+
travis_fold_end docker_test
154185
else
186+
travis_fold_start cargo_build "cargo build" verbose
155187
cargo build --verbose
188+
travis_fold_end cargo_build
189+
travis_fold_start cargo_test "cargo test" verbose
156190
cargo test
191+
travis_fold_end cargo_test
157192
fi
158-
travis_end_fold build_and_test
159193

160194
# OK! If we got this far, we think we made a functional set of (debug-mode)
161195
# Tectonic artifacts for this build matrix element.
162196

163197
# The main build is equipped to test code coverage.
164198

165-
travis_start_fold coverage "Maybe analyze code coverage? ($is_main_build)"
166199
if $is_main_build ; then
200+
travis_fold_start cargo_kcov "cargo kcov" verbose
167201
sudo apt-get install -y kcov
168202
cargo install --force cargo-kcov
169203
cargo test --no-run
170204
env RUNNING_COVERAGE=1 cargo kcov --no-clean-rebuild
171205
bash <(curl -s https://codecov.io/bash)
206+
travis_fold_end cargo_kcov
172207
fi
173-
travis_end_fold coverage
174208

175209
# If we're a "continuous deployment" build, we should push up artifacts for
176210
# the "continuous" pseudo-release. Right now, all we do is make an AppImage
@@ -179,9 +213,9 @@ travis_end_fold coverage
179213
# the build matrix to contribute various artifacts, we're going to need to
180214
# take a different tactic.
181215

182-
travis_start_fold continuous_deployment "Maybe continuous deployment activities? ($is_continuous_deployment_build)"
183216
if $is_continuous_deployment_build; then
184217
if $is_main_build; then
218+
travis_fold_start continuous "Continuous deployment" verbose
185219
# Careful! For the code coverage, we use "-C link-dead-code", which we
186220
# don't want for release artifacts. (Which are built with `cargo build
187221
# --release` inside dist/appimage/build.sh.) But if we ever add other
@@ -195,18 +229,18 @@ if $is_continuous_deployment_build; then
195229
UPDATE_INFORMATION="gh-releases-zsync|$repo_info|continuous|tectonic-*.AppImage.zsync" \
196230
dist/appimage/build.sh
197231
bash ./upload.sh dist/appimage/tectonic-*.AppImage*
232+
travis_fold_end continuous
198233
fi
199234

200235
# TODO: Do something with the Linux static build?
201236
fi
202-
travis_end_fold continuous_deployment
203237

204238
# If we're a release build, we should create and upload official release
205239
# artifacts, etc.
206240

207-
travis_start_fold release "Maybe release activities? ($is_release_build)"
208241
if $is_release_build; then
209242
if $is_main_build; then
243+
travis_fold_start release "Release deployment" verbose
210244
# Careful! See the warning above.
211245
unset RUSTFLAGS
212246

@@ -220,8 +254,8 @@ if $is_release_build; then
220254
-in dist/deploy_key.enc -out /tmp/deploy_key -d
221255
chmod 600 /tmp/deploy_key
222256
bash dist/arch/deploy.sh
257+
travis_fold_end release
223258
fi
224259

225260
# TODO: Do something with the Linux static build?
226261
fi
227-
travis_end_fold release

0 commit comments

Comments
 (0)