-
Notifications
You must be signed in to change notification settings - Fork 1
220 lines (200 loc) · 5.74 KB
/
main.yaml
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
name: Run Code Checks
on:
push:
pull_request:
jobs:
pyenv:
runs-on: ubuntu-20.04
outputs:
cache-key: ${{ steps.cfg.outputs.cache-key }}
cache-path: ${{ steps.cfg.outputs.cache-path }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: cfg
id: cfg
run: |
cache_path="${{ env.pythonLocation }}"
cache_key="${cache_path}-${{ hashFiles('requirements.txt', 'requirements_dev.txt') }}"
echo "cache-key=${cache_key}" >> $GITHUB_OUTPUT
echo "cache-path=${cache_path}" >> $GITHUB_OUTPUT
- name: cache deps
uses: actions/cache@v4
id: py_cache
with:
path: ${{ steps.cfg.outputs.cache-path }}
key: ${{ steps.cfg.outputs.cache-key }}
restore-keys: |
${{ steps.cfg.outputs.cache-path }}-
- name: install dependencies
if: steps.py_cache.outputs.cache-hit != 'true'
run: |
pip install \
--upgrade --upgrade-strategy eager \
-r requirements.txt \
-r requirements_dev.txt
pip freeze
- name: dump
run: |
echo $LD_LIBRARY_PATH
echo "$PATH"
which python
python --version
black:
needs:
- pyenv
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Get Python Env from Cache
uses: actions/cache@v4
with:
key: ${{ needs.pyenv.outputs.cache-key }}
path: ${{ needs.pyenv.outputs.cache-path }}
- name: Update PATH
run: |
echo "${py_path}/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=${py_path}/lib" >> $GITHUB_ENV
env:
py_path: ${{ needs.pyenv.outputs.cache-path }}
- name: run black
run: |
black --version
black --check --diff hdc tests
linting:
needs:
- pyenv
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Get Python Env from Cache
uses: actions/cache@v4
with:
key: ${{ needs.pyenv.outputs.cache-key }}
path: ${{ needs.pyenv.outputs.cache-path }}
- name: Update PATH
run: |
echo "${py_path}/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=${py_path}/lib" >> $GITHUB_ENV
env:
py_path: ${{ needs.pyenv.outputs.cache-path }}
- name: pylint
run: pylint hdc
- name: pydocstyle
run: pydocstyle hdc
- name: mypy
run: mypy hdc
wheels:
needs:
- pyenv
- black
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Get Python Env from Cache
uses: actions/cache@v4
with:
key: ${{ needs.pyenv.outputs.cache-key }}
path: ${{ needs.pyenv.outputs.cache-path }}
- name: Update PATH
shell: bash
run: |
echo "${py_path}/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=${py_path}/lib" >> $GITHUB_ENV
env:
py_path: ${{ needs.pyenv.outputs.cache-path }}
- uses: actions/cache@v4
id: wheels_cache
with:
path: ./wheels
key: wheels-${{ github.sha }}
- name: build wheels unpatched
run: |
mkdir -p wheels
pip wheel \
--verbose \
--no-input \
--no-deps \
--exists-action w \
--wheel-dir wheels \
.
python setup.py sdist -d wheels
- name: patch version
run: |
python ./scripts/patch_version.py ${GITHUB_RUN_NUMBER:-0} ./hdc/algo/_version.py
- name: build wheels patched version
run: |
pip wheel \
--verbose \
--no-input \
--no-deps \
--exists-action w \
--wheel-dir wheels \
.
python setup.py sdist -d wheels
- name: Upload results (artifact)
uses: actions/upload-artifact@v4
with:
name: wheels
path: wheels
if-no-files-found: error
tests:
needs:
- pyenv
- black
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Get Python Env from Cache
uses: actions/cache@v4
with:
key: ${{ needs.pyenv.outputs.cache-key }}
path: ${{ needs.pyenv.outputs.cache-path }}
- name: Update PATH
shell: bash
run: |
echo "${py_path}/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=${py_path}/lib" >> $GITHUB_ENV
env:
py_path: ${{ needs.pyenv.outputs.cache-path }}
- name: Run test with coverage
run: |
python -m pytest -s \
--cov \
--cov-report=term \
tests/
test-wheel:
needs:
- pyenv
- black
- wheels
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Get Python Env from Cache
uses: actions/cache@v4
with:
key: ${{ needs.pyenv.outputs.cache-key }}
path: ${{ needs.pyenv.outputs.cache-path }}
- name: Update PATH
shell: bash
run: |
echo "${py_path}/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=${py_path}/lib" >> $GITHUB_ENV
env:
py_path: ${{ needs.pyenv.outputs.cache-path }}
- name: Get Wheels
uses: actions/download-artifact@v4
with:
name: wheels
path: wheels
- name: Install dev wheel
run: |
find wheels/ -type f -name "*.dev*.whl" | head -1 | xargs python -m pip install
- name: Test Code from the wheel
run: |
cd tests/
python -m pytest -s .