-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
ci.sh
executable file
·137 lines (106 loc) · 3.59 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
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
134
135
136
137
#!/bin/bash
set -ex -o pipefail
CHECK_FILES="src tests"
YAPF_VERSION=0.20.1
# Log some general info about the environment
echo "::group::Environment"
uname -a
env | sort
echo "::endgroup::"
################################################################
# We have a Python environment!
################################################################
echo "::group::Versions"
python -c "import sys, struct; print('python:', sys.version); print('version_info:', sys.version_info); print('bits:', struct.calcsize('P') * 8)"
echo "::endgroup::"
echo "::group::Install dependencies"
python -m pip install -U pip build
python -m pip --version
python -m build
python -m pip install dist/*.whl
echo "::endgroup::"
echo "::group::Setup for tests"
# Install dependencies.
pip install -Ur test-requirements.txt
echo "::endgroup::"
if [ "$CHECK_FORMATTING" = "1" ]; then
echo "::group::Yapf"
pip install yapf==${YAPF_VERSION} "isort>=5" mypy pyright
if ! yapf -rpd $CHECK_FILES; then
echo "::endgroup::"
cat <<EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Formatting problems were found (listed above). To fix them, run
pip install yapf==${YAPF_VERSION}
yapf -rpi $CHECK_FILES
in your local checkout.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EOF
echo "::error:: yapf found issues"
exit 1
else
echo "::endgroup::"
fi
echo "::group::isort"
if ! isort --check-only --diff $CHECK_FILES ; then
echo "::endgroup::"
cat <<EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Formatting problems were found (listed above). To fix them, run
pip install isort
isort $CHECK_FILES
in your local checkout.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EOF
echo "::error:: isort found issues"
exit 1
else
echo "::endgroup::"
fi
echo "::group::Mypy"
if ! mypy src/ tests/type_tests.py ; then
echo "::endgroup::"
cat <<EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Type checking errors were found (listed above). To get more detail, run
pip install mypy
mypy src/ tests/type_tests.py
in your local checkout.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EOF
echo "::error:: Mypy found issues"
exit 1
else
echo "::endgroup::"
fi
echo "::group::Pyright"
if ! pyright --verifytypes outcome src/outcome/ ; then
cat <<EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Types are not complete (listed above). To get more detail, run
pip install pyright
pyright --verifytypes outcome src/outcome/
in your local checkout.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EOF
echo "::error:: Pyright found issues"
exit 1
else
echo "::endgroup::"
fi
exit 0
fi
echo "::group:: Run Tests"
pytest -W error -ra -v tests --cov --cov-config=.coveragerc
echo "::endgroup::"
echo "::group:: Code Coverage"
bash <(curl -s https://codecov.io/bash)
echo "::endgroup::"