-
Notifications
You must be signed in to change notification settings - Fork 21
244 lines (221 loc) · 8.05 KB
/
pr_master_test.yml
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
name: GitHub CI
on:
push:
branches:
- master
pull_request:
branches:
- master
defaults:
run:
shell: bash -l {0}
env:
PYTHONWARNINGS: ignore::UserWarning
PYTHON_BASE_PKGS: >
coverage xlrd
jobs:
build:
name: ${{ matrix.TARGET }}/${{ matrix.python }}${{ matrix.NAME }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3]
include:
- os: ubuntu-latest
TARGET: linux
PYENV: pip
- os: macos-latest
TARGET: osx
PYENV: pip
- os: windows-latest
TARGET: win
PYENV: conda
PACKAGES: setuptools coverage nose xlrd
exclude:
- {os: macos-latest, python: pypy2}
- {os: macos-latest, python: pypy3}
- {os: windows-latest, python: pypy2}
- {os: windows-latest, python: pypy3}
steps:
- uses: actions/checkout@v2
- name: Pip package cache
uses: actions/cache@v2
if: matrix.PYENV == 'pip'
id: pip-cache
with:
path: cache/pip
key: pip-v2-${{runner.os}}-${{matrix.python}}
- name: Download cache
uses: actions/cache@v2
id: download-cache
with:
path: cache/download
key: download-v4-${{runner.os}}
- name: Configure curl
run: |
CURLRC="$(cat <<EOF
retry = 0
max-time = 30
EOF
)"
echo "$CURLRC" > ${GITHUB_WORKSPACE}/.curlrc
echo "$CURLRC" > ${GITHUB_WORKSPACE}/_curlrc
echo "::set-env name=CURL_HOME::$GITHUB_WORKSPACE"
- name: Set up Python ${{ matrix.python }}
if: matrix.PYENV == 'pip'
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
- name: Set up Miniconda Python ${{ matrix.python }}
if: matrix.PYENV == 'conda'
uses: goanpeca/setup-miniconda@v1
with:
auto-update-conda: true
python-version: ${{ matrix.python }}
# GitHub actions is very fragile when it comes to setting up various
# Python interpreters, expecially the setup-miniconda interface.
# Per the setup-miniconda documentation, it is important to always
# invoke bash as a login shell ('shell: bash -l {0}') so that the
# conda environment is properly activated. However, running within
# a login shell appears to foul up the link to python from
# setup-python. Further, we have anecdotal evidence that
# subprocesses invoked through $(python -c ...) and `python -c ...`
# will not pick up the python activated by setup-python on OSX.
#
# Our solution is to define a PYTHON_EXE environment variable that
# can be explicitly called within subprocess calls to reach the
# correct interpreter. Note that we must explicitly run in a *non*
# login shell to set up the environment variable for the
# setup-python environments.
- name: Install Python Packages (pip)
if: matrix.PYENV == 'pip'
shell: bash
run: |
python -m pip install --cache-dir cache/pip --upgrade pip
pip install --cache-dir cache/pip ${PYTHON_BASE_PKGS}
if [[ ${{matrix.python}} == pypy ]] || [[ ${{matrix.python}} == 2.7 ]]; then
pip install --cache-dir cache/pip pyro
else
pip install --cache-dir cache/pip pyro4
fi
if [[ ${{matrix.python}} == 3.4 ]]; then
pip install --cache-dir cache/pip pyyaml<=5.2
elif [[ ${{matrix.python}} != 3.6 ]]; then
pip install --cache-dir cache/pip pyyaml
fi
python -c 'import sys; print("::set-env name=PYTHON_EXE::%s" \
% (sys.executable,))'
- name: Install Python packages (conda)
if: matrix.PYENV == 'conda'
run: |
mkdir -p $GITHUB_WORKSPACE/cache/conda
conda config --set always_yes yes
conda config --set auto_update_conda false
conda config --prepend pkgs_dirs $GITHUB_WORKSPACE/cache/conda
conda info
conda config --show-sources
conda list --show-channel-urls
conda install -q -y -c conda-forge -c anaconda ${{matrix.PACKAGES}}
python -c 'import sys; print("::set-env name=PYTHON_EXE::%s" \
% (sys.executable,))'
- name: Install Pyutilib
run: |
$PYTHON_EXE setup.py develop
- name: Set up coverage tracking
run: |
if test "${{matrix.TARGET}}" == win; then
COVERAGE_BASE=${GITHUB_WORKSPACE}\\.cover
else
COVERAGE_BASE=${GITHUB_WORKSPACE}/.cover
fi
COVERAGE_RC=${COVERAGE_BASE}_rc
echo "::set-env name=COVERAGE_RCFILE::$COVERAGE_RC"
echo "::set-env name=COVERAGE_PROCESS_START::$COVERAGE_RC"
cp ${GITHUB_WORKSPACE}/.coveragerc ${COVERAGE_RC}
echo "[run]" >> ${COVERAGE_RC}
echo "data_file=${COVERAGE_BASE}age" >> ${COVERAGE_RC}
SITE_PACKAGES=$($PYTHON_EXE -c "from distutils.sysconfig import \
get_python_lib; print(get_python_lib())")
echo "Python site-packages: $SITE_PACKAGES"
echo 'import coverage; coverage.process_startup()' \
> ${SITE_PACKAGES}/run_coverage_at_startup.pth
cat ${COVERAGE_RC}
- name: Run Pyutilib tests
run: |
if [ ${{matrix.TARGET}} == 'osx' ]; then
PYTHON_DIR=`dirname $PYTHON_EXE`
export PATH=$PYTHON_DIR:$PATH
fi
test.pyutilib --cat=all -v
- name: Process code coverage report
env:
CODECOV_NAME: ${{matrix.TARGET}}/${{matrix.python}}${{matrix.NAME}}
run: |
[ ! -d ${GITHUB_WORKSPACE}/cache/download ] && mkdir -pv ${GITHUB_WORKSPACE}/cache/download
coverage combine || echo "Nothing to combine."
coverage report -i
coverage xml -i
set +e
# Always attempt to update the codecov script, but fall back on
# the previously cached script if it fails
CODECOV="${GITHUB_WORKSPACE}/cache/download/codecov.sh"
for i in `seq 3`; do
echo "Downloading current codecov script (attempt ${i})"
curl -L https://codecov.io/bash -o $CODECOV
if test $? == 0; then
break
fi
DELAY=$(( RANDOM % 30 + 30))
echo "Pausing $DELAY seconds before re-attempting download"
sleep $DELAY
done
i=0
while : ; do
((i+=1))
echo "Uploading coverage to codecov (attempt ${i})"
bash $CODECOV -Z -X gcov -X s3 -f coverage.xml
if test $? == 0; then
echo "PASS" > ${GITHUB_WORKSPACE}/codecov.result
break
elif test $i -ge 2; then
# Do not fail the build just because the codecov upload fails
echo "FAIL" > ${GITHUB_WORKSPACE}/codecov.result
break
fi
DELAY=$(( RANDOM % 30 + 30))
echo "Pausing $DELAY seconds before re-attempting upload"
sleep $DELAY
done
- name: Record build artifacts
uses: actions/upload-artifact@v2
with:
name: ${{github.job}}_${{env.GHA_JOBNAME}}
path: |
codecov.result
# In general, do not record test results as artifacts to
# manage total artifact storage
# TEST-*.xml
post:
name: post-build
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Check codecov upload success
run: |
FAIL=`grep FAIL artifacts/*/codecov.result | wc -l`
ALL=`ls -1 artifacts/*/codecov.result | wc -l`
# Fail is more than 1/9 codecov uploads fail
echo "$FAIL of $ALL codecov uploads failed"
if test $FAIL -gt 0; then
grep FAIL artifacts/*/codecov.result | sed 's/^/ /'
if test $(( $FAIL * 9 )) -gt $ALL; then
echo "More than 1/9 codecov uploads failed:"
exit 1
fi
fi