-
Notifications
You must be signed in to change notification settings - Fork 0
/
travis-script
executable file
·79 lines (64 loc) · 2.07 KB
/
travis-script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh -xeu
ZI_DUMP_CSV="https://github.com/zapret-info/z-i/raw/0f69ad8852a79fa3ba3a9a788b8e2157cd1da9f7/dump.csv"
CURL_OPTS="--connect-timeout 15 --location"
is_nightly() {
# Fixed version of nightly for clippy.
echo "${TRAVIS_RUST_VERSION}" | grep -qe "^nightly"
}
is_nightly_for_clippy() {
# Fixed version of nightly for clippy.
echo "${TRAVIS_RUST_VERSION}" | grep -qe "^nightly-.*"
}
workspace_members() {
sed -ne 's,^ *"\([^ "]*\)".*$,\1,p' <Cargo.toml
}
crate_has_unstable_feature() {
grep -qe "^ *unstable *= *\[ *\] *$" Cargo.toml
}
is_binary_crate() {
test -e src/main.rs
}
if [ "${1}" = "before_script" ]; then
if is_nightly_for_clippy; then
cargo install clippy --version "${CLIPPY_VERSION}" --force
fi
elif [ "${1}" = "script" ]; then
if is_nightly_for_clippy; then
cargo clippy --all --features unstable --all-targets
fi
for crate in $( workspace_members ); do
(
cd "${crate}"
if is_nightly; then
targets="--all-targets"
if crate_has_unstable_feature; then
features="--features unstable"
else
features=""
fi
else
if is_binary_crate; then
targets=""
else
targets="--all-targets"
fi
features=""
fi
# tests/skeptic.rs fails without this.
cargo clean
cargo test --verbose $features
# tests/skeptic.rs fails without this.
cargo clean
cargo test --release --verbose $features
cargo build --verbose $targets $features
cargo build --release --verbose $targets $features
)
done
curl $CURL_OPTS --output "./dump.csv" "${ZI_DUMP_CSV}"
for build_type in "debug" "release"; do
"./target/${build_type}/zicsv-tool" --input "./dump.csv" into-json --disable-pretty >/dev/null
done
else
printf "Unknown command: %s\n" "${1}" >&2
exit 1
fi