-
Notifications
You must be signed in to change notification settings - Fork 0
416 lines (360 loc) · 13.2 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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
name: GitHub CI
on:
pull_request:
workflow_dispatch:
push:
tags:
- "*"
branches:
- main
env:
MAIN_PYTHON_VERSION: '3.10'
PACKAGE_NAME: ansys-mechanical-stubs
PACKAGE_NAMESPACE: ansys.mechanical.stubs
PACKAGE_PATH: src/ansys/mechanical/stubs
DOCUMENTATION_CNAME: scripting.mechanical.docs.pyansys.com
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
ANSYSLMD_LICENSE_FILE: 1055@${{ secrets.LICENSE_SERVER }}
ANSYS_WORKBENCH_LOGGING_CONSOLE: 0
ANSYS_WORKBENCH_LOGGING: 0
ANSYS_WORKBENCH_LOGGING_FILTER_LEVEL: 2
NUM_CORES: 1
MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY }}
MEILISEARCH_HOST_URL: ${{ vars.MEILISEARCH_HOST_URL }}
MEILISEARCH_PUBLIC_API_KEY: ${{ secrets.MEILISEARCH_PUBLIC_API_KEY }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
update-changelog:
name: "Update CHANGELOG for new tag"
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: ansys/actions/doc-deploy-changelog@v8
with:
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}
style:
name: Code style
runs-on: ubuntu-latest
steps:
- name: "PyAnsys code style checks"
uses: ansys/actions/code-style@v8
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
doc-style:
name: Documentation style check
runs-on: ubuntu-latest
steps:
- name: "PyAnsys documentation style checks"
uses: ansys/actions/doc-style@v8
with:
vale-config: doc/.vale.ini
token: ${{ secrets.GITHUB_TOKEN }}
gen-stubs:
name: Generate Mechanical stubs
needs: [style, doc-style]
runs-on: ${{ matrix.os }}
container:
image: ghcr.io/ansys/mechanical:${{ matrix.mechanical.image }}
options: --entrypoint /bin/bash
strategy:
matrix:
os: [public-ubuntu-latest-8-cores]
mechanical: [
{ image: '24.1.0', version: '241' },
{ image: '24.2.0', version: '242' },
]
python-version: ['3.10', '3.11', '3.12']
steps:
- name: "Install Git and clone project"
uses: actions/checkout@v4
- name: "Install dependencies"
env:
AWP_ROOTDV_DEV: /install/ansys_inc/v${{ matrix.mechanical.version }}
ANSYSCL${{ matrix.mechanical.version }}_DIR: /install/ansys_inc/v${{ matrix.mechanical.version }}/licensingclient
run: |
apt update
apt install --reinstall ca-certificates
apt install software-properties-common -y
add-apt-repository ppa:deadsnakes/ppa -y
apt install python${{ matrix.python-version }} -y
ln -s /usr/bin/python${{ matrix.python-version }} /usr/bin/python
apt install python${{ matrix.python-version }}-venv -y
apt install -y lsb-release mono-complete make git zip
python -m ensurepip --default-pip
python -m pip install --upgrade pip
python --version
python -m pip --version
python -m pip install -e .[build,doc]
python -m pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org pip setuptools
python -m pip install --upgrade pip flit pytz tzdata ansys-pythonnet
- name: "Generate the Mechanical stub files"
env:
AWP_ROOTDV_DEV: /install/ansys_inc/v${{ matrix.mechanical.version }}
ANSYSCL${{ matrix.mechanical.version }}_DIR: /install/ansys_inc/v${{ matrix.mechanical.version }}/licensingclient
run: |
python src/ansys/mechanical/stubs/stub_generator/create_files.py > results.txt
continue-on-error: True
- name: "Check stubs were generated"
run: |
cat results.txt
# Check if failure occurred
output=$(grep -c "Done processing all mechanical stubs" results.txt)
if [ $output -eq 1 ]; then
echo "All mechanical stubs were created"
exit 0
else
echo "There was an issue creating the mechanical stubs"
exit 1
fi
- name: "Upload v${{ matrix.mechanical.version }} stubs"
uses: actions/upload-artifact@v4
with:
name: v${{ matrix.mechanical.version }}-${{ matrix.python-version }}
path: ${{ env.PACKAGE_PATH }}/v${{ matrix.mechanical.version }}
retention-days: 7
smoke-tests:
name: Build wheelhouse
runs-on: ${{ matrix.os }}
needs: [gen-stubs]
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.10', '3.11', '3.12']
steps:
- name: "Install Git and clone project"
uses: actions/checkout@v4
- name: "Download stubs"
uses: ./.github/workflows/setup-stubs/
with:
folder-pattern: "v[0-9][0-9][0-9]-${{ matrix.python-version }}"
package-path: "${{ env.PACKAGE_PATH }}"
python-version: ${{ matrix.python-version }}
- name: Install build requirements
run: |
pip install -U pip
pip install build
- name: Build project
run: |
python -m build
- name: Install on Windows
if: matrix.os == 'windows-latest'
run: |
New-Item -Path $PWD -Name "wheelhouse" -ItemType "Directory"
cd dist
$files = Get-ChildItem -Path $PWD | Where-Object { $_.Extension -eq '.whl' }
foreach ($file in $files) {
Copy-Item -Path "$file" -Destination "..\wheelhouse"
pip install $file
}
- name: Install on Ubuntu
if: matrix.os == 'ubuntu-latest'
run: |
mkdir wheelhouse
cp dist/*.whl wheelhouse
pip install dist/*.whl
- name: "Retrieve Mechanical version"
shell: python
run: |
import os
from ${{ env.PACKAGE_NAMESPACE }} import __version__
# Get the GITHUB_ENV variable
github_env = os.getenv('GITHUB_ENV')
with open(github_env, "a") as f:
f.write(f"MECHANICAL_VERSION={__version__}")
print(f"Mechanical version is {__version__}")
- name: "Compress the wheelhouse"
uses: vimtor/[email protected]
with:
files: wheelhouse
dest: ${{ env.PACKAGE_NAME }}-v${{ env.MECHANICAL_VERSION }}-wheelhouse-${{ matrix.os }}-${{ matrix.python-version }}.zip
- name: "Upload the compressed wheelhouse"
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}-v${{ env.MECHANICAL_VERSION }}-wheelhouse-${{ matrix.os }}-${{ matrix.python-version }}
path: ${{ env.PACKAGE_NAME }}-v${{ env.MECHANICAL_VERSION }}-wheelhouse-${{ matrix.os }}-${{ matrix.python-version }}.zip
retention-days: 7
doc-build:
name: Make html and markdown documentation
needs: [smoke-tests]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
steps:
- name: "Install Git and clone project"
uses: actions/checkout@v4
- name: "Download stubs"
uses: ./.github/workflows/setup-stubs/
with:
folder-pattern: "v[0-9][0-9][0-9]-${{ matrix.python-version }}"
package-path: "${{ env.PACKAGE_PATH }}"
python-version: ${{ matrix.python-version }}
- name: "Install project & doc dependencies"
run: |
python -m pip install -e .[doc]
- name: "Generate HTML documentation"
run: |
make -C doc html
make -C doc pdf
- name: "Upload original Sphinx HTML documentation"
uses: actions/upload-artifact@v4
if: matrix.python-version == env.MAIN_PYTHON_VERSION
with:
name: original-documentation-html
path: doc/_build/html
retention-days: 7
- name: "Generate Markdown documentation"
run: |
make -C doc markdown
- name: "Upload original markdown documentation"
uses: actions/upload-artifact@v4
if: matrix.python-version == env.MAIN_PYTHON_VERSION
with:
name: original-documentation-md
path: doc/_build/markdown
retention-days: 7
- name: "Replace Windows apostrophes with single quotes"
run: |
python scripts/replace-windows-apostrophes.py
- name: "Make all hrefs local in Markdown"
run: |
python scripts/fix-href-md.py
- name: "Make all hrefs local in HTML"
run: |
python scripts/fix-href-html.py
- name: "Clean ID in first row"
run: |
python scripts/01-clean-id.py
- name: "Clean empty rows"
run: |
python scripts/02-clean-empty-row.py
- name: "Create table of contents"
run: |
python scripts/03-create-toc-from-html-mechanical.py
- name: "Fix paths in toc.yml"
shell: bash
run: |
# Remove doc/_build/html from paths in toc.yml file
sed -i -e 's;doc/_build/html/;;g' output/toc.yml
- name: "Add header to tables"
run: |
python scripts/04-add-header-to-tables.py
- name: "Remove links in heading"
run: |
python scripts/05-remove-link-in-heading.py
- name: "Upload toc.yml"
if: matrix.python-version == env.MAIN_PYTHON_VERSION
uses: actions/upload-artifact@v4
with:
name: toc-file
path: output/
- name: "Upload Markdown documentation"
uses: actions/upload-artifact@v4
if: matrix.python-version == env.MAIN_PYTHON_VERSION
with:
name: documentation-md
path: doc/_build/markdown
retention-days: 7
- name: "Upload HTML documentation"
uses: actions/upload-artifact@v4
if: matrix.python-version == env.MAIN_PYTHON_VERSION
with:
name: documentation-html
path: doc/_build/html
retention-days: 7
- name: Upload PDF Documentation
if: matrix.python-version == env.MAIN_PYTHON_VERSION
uses: actions/upload-artifact@v4
with:
name: documentation-pdf
path: doc/_build/latex/doc.pdf
retention-days: 7
build-library:
name: Build library
runs-on: ubuntu-latest
needs: [doc-build]
steps:
- name: "Install Git and clone project"
uses: actions/checkout@v4
- name: "Set up Python"
uses: ansys/actions/_setup-python@v8
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
use-cache: false
- name: "Download stubs"
uses: ./.github/workflows/setup-stubs/
with:
folder-pattern: "v[0-9][0-9][0-9]-${{ env.MAIN_PYTHON_VERSION }}"
package-path: "${{ env.PACKAGE_PATH }}"
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: "Install build and twine"
shell: bash
run: |
python -m pip install build twine
- name: "Build distribution artifacts"
shell: bash
run: |
python -m build
- name: "Check build health"
shell: bash
run: |
python -m twine check dist/*
- name: "Upload distribution artifacts to GitHub artifacts"
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}-artifacts
path: dist/
retention-days: 7
release:
runs-on: ubuntu-latest
needs: [build-library, update-changelog]
environment: release
permissions:
id-token: write
contents: write
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
steps:
- name: "Release to the public PyPI repository"
uses: ansys/actions/release-pypi-public@v8
with:
library-name: ${{ env.PACKAGE_NAME }}
use-trusted-publisher: true
- name: "Release to GitHub"
uses: ansys/actions/release-github@v8
with:
library-name: ${{ env.PACKAGE_NAME }}
doc-deploy-dev:
name: "Deploy development documentation"
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [doc-build]
steps:
- name: "Deploy development documentation"
uses: ansys/actions/doc-deploy-dev@v8
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
doc-artifact-name: 'documentation-html'
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}
doc-deploy-stable:
name: "Deploy stable documentation"
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
runs-on: ubuntu-latest
needs: release
steps:
- name: "Deploy stable documentation"
uses: ansys/actions/doc-deploy-stable@v8
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
doc-artifact-name: 'documentation-html'
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}