-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci.sh
executable file
·89 lines (79 loc) · 3.05 KB
/
ci.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
#!/usr/bin/env bash
set -o errtrace -o nounset -o pipefail -o errexit
# Goto directory of this script
cd "$(dirname "${BASH_SOURCE[0]}")"
self_check () {
echo "############################################"
echo "# #"
echo "# Self-check #"
echo "# #"
echo "############################################"
# Don't fail here, failing later at the end when all shell scripts are checked anyway.
shellcheck ./ci.sh && echo "Self-check succeeded!" || echo "Self-check failed!"
}
setup () {
echo "############################################"
echo "# #"
echo "# Environment setup #"
echo "# #"
echo "############################################"
conda info -a || true
pip list --format=columns
}
unit_tests () {
echo "############################################"
echo "# #"
echo "# Unit testing #"
echo "# #"
echo "############################################"
python setup.py test
}
beautyci () {
echo "############################################"
echo "# #"
echo "# Beautysh #"
echo "# #"
echo "############################################"
pip install beautysh
beautysh --indent-size 2 --files ci.sh
}
shell_check () {
echo "############################################"
echo "# #"
echo "# Shellcheck #"
echo "# #"
echo "############################################"
find . -name "*.sh" -print0 | xargs -n 1 -0 shellcheck
}
create_source_distribution() {
echo "############################################"
echo "# #"
echo "# Creating a Source Distribution #"
echo "# #"
echo "############################################"
python setup.py sdist
}
check_for_clean_worktree() {
echo "############################################"
echo "# #"
echo "# Check for clean worktree #"
echo "# #"
echo "############################################"
# To be executed after all other steps, to ensures that there is no
# uncommitted code and there are no untracked files, which means .gitignore is
# complete and all code is part of a reviewable commit.
GIT_STATUS="$(git status --porcelain)"
if [[ $GIT_STATUS ]]; then
echo "Your worktree is not clean, there is either uncommitted code or there are untracked files:"
echo "${GIT_STATUS}"
exit 1
fi
}
self_check
setup
unit_tests
beautyci
shell_check
check_for_clean_worktree
create_source_distribution
check_for_clean_worktree