-
Notifications
You must be signed in to change notification settings - Fork 31
190 lines (164 loc) · 6.66 KB
/
pnl-ci.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
name: PsyNeuLink CI
on:
push:
branches-ignore:
- 'dependabot/**'
paths-ignore:
- 'docs/**'
- 'doc_requirements.txt'
tags-ignore:
- 'v**'
pull_request:
env:
SELF_HOSTED_MACOS: ${{ secrets.SELF_HOSTED_MACOS }}
SELF_HOSTED_LINUX: ${{ secrets.SELF_HOSTED_LINUX }}
SELF_HOSTED_WINDOWS: ${{ secrets.SELF_HOSTED_WINDOWS }}
# run only the latest instance of this workflow job for the current branch/PR
# cancel older runs
# fall back to run id if not available (run id is unique -> no cancellations)
concurrency:
group: ci-${{ github.ref || github.run_id }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
# A job to select self-hosted runner if requested by an env var
select-runner:
runs-on: ubuntu-latest
outputs:
self_hosted_macos: ${{ steps.is_self_hosted.outputs.macos && 'macos' || '' }}
self_hosted_linux: ${{ steps.is_self_hosted.outputs.linux && 'linux' || '' }}
self_hosted_windows: ${{ steps.is_self_hosted.outputs.windows && 'windows' || '' }}
steps:
- name: Add macos
id: is_self_hosted
run: |
echo "macos=$SELF_HOSTED_MACOS" | tee -a $GITHUB_OUTPUT
echo "linux=$SELF_HOSTED_LINUX" | tee -a $GITHUB_OUTPUT
echo "windows=$SELF_HOSTED_WINDOWS" | tee -a $GITHUB_OUTPUT
# the main build job
build:
needs: select-runner
runs-on: ${{ (contains(needs.select-runner.outputs.*, matrix.os) && fromJSON(format('[ "self-hosted","{0}", "X64" ]', matrix.os))) || format('{0}-latest', matrix.os) }}
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.11']
python-architecture: ['x64']
extra-args: ['']
os: [ubuntu, macos, windows]
include:
# code-coverage build on macos python 3.9
- python-version: '3.9'
os: macos
extra-args: '--cov=psyneulink'
# --forked run of python only tests
# Python tests are enough to test potential naming issues
- python-version: '3.9'
os: ubuntu
extra-args: '--forked -m "not llvm"'
# add 32-bit build on windows
- python-version: '3.8'
python-architecture: 'x86'
os: windows
# fp32 run on linux python 3.10
- python-version: '3.10'
os: ubuntu
extra-args: '--fp-precision=fp32'
# --benchmark-enable run on macos python 3.10
- python-version: '3.10'
os: macos
# pytest needs both '--benchmark-only' and '-m benchmark'
# The former fails the test if benchamrks cannot be enabled
# The latter works around a crash in pytest when collecting tests:
# https://github.com/ionelmc/pytest-benchmark/issues/243
extra-args: '-m benchmark --benchmark-enable --benchmark-only --benchmark-min-rounds=2 --benchmark-max-time=0.001 --benchmark-warmup=off -n0 --dist=no'
# add python 3.8 build on macos since 3.7 is broken
# https://github.com/actions/virtual-environments/issues/4230
- python-version: '3.8'
python-architecture: 'x64'
os: macos
exclude:
# 3.7 is broken on macos-11,
# https://github.com/actions/virtual-environments/issues/4230
- python-version: '3.7'
os: macos
steps:
# increased fetch-depth and tag checkout needed to get correct
# version string from versioneer (must have history to a prior tag);
# otherwise install fails due to circular dependency with modeci_mdf
- name: Checkout sources
uses: actions/checkout@v3
with:
fetch-depth: 200
# fetch only master to avoid getting unneeded branches with
# characters invalid on windows
- name: Checkout tags
run: git fetch --tags origin master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.python-architecture }}
- name: Get pip cache location
shell: bash
id: pip_cache
run: |
python -m pip install -U pip
python -m pip --version
echo "pip_cache_dir=$(python -m pip cache dir)" | tee -a $GITHUB_OUTPUT
- name: Wheels cache
uses: actions/cache@v3
with:
path: ${{ steps.pip_cache.outputs.pip_cache_dir }}/wheels
key: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ matrix.python-architecture }}-pip-wheels-${{ hashFiles('requirements.txt', 'dev_requirements.txt') }}-${{ github.sha }}
restore-keys: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ matrix.python-architecture }}-pip-wheels-${{ hashFiles('requirements.txt', 'dev_requirements.txt') }}
- name: Install local, editable PNL package
uses: ./.github/actions/install-pnl
with:
features: 'dev'
- name: Lint with flake8
shell: bash
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --exit-zero --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Print test machine/env info
shell: bash
run: |
python -c "import numpy; numpy.show_config()"
case "$RUNNER_OS" in
Linux*) lscpu;;
esac
- name: Test with pytest
timeout-minutes: 180
run: pytest --junit-xml=tests_out.xml --verbosity=0 -n auto ${{ matrix.extra-args }}
- name: Upload test results
uses: actions/upload-artifact@v3
with:
name: test-results-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.python-architecture }}
path: tests_out.xml
retention-days: 5
if: (success() || failure()) && ! contains(matrix.extra-args, 'forked')
- name: Upload coveralls code coverage
if: contains(matrix.extra-args, '--cov=psyneulink')
shell: bash
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
if [ -n "$COVERALLS_REPO_TOKEN" ]; then
pip install coveralls
coveralls
else
echo "::warning::Not uploading to coveralls.io, token not available!"
fi
- name: Build dist
run: |
pip install setuptools wheel
python setup.py sdist bdist_wheel
- name: Upload dist packages
uses: actions/upload-artifact@v3
with:
name: dist-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.python-architecture }}
path: dist/
retention-days: 2