-
Notifications
You must be signed in to change notification settings - Fork 2
243 lines (214 loc) · 9.3 KB
/
geometry-mechanical-dpf.yml
File metadata and controls
243 lines (214 loc) · 9.3 KB
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
name: Geometry Mechanical DPF Workflow
on:
workflow_dispatch:
inputs:
doc-build:
required: false
default: false
type: boolean
description: 'Whether to build the documentation'
workflow_call:
inputs:
doc-build:
required: false
default: false
type: boolean
description: 'Whether to build the documentation'
push:
branches:
- main
pull_request:
paths:
- 'geometry-mechanical-dpf/**'
env:
MAIN_PYTHON_VERSION: '3.12'
GEOMETRY_DOCKER_IMAGE: 'ghcr.io/ansys/geometry'
MECHANICAL_DOCKER_IMAGE: 'ghcr.io/ansys/mechanical'
ANSRV_GEO_PORT: 700
ANSRV_GEO_LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER )}}
PYANSYS_WORKFLOWS_CI: true
ANSYS_RELEASE_FOR_DOCS: 25.1
jobs:
is-only-docs-required:
uses: ./.github/workflows/check-docs-required.yml
with:
doc-build: ${{ inputs.doc-build || false }}
geometry:
name: Geometry
runs-on: [self-hosted, Windows, pyansys-workflows]
needs: is-only-docs-required
strategy:
fail-fast: false
matrix:
ansys-release: ${{ needs.is-only-docs-required.outputs.only-docs == 'true' && fromJSON('[25.1]') || fromJSON('[24.1, 24.2, 25.1]') }}
steps:
- name: Checkout code
uses: actions/checkout@v6.0.2
with:
sparse-checkout: |
geometry-mechanical-dpf
doc
- name: Set up Python ${{ env.MAIN_PYTHON_VERSION }}
uses: actions/setup-python@v6
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: Setup headless display
uses: pyvista/setup-headless-display-action@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m venv .venv
.venv/Scripts/activate
pip install -r geometry-mechanical-dpf/requirements_${{ matrix.ansys-release }}.txt
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download (if needed) and run Geometry service container
run: |
# If we are on 25.1 or above - the tag name is different - remember we are on powershell
if (${{ matrix.ansys-release }} -ge 25.2) {
$env:ANSYS_GEOMETRY_RELEASE = "${{ env.GEOMETRY_DOCKER_IMAGE }}:core-windows-${{ matrix.ansys-release }}"
} else {
$env:ANSYS_GEOMETRY_RELEASE = "${{ env.GEOMETRY_DOCKER_IMAGE }}:windows-${{ matrix.ansys-release }}"
}
Write-Host "Running Geometry service container: $env:ANSYS_GEOMETRY_RELEASE"
# Pull the container image
docker pull $env:ANSYS_GEOMETRY_RELEASE
# Define the ANSYS_GEOMETRY_RELEASE environment variable to be used in the next stages
echo "ANSYS_GEOMETRY_RELEASE=$env:ANSYS_GEOMETRY_RELEASE" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Run the PyAnsys Geometry script
run: |
.venv/Scripts/activate
python geometry-mechanical-dpf/wf_gmd_01_geometry.py
- name: Store the outputs
uses: actions/upload-artifact@v7
with:
name: geometry-mechanical-dpf-workflow-geometry-outputs-${{ matrix.ansys-release }}
path: geometry-mechanical-dpf/outputs
- name: (DOCS) Build the documentation (only on ${{ env.ANSYS_RELEASE_FOR_DOCS }})
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
env:
BUILD_DOCS_SCRIPT: 'geometry-mechanical-dpf/wf_gmd_01_geometry.py'
run: |
.venv/Scripts/activate
cd doc
pip install -r requirements.txt
./make.bat html
- name: (DOCS) Upload docs artifacts
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
uses: actions/upload-artifact@v7
with:
name: geometry-mechanical-dpf-docs-stage-geometry
path: |
doc/_build/
doc/source/examples/geometry-mechanical-dpf/
- name: Stop any remaining containers
if: always()
run: |
$dockerContainers = docker ps -a -q
if (-not [string]::IsNullOrEmpty($dockerContainers)) {
docker rm -f $dockerContainers
}
mech-dpf:
name: Mechanical - Dpf
runs-on: public-ubuntu-latest-8-cores
needs: [geometry, is-only-docs-required]
strategy:
fail-fast: false
matrix:
ansys-release: ${{ needs.is-only-docs-required.outputs.only-docs == 'true' && fromJSON('[25.1]') || fromJSON('[24.1, 24.2, 25.1]') }}
container:
image: 'ghcr.io/ansys/mechanical:${{ matrix.ansys-release }}.0'
options: --entrypoint /bin/bash
steps:
- name: Checkout code
uses: actions/checkout@v6.0.2
with:
sparse-checkout: |
geometry-mechanical-dpf
doc
- name: "Set up Python and activate virtual environment"
shell: bash
run: |
apt update
apt install lsb-release xvfb git curl make -y
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
uv python install python${{ env.MAIN_PYTHON_VERSION }}
uv venv /.venv
- name: Install dependencies
run: |
. /.venv/bin/activate
uv pip install --upgrade pip
uv pip install -r geometry-mechanical-dpf/requirements_${{ matrix.ansys-release }}.txt
- name: Check out the geometry outputs
uses: actions/download-artifact@v8
with:
name: geometry-mechanical-dpf-workflow-geometry-outputs-${{ matrix.ansys-release }}
path: geometry-mechanical-dpf/outputs
- name: Run the PyMechanical script
env:
NUM_CORES: 1
ANSYS_WORKBENCH_LOGGING_CONSOLE: 0
ANSYS_WORKBENCH_LOGGING: 0
ANSYS_WORKBENCH_LOGGING_FILTER_LEVEL: 2
run: |
. /.venv/bin/activate
xvfb-run mechanical-env python geometry-mechanical-dpf/wf_gmd_02_mechanical.py > pymechlogs${{ matrix.ansys-release }}.txt 2>&1 || true
cat pymechlogs${{ matrix.ansys-release }}.txt
- name: Run the PyDPF script
run: |
. /.venv/bin/activate
xvfb-run python geometry-mechanical-dpf/wf_gmd_03_dpf.py > pydpflogs${{ matrix.ansys-release }}.txt 2>&1 || true
cat pydpflogs${{ matrix.ansys-release }}.txt
- name: Store the outputs
uses: actions/upload-artifact@v7
with:
name: geometry-mechanical-dpf-workflow-mechanical-dpf-outputs-${{ matrix.ansys-release }}
path: geometry-mechanical-dpf/outputs
- name: (DOCS) Download the docs artifacts
uses: actions/download-artifact@v8
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
with:
name: geometry-mechanical-dpf-docs-stage-geometry
path: doc
- name: (DOCS) Build the documentation for the Mechanical script (only on ${{ env.ANSYS_RELEASE_FOR_DOCS }})
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
env:
NUM_CORES: 1
ANSYS_WORKBENCH_LOGGING_CONSOLE: 0
ANSYS_WORKBENCH_LOGGING: 0
ANSYS_WORKBENCH_LOGGING_FILTER_LEVEL: 2
BUILD_DOCS_SCRIPT: 'geometry-mechanical-dpf/wf_gmd_02_mechanical.py'
run: |
. /.venv/bin/activate
find . -type f -exec sed -i 's|C:\\Users\\ansys\\actions-runner\\_work\\pyansys-workflows\\pyansys-workflows\\doc\\source\\examples\\geometry-mechanical-dpf\\images\\|./images/|g' {} +
uv pip install -r ./doc/requirements.txt
xvfb-run mechanical-env make -C doc html > pymech-docs-logs${{ matrix.ansys-release }}.txt 2>&1 || true
cat pymech-docs-logs${{ matrix.ansys-release }}.txt
- name: (DOCS) Build the documentation for the DPF script (only on ${{ env.ANSYS_RELEASE_FOR_DOCS }})
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
env:
BUILD_DOCS_SCRIPT: 'geometry-mechanical-dpf/wf_gmd_03_dpf.py'
run: |
. /.venv/bin/activate
uv pip install -r ./doc/requirements.txt
xvfb-run make -C doc html > dpf-docs-logs${{ matrix.ansys-release }}.txt 2>&1 || true
cat dpf-docs-logs${{ matrix.ansys-release }}.txt
- name: (DOCS) Adapt the documentation paths
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
run: |
find . -type f -exec sed -i 's|/__w/pyansys-workflows/pyansys-workflows/doc/source/examples/geometry-mechanical-dpf/images|./images/|g' {} +
- name: (DOCS) Upload docs artifacts
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
uses: actions/upload-artifact@v7
with:
name: geometry-mechanical-dpf-docs
path: |
doc/_build/
doc/source/examples/geometry-mechanical-dpf/
overwrite: true