forked from chronotope/chrono
-
Notifications
You must be signed in to change notification settings - Fork 0
/
github.sh
executable file
·133 lines (113 loc) · 3.78 KB
/
github.sh
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env bash
set -euo pipefail
# shellcheck source=ci/_shlib.sh
source "${BASH_SOURCE[0]%/*}/_shlib.sh"
TEST_TZS=(ACST-9:30 EST4 UTC0 Asia/Katmandu)
FEATURES=(std serde clock "alloc serde" unstable-locales)
CHECK_FEATURES=(alloc "std unstable-locales" "serde clock" "clock unstable-locales")
RUST_132_FEATURES=(rustc-serialize serde)
main() {
if [[ "$*" =~ "-h" ]]; then
echo -n "usage: ENV_VARS... $0
Recognized environment variables. Their values are as they are so that they are
meaningful in the github actions feature matrix UI.
RUST_VERSION The rust version currently being tested
This doesn't set the version, it is just used to test
WASM Empty or 'yes_wasm'
CORE 'std' or 'no_std'
EXHAUSTIVE_TZ Emptly or 'all_tzs'
CHECK_COMBINATORIC Combine various features and verify that we compile
"
exit
fi
runv cargo --version
if [[ ${RUST_VERSION:-} != 1.38.0 ]]; then
if [[ ${WASM:-} == yes_wasm ]]; then
test_wasm
elif [[ ${WASM:-} == wasm_simple ]]; then
test_wasm_simple
elif [[ ${WASM:-} == wasm_emscripten ]]; then
test_wasm_emscripten
elif [[ ${WASM:-} == wasm_unknown ]]; then
test_wasm_unknown
elif [[ ${WASM:-} == wasm_wasi ]]; then
test_wasm_wasi
elif [[ ${CORE:-} == no_std ]]; then
test_core
elif [[ ${EXHAUSTIVE_TZ:-} == all_tzs ]]; then
test_all_tzs
elif [[ ${CHECK_COMBINATORIC:-} == combinatoric ]]; then
check_combinatoric
else
test_regular UTC0
fi
elif [[ ${RUST_VERSION:-} == 1.38.0 ]]; then
test_132
else
echo "ERROR: didn't run any tests"
exit 1
fi
}
test_all_tzs() {
for tz in "${TEST_TZS[@]}"; do
test_regular "$tz"
done
}
test_regular() {
tz="$1" && shift
runt env TZ="$tz" cargo test --features __doctest,unstable-locales --color=always -- --color=always
for feature in "${FEATURES[@]}"; do
runt env TZ="$tz" cargo test --no-default-features --features "$feature" --lib --color=always -- --color=always
done
}
check_combinatoric() {
runt cargo check --no-default-features
runt cargo check --all-features
for feature in "${CHECK_FEATURES[@]}"; do
runt cargo check --no-default-features --features "$feature" --lib --color=always
done
}
test_132() {
runv cargo build --color=always
for feature in "${RUST_132_FEATURES[@]}"; do
runt cargo build --features "$feature" --color=always
done
}
test_core() {
(
cd ci/core-test
runt cargo build --target thumbv6m-none-eabi --color=always
)
}
test_wasm() {
if ! command -v node; then
echo "node is not installed, can't run wasm-pack tests"
exit 1
fi
if ! command -v wasm-pack >/dev/null; then
echo "::group::curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh"
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
runv wasm-pack --version
fi
test_wasm_simple
}
test_wasm_simple() {
if ! runt env TZ="$(date +%z)" NOW="$(date +%s)" wasm-pack test --node ; then
# sometimes on github the initial build takes 8-10 minutes, and we
# check that the time makes sense inside the test by approximately
# comparing it to the env var,
#
# so re-run the test in case it took too long
runt env TZ="$(date +%z)" NOW="$(date +%s)" wasm-pack test --node
fi
}
test_wasm_emscripten() {
runt cargo build --target wasm32-unknown-emscripten
}
test_wasm_unknown() {
runt cargo build --target wasm32-unknown-unknown
}
test_wasm_wasi() {
runt cargo build --target wasm32-wasi
}
main "$@"