-
Notifications
You must be signed in to change notification settings - Fork 128
374 lines (316 loc) · 12.2 KB
/
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
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
name: GitHub Actions
on:
pull_request:
workflow_dispatch:
push:
tags:
- "*"
branches:
- main
env:
PYMAPDL_PORT: 21000 # default won't work on GitHub runners
PYMAPDL_DB_PORT: 21001 # default won't work on GitHub runners
PYMAPDL_START_INSTANCE: FALSE
PYANSYS_OFF_SCREEN: True
DOCKER_PACKAGE: ghcr.io/pyansys/pymapdl/mapdl
DOCKER_IMAGE_VERSION_DOCS_BUILD: v22.2.0
# Following env vars when changed will "reset" the mentioned cache,
# by changing the cache file name. It is rendered as ...-v%RESET_XXX%-...
# You should go up in number, if you go down (or repeat a previous value)
# you might end up reusing a previous cache if it haven't been deleted already.
# It applies 7 days retention policy by default.
RESET_PIP_CACHE: 3
RESET_EXAMPLES_CACHE: 3
RESET_DOC_BUILD_CACHE: 3
RESET_AUTOSUMMARY_CACHE: 3
PACKAGE_NAME: PyMAPDL
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
stylecheck:
name: Style Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/[email protected]
with:
python-version: 3.9
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
testimport:
name: Smoke Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
python-version: ['3.7', '3.8', '3.9']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Linux pip cache
uses: actions/cache@v2
if: ${{ runner.os == 'Linux' }}
with:
path: ~/.cache/pip
key: Python-v${{ env.RESET_PIP_CACHE }}-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements/requirements_tests.txt') }}
restore-keys: |
Python-v${{ env.RESET_PIP_CACHE }}-${{ runner.os }}-${{ matrix.python-version }}
- name: Window pip cache
uses: actions/cache@v2
if: ${{ runner.os == 'Windows' }}
with:
path: ~\AppData\Local\pip\Cache
key: Python-v${{ env.RESET_PIP_CACHE }}-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements/requirements_tests*.txt') }}
restore-keys: |
Python-v${{ env.RESET_PIP_CACHE }}-${{ runner.os }}-${{ matrix.python-version }}
- name: Install PyMAPDL
run: pip install .
- name: Test import
working-directory: tests
run: python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report(gpu=False))"
- name: Retrieve PyMAPDL version
run: |
echo "::set-output name=PYMAPDL_VERSION::$(python -c "from ansys.mapdl.core import __version__; print(__version__)")"
echo "PyMAPDL version is: $(python -c "from ansys.mapdl.core import __version__; print(__version__)")"
id: version
- name: Generate wheelhouse
run: pip wheel . -w wheelhouse
- name: Zip wheelhouse
uses: vimtor/action-zip@v1
with:
files: wheelhouse
dest: ${{ env.PACKAGE_NAME }}-v${{ steps.version.outputs.PYMAPDL_VERSION }}-wheelhouse-${{ runner.os }}-${{ matrix.python-version }}.zip
- name: Upload Wheelhouse
uses: actions/upload-artifact@v2
with:
name: ${{ env.PACKAGE_NAME }}-v${{ steps.version.outputs.PYMAPDL_VERSION }}-wheelhouse-${{ runner.os }}-${{ matrix.python-version }}
path: '*.zip'
retention-days: 7
docs_build:
name: Build Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# used for documentation deployment
- name: Get Bot Application Token
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v1
with:
application_id: ${{ secrets.BOT_APPLICATION_ID }}
application_private_key: ${{ secrets.BOT_APPLICATION_PRIVATE_KEY }}
- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
with:
# Optionally strip `v` prefix
strip_v: false
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install OS packages
run: |
sudo apt update
sudo apt install zip pandoc libgl1-mesa-glx xvfb texlive-latex-extra latexmk
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: Python-v${{ env.RESET_PIP_CACHE }}-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements/requirements_docs*.txt') }}
restore-keys: |
Python-v${{ env.RESET_PIP_CACHE }}-${{ runner.os }}-${{ matrix.python-version }}
- name: Test virtual framebuffer
run: |
pip install -r .ci/requirements_test_xvfb.txt
xvfb-run python .ci/display_test.py
- name: Install ansys-mapdl-core
run: |
pip install build
python -m build
pip install dist/ansys*.whl
xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())"
- name: Login in Github Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull, launch, and validate MAPDL service
run: .ci/start_mapdl.sh
env:
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
MAPDL_IMAGE: '${{ env.DOCKER_PACKAGE }}:${{ env.DOCKER_IMAGE_VERSION_DOCS_BUILD }}'
- name: Retrieve PyMAPDL version
run: |
echo "::set-output name=PYMAPDL_VERSION::$(python -c "from ansys.mapdl.core import __version__; print(__version__)")"
echo "PyMAPDL version is: $(python -c "from ansys.mapdl.core import __version__; print(__version__)")"
id: version
- name: Cache examples
uses: actions/cache@v2
with:
path: doc/source/examples
key: Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }}
restore-keys: |
Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}
- name: Cache docs build directory
uses: actions/cache@v2
with:
path: doc/build
key: doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }}
restore-keys: |
doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}
- name: Cache autosummary
uses: actions/cache@v2
with:
path: doc/source/**/_autosummary/*.rst
key: autosummary-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }}
restore-keys: |
autosummary-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}
- name: Install Docs Build Requirements
run: |
pip install -r requirements/requirements_docs.txt
- name: Build Documentation
run: |
xvfb-run make -C doc html SPHINXOPTS="-j auto -W --keep-going"
- name: Zip documentation
run: |
cd doc/build/html
zip -r PyMAPDL_documentation.zip *
- name: Upload HTML Documentation
uses: actions/upload-artifact@v2
with:
name: HTML-Documentation
path: doc/build/html/PyMAPDL_documentation.zip
retention-days: 7
- name: Deploy
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
uses: JamesIves/[email protected]
with:
repository-name: pyansys/pymapdl-docs
token: ${{ steps.get_workflow_token.outputs.token }}
branch: gh-pages
folder: doc/build/html
clean: true
tag: ${{steps.tag.outputs.tag}}
- name: Build PDF Documentation
working-directory: doc
run: make pdf
- name: Upload PDF Documentation
uses: actions/upload-artifact@v2
with:
name: PDF-Documentation
path: doc/build/latex/pymapdl*.pdf
retention-days: 7
build_test:
name: Build and Unit Testing
needs: testimport
runs-on: ubuntu-latest
strategy:
matrix:
mapdl-version: ['v21.1.1', 'v21.2.1', 'v22.1.0', 'v22.2.0']
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install OS packages
run: |
sudo apt update
sudo apt install libgl1-mesa-glx xvfb
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: Python-v${{ env.RESET_PIP_CACHE }}-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements/requirements_tests.txt') }}
restore-keys: |
Python-v${{ env.RESET_PIP_CACHE }}-${{ runner.os }}-${{ matrix.python-version }}
- name: Test virtual framebuffer
run: |
pip install -r .ci/requirements_test_xvfb.txt
xvfb-run python .ci/display_test.py
- name: Install ansys-mapdl-core
run: |
pip install build
python -m build
pip install dist/*.whl
xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())"
- name: Login in Github Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull, launch, and validate MAPDL service
run: .ci/start_mapdl.sh
env:
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
MAPDL_IMAGE: ${{ env.DOCKER_PACKAGE }}:${{ matrix.mapdl-version }}
- name: Unit Testing
run: |
pip install -r requirements/requirements_tests.txt
xvfb-run pytest -v --cov=ansys.mapdl.core --cov-report=xml --cov-report=html
- uses: codecov/codecov-action@v2
if: matrix.mapdl-version == 'v21.2.1'
name: 'Upload coverage to Codecov'
- name: Check package
run: |
pip install twine
twine check dist/*
- name: Upload wheel and binaries
uses: actions/upload-artifact@v2
with:
name: PyMAPDL-packages
path: dist/
retention-days: 7
- name: Display MAPDL Logs
if: always()
run: cat log.txt
Release:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
needs: [docs_build, build_test]
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.9
- uses: actions/download-artifact@v2
- name: Display structure of downloaded files
run: ls -R
- name: Upload to Public PyPi
run: |
pip install twine
twine upload --skip-existing ./**/*.whl
twine upload --skip-existing ./**/*.tar.gz
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
./**/*.whl
./**/*.tar.gz
./**/*.pdf
./**/*.zip
- name: Notify if fail
uses: skitionek/notify-microsoft-teams@master
if: ${{ failure() }}
with:
webhook_url: ${{ secrets.TEAM_HOOK }}
needs: ${{ toJson(needs) }}
job: ${{ toJson(job) }}
steps: ${{ toJson(steps) }}
overwrite: "{
title: `Release FAILED!`,
}"