Skip to content

Commit ed181d6

Browse files
committed
Added support for additional linters (html-proofer link checker)
- added additional test matrix item just for linters - install and build mdbook only when needed to speedup CI - reorganized the travis scripts
1 parent deb4ef6 commit ed181d6

File tree

4 files changed

+90
-11
lines changed

4 files changed

+90
-11
lines changed

.travis.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,21 @@ env:
1212
global:
1313
- secure: m28oDDxTcaLlbCXv9la/yz0PzafOCDuhOhmHRoc1ELQC0wc3r6HT3a2myrP5ewQQhaxYDzd2XXYDJB3odFV1qLQOp0hFDgNn/w3ctWZpJdLxIJN6dsaPL/azhE2hz7T+SPEoWLwTW1va6bu4wwzSOykt9//RIK0ZoyVMCRSAlMB965iMV2Nkw7SWdQZ8SlskMVk8sB103N5+WTtt6rse54jHnXTpFEq9q0EAXC1R3GBDKEWB7iwb0c++Kw46Fz86ZJJDotiVuxMtsEk0VfT0Yxx665is5Ko6sV4cahbuXqMIqYYEfqpTHNHadHWD1m1i32hW9Rjtt9fFZ+a8m9zfTixPlkfOZvQ94RnD2zqv9qiwFr8oR7t2SsZaB4aqPlJd45DqgnwQ1B0cmrUAsjSB2+1DQDkR4FgKFB/o1c6F6g8imNh+2OwiZXVLwIimXNJQ5xfZeObXFMrEZ0+uj7oxFX49EcwE/SvwsVJHST3/zL5QuQwa9/uVhW/x135/Z2ypVao2xydpow/KL8VwhX9YsOSP5ApffL4OLJ5hE9qwS/SShHGg8AenFqqm/UNFqWDU+C097YaWvG5PEvCVXvOofic65AUTCmwB+h3MSQmZIqz2sb/kwdbtkoRRR6maMgelQmg1JdIfQcKeTJIStIihjk54VENHPVAslz0oV7Ia5Bo=
1414

15+
matrix:
16+
include:
17+
- rust: stable
18+
os: linux
19+
env: CONTENT_TESTS=1
20+
allow_failures:
21+
- rust: stable
22+
os: linux
23+
env: CONTENT_TESTS=1
24+
25+
1526
before_install:
16-
- cargo install mdbook --vers '0.0.25' --debug
27+
- ./ci/install_deps.sh
1728
- export PATH=$HOME/.cargo/bin:$PATH
1829

19-
after_success: ./deploy.sh
30+
script: ./ci/test_script.sh
31+
32+
after_success: ./ci/deploy.sh

deploy.sh renamed to ci/deploy.sh

+17-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -o errexit -o nounset
44

5+
echo "Running $0"
6+
57
if [ -z "${TRAVIS_BRANCH:-}" ]; then
68
echo "This script may only be run from Travis!"
79
exit 1
@@ -14,16 +16,22 @@ if [[ "$TRAVIS_BRANCH" != "master" || "$TRAVIS_RUST_VERSION" != "stable" || "$TR
1416
exit 0
1517
fi
1618

17-
# check for outdated dependencies on nightly builds
18-
if [ "${TRAVIS_EVENT_TYPE:-}" == "cron" ]; then
19-
echo "This is cron build. Checking for outdated dependencies!"
20-
rm ./Cargo.lock
21-
cargo clean
22-
# replace all [dependencies] versions with "*"
23-
sed -i -e "/^\[dependencies\]/,/^\[.*\]/ s|^\(.*=[ \t]*\).*$|\1\"\*\"|" ./Cargo.toml
2419

25-
cargo test || { echo "Cron build failed! Dependencies outdated!"; exit 1; }
26-
echo "Cron build success! Dependencies are up to date!"
20+
if [ -z "${CONTENT_TESTS:-}" ]; then
21+
# check for outdated dependencies on nightly builds
22+
if [ "${TRAVIS_EVENT_TYPE:-}" == "cron" ]; then
23+
echo "This is cron build. Checking for outdated dependencies!"
24+
rm ./Cargo.lock
25+
cargo clean
26+
# replace all [dependencies] versions with "*"
27+
sed -i -e "/^\[dependencies\]/,/^\[.*\]/ s|^\(.*=[ \t]*\).*$|\1\"\*\"|" ./Cargo.toml
28+
29+
cargo test || { echo "Cron build failed! Dependencies outdated!"; exit 1; }
30+
echo "Cron build success! Dependencies are up to date!"
31+
exit 0
32+
fi
33+
34+
echo "We deploy only after we also test the markup and descriptions!"
2735
exit 0
2836
fi
2937

ci/install_deps.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -o errexit -o nounset
4+
5+
echo "Running $0"
6+
7+
if [ -z "${TRAVIS_BRANCH:-}" ]; then
8+
echo "This script may only be run from Travis!"
9+
exit 1
10+
fi
11+
12+
if [[ "${CONTENT_TESTS:-}" == 1 ]]; then
13+
echo "Installing additional dependencies"
14+
gem install html-proofer
15+
cargo install mdbook --vers '0.0.25' --debug
16+
fi
17+
18+
exit 0
19+

ci/test_script.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
set -o errexit -o nounset
4+
5+
echo "Running $0"
6+
7+
if [ -z "${TRAVIS_BRANCH:-}" ]; then
8+
echo "This script may only be run from Travis!"
9+
exit 1
10+
fi
11+
12+
# Returns 1 if program is installed and 0 otherwise
13+
program_installed() {
14+
local return_=1
15+
16+
type $1 >/dev/null 2>&1 || { local return_=0; }
17+
18+
echo "$return_"
19+
}
20+
21+
if [[ "${CONTENT_TESTS:-}" == 1 ]]; then
22+
# Ensure required programs are installed
23+
if [ $(program_installed htmlproofer) == 0 ]; then
24+
echo "Please install htmlproofer: gem install html-proofer"
25+
exit 1
26+
elif [ $(program_installed mdbook) == 0 ]; then
27+
echo "Please install mdbook: cargo install mdbook."
28+
exit 1
29+
fi
30+
31+
echo "Testing markup and descriptions"
32+
echo "Building site to book/"
33+
mdbook build
34+
htmlproofer --empty-alt-ignore ./book/
35+
else
36+
echo "Testing code snippets"
37+
cargo build --verbose
38+
cargo test --verbose
39+
fi

0 commit comments

Comments
 (0)