-
Notifications
You must be signed in to change notification settings - Fork 1
360 lines (308 loc) · 13.5 KB
/
ci_cd.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
# check spelling, codestyle
name: GitHub CI
# run only on main branch. This avoids duplicated actions on PRs
on:
pull_request:
push:
tags:
- "*"
branches:
- main
workflow_dispatch:
inputs:
api_branch:
description: "Branch of the 'ansys-api-acp' repository used during the build."
required: false
docker_image_suffix:
description: "Suffix of the 'pyacp' docker image used for testing. For example, ':latest', or '@sha256:<hash>' (without quotes)."
required: false
env:
MAIN_PYTHON_VERSION: "3.8"
PACKAGE_NAME: "ansys-acp-core"
DOCUMENTATION_CNAME: "acp.docs.pyansys.com"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
code-style:
name: "Pre-commit Check"
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: Pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-${{ runner.os }}-${{ hashFiles('poetry.lock') }}-precommit
restore-keys: |
pip-${{ runner.os }}
# pre-commit needs all dev dependencies, since it also checks the test and example files
# TODO: remove 'poetry config installer.modern-installation false' once we use a pydata-sphinx-theme
# version where https://github.com/pydata/pydata-sphinx-theme/issues/1253 is resolved.
# The same needs to be removed in the README.
- name: Install library, with all optional groups
run: |
git config --global url."https://${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/ansys-internal/ansys-api-acp".insteadOf "https://github.com/ansys-internal/ansys-api-acp"
git config --global url."https://${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/ansys-internal/ansys-tools-filetransfer".insteadOf "https://github.com/ansys-internal/ansys-tools-filetransfer"
git config --global url."https://${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/ansys-internal/ansys-api-tools-filetransfer".insteadOf "https://github.com/ansys-internal/ansys-api-tools-filetransfer"
git config --global url."https://${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/ansys-internal/ansys-tools-local-product-launcher".insteadOf "https://github.com/ansys-internal/ansys-tools-local-product-launcher"
pip install poetry
poetry config installer.modern-installation false
poetry install --with dev,test
- name: Install custom API branch if needed
if: "${{ github.event.inputs.api_branch != '' }}"
run: |
poetry run pip install --force-reinstall git+https://github.com/ansys-internal/ansys-api-acp.git@${{ github.event.inputs.api_branch }}
- name: Run pre-commit
run: |
poetry run pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
doc-style:
name: "Documentation style"
runs-on: ubuntu-latest
steps:
- uses: ansys/actions/doc-style@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
build:
name: Build packages
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: Pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-${{ runner.os }}-${{ hashFiles('poetry.lock') }}-precommit
restore-keys: |
pip-${{ runner.os }}
- name: Build packages
run: |
git config --global url."https://${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/ansys-internal/ansys-api-acp".insteadOf "https://github.com/ansys-internal/ansys-api-acp"
git config --global url."https://${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/ansys-internal/ansys-tools-local-product-launcher".insteadOf "https://github.com/ansys-internal/ansys-tools-local-product-launcher"
pip install poetry
poetry build
- name: Validate packages
run: |
pip install twine
twine check dist/*
- name: Upload packages
uses: actions/upload-artifact@v3
with:
name: Packages
path: dist/
retention-days: 7
testing:
name: Testing
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
python-version: ["3.8", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}-testing
restore-keys: |
pip-${{ runner.os }}-${{ matrix.python-version }}
- name: Install library, with test group
run: |
git config --global url."https://${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/ansys-internal/ansys-api-acp".insteadOf "https://github.com/ansys-internal/ansys-api-acp"
git config --global url."https://${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/ansys-internal/ansys-tools-filetransfer".insteadOf "https://github.com/ansys-internal/ansys-tools-filetransfer"
git config --global url."https://${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/ansys-internal/ansys-api-tools-filetransfer".insteadOf "https://github.com/ansys-internal/ansys-api-tools-filetransfer"
git config --global url."https://${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/ansys-internal/ansys-tools-local-product-launcher".insteadOf "https://github.com/ansys-internal/ansys-tools-local-product-launcher"
pip install poetry
poetry install --with test
- name: Install custom API branch if needed
if: "${{ github.event.inputs.api_branch != '' }}"
run: |
poetry run pip install --force-reinstall git+https://github.com/ansys-internal/ansys-api-acp.git@${{ github.event.inputs.api_branch }}
- name: Login in Github Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Unit testing
working-directory: tests/unittests
run: |
docker pull $IMAGE_NAME
poetry run pytest -v --license-server=1055@$LICENSE_SERVER --no-server-log-files --docker-image=$IMAGE_NAME
env:
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
IMAGE_NAME: "ghcr.io/ansys-internal/pyacp${{ github.event.inputs.docker_image_suffix || ':latest' }}"
- name: Benchmarks
working-directory: tests/benchmarks
run: |
poetry run pytest -v --license-server=1055@$LICENSE_SERVER --no-server-log-files --docker-image=$IMAGE_NAME --build-benchmark-image --benchmark-json benchmark_output.json --benchmark-group-by=fullname ${{ (matrix.python-version == '3.8' && github.ref == 'refs/heads/main') && ' ' || '--validate-benchmarks-only' }}
env:
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
IMAGE_NAME: "ghcr.io/ansys-internal/pyacp${{ github.event.inputs.docker_image_suffix || ':latest' }}"
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: 'PyACP benchmarks'
tool: 'pytest'
output-file-path: tests/benchmarks/benchmark_output.json
benchmark-data-dir-path: benchmarks
auto-push: true
github-token: ${{ secrets.GITHUB_TOKEN }}
if: matrix.python-version == '3.8' && github.ref == 'refs/heads/main'
docs:
name: Build Documentation
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: Pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-${{ runner.os }}-${{ hashFiles('poetry.lock') }}-docs
restore-keys: |
pip-${{ runner.os }}
- name: Login in Github Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: pyansys-ci-bot
password: ${{ secrets.PYANSYS_CI_BOT_PACKAGE_TOKEN }}
- name: Install OS packages
run: |
sudo apt update
sudo apt-get install pandoc xvfb
- name: Install library, with dev group
run: |
git config --global url."https://${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/ansys-internal/ansys-api-acp".insteadOf "https://github.com/ansys-internal/ansys-api-acp"
git config --global url."https://${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/ansys-internal/ansys-tools-filetransfer".insteadOf "https://github.com/ansys-internal/ansys-tools-filetransfer"
git config --global url."https://${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/ansys-internal/ansys-api-tools-filetransfer".insteadOf "https://github.com/ansys-internal/ansys-api-tools-filetransfer"
git config --global url."https://${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/ansys-internal/ansys-tools-local-product-launcher".insteadOf "https://github.com/ansys-internal/ansys-tools-local-product-launcher"
pip install poetry
poetry install --with dev
- name: Install custom API branch if needed
if: "${{ github.event.inputs.api_branch != '' }}"
run: |
poetry run pip install --force-reinstall git+https://github.com/ansys-internal/ansys-api-acp.git@${{ github.event.inputs.api_branch }}
- name: Configure Local Product Launcher for ACP
run: >
poetry run
ansys-launcher configure ACP docker_compose
--image_name_pyacp=ghcr.io/ansys-internal/pyacp${{ github.event.inputs.docker_image_suffix || ':latest' }}
--image_name_filetransfer=ghcr.io/ansys-internal/tools-filetransfer:latest
--license_server=1055@$LICENSE_SERVER
--keep_volume=False
--overwrite_default
env:
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
- name: Launch MAPDL and DPF servers via docker-compose
run: |
docker-compose -f ./docker-compose/docker-compose-extras.yaml up -d
env:
ANSYSLMD_LICENSE_FILE: "1055@${{ secrets.LICENSE_SERVER }}"
ANSYS_DPF_ACCEPT_LA: "Y"
- name: Build HTML
run: |
xvfb-run poetry run make -C doc html SPHINXOPTS="-W --keep-going -v"
- name: Stop and clean up MAPDL and DPF servers
run: |
docker-compose -f ./docker-compose/docker-compose-extras.yaml down -v
- name: Upload HTML Documentation
uses: actions/upload-artifact@v3
with:
name: documentation-html
path: doc/build/html
retention-days: 7
- name: Install OS packages for PDF build
run: |
sudo apt update
sudo apt install build-essential zip pandoc texlive-latex-extra latexmk texlive-pstricks
- name: Restart MAPDL and DPF servers via docker-compose
run: |
docker-compose -f ./docker-compose/docker-compose-extras.yaml up -d
env:
ANSYSLMD_LICENSE_FILE: "1055@${{ secrets.LICENSE_SERVER }}"
ANSYS_DPF_ACCEPT_LA: "Y"
- name: Build PDF Documentation
run: xvfb-run poetry run make -C doc pdf
- name: Upload PDF Documentation
uses: actions/upload-artifact@v3
with:
name: Documentation-pdf
path: doc/build/latex/ansys-acp-core.pdf
retention-days: 7
upload_dev_docs:
name: "Upload dev documentation"
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [docs]
steps:
- name: Deploy the latest documentation
uses: ansys/actions/doc-deploy-dev@v4
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
force-orphan: false
# Release:
# if: contains(github.ref, 'refs/tags')
# needs: [main, style, docs]
# runs-on: ubuntu-latest
# steps:
# - name: Set up Python
# uses: actions/setup-python@v1
# with:
# python-version: 3.9
# - uses: actions/checkout@v4
# - uses: actions/download-artifact@v2
# with:
# name: ansys-acp-core-wheel
# - uses: actions/download-artifact@v2
# with:
# name: Documentation-pdf
# - uses: actions/download-artifact@v2
# with:
# name: Documentation-html
# path: ~/html
# # list current directory
# - name: List directory structure
# run: ls -R
# - name: Deploy
# uses: JamesIves/[email protected]
# with:
# BRANCH: gh-pages
# FOLDER: ~/html
# CLEAN: true
# # note how we use the PyPI tokens
# - name: Upload to Azure PyPi (disabled)
# run: |
# pip install twine
# # twine upload --skip-existing ./**/*.whl
# env:
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
# - name: Release
# uses: softprops/action-gh-release@v1
# with:
# files: |
# ./**/*.whl
# ./**/*.zip
# ./**/*.pdf