-
Notifications
You must be signed in to change notification settings - Fork 149
319 lines (270 loc) · 9.76 KB
/
Copy pathtest-local.yml
File metadata and controls
319 lines (270 loc) · 9.76 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
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
# This action tests PyMAPDL with MAPDL running locally.
# It does support running with minimal requirements and with console interface.
name: "Local testing"
on:
workflow_call:
inputs:
mapdl-version:
description: |
MAPDL version to test.
required: true
type: string
latest-version:
description: |
Latest version of MAPDL.
required: true
type: string
pytest-arguments:
description: |
Arguments to pass to pytest, additionally to the ones in the environment variable PYTEST_ARGUMENTS.
required: false
type: string
default: ""
testing-minimal:
description: |
If true, the minimal requirements will be installed.
required: false
type: boolean
default: false
test_dpf:
description: |
If true, the DPF tests will be run.
required: false
type: boolean
default: true
on-console:
description: |
If true, the tests will be run on console.
required: false
type: boolean
default: false
file-name:
description: |
Name of the file to save the logs.
required: true
type: string
tags:
description: |
Tags to add to the coverage report.
required: false
type: string
codecov-report:
description: |
Whether to upload the coverage report to Codecov or not. If `true`, then the
appropriate token is needed.
required: false
default: true
type: boolean
package-registry:
description: |
Package registry for the container.
required: false
type: string
default: ghcr.io/ansys/mapdl
runner:
description: |
Runner to use.
required: false
type: string
default: ubuntu-22.04
python-version:
description: |
Python version to use.
required: false
type: string
default: "3.12"
secrets:
license-server:
description: |
License server for ANSYS MAPDL
required: true
codecov-token:
description: |
Token for Codecov.
required: true
token:
description: |
Token for GitHub. Used also for login into ghcr.io.
required: true
username:
description: |
GitHub username for login into ghcr.io.
required: true
jobs:
test-local:
runs-on: ${{ inputs.runner }}
env:
ON_CI: True
ON_LOCAL: true
ON_UBUNTU: true
HAS_DPF: ${{ inputs.test_dpf }}
PYMAPDL_DEBUG_TESTING: True
TESTING_MINIMAL: ${{ inputs.testing-minimal }}
P_SCHEMA: "/ansys_inc/v241/ansys/ac4/schema"
PYTEST_TIMEOUT: 120 # seconds. Limit the duration for each unit test
PYTEST_ARGUMENTS: '-vvv -ra --color=yes --durations=30 --random-order --random-order-bucket=class --maxfail=10 --reruns 3 --reruns-delay 4 --cov=ansys.mapdl.core --cov-report=html --timeout=180 --profile-svg --profile --report-log-exclude-logs-on-passed-tests --strict-markers --random-order-seed=307591'
OMPI_ALLOW_RUN_AS_ROOT: 1
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
DATAPROCESSING_DEBUG: /home/mapdl/dpf_logs
container:
image: "${{ inputs.package-registry }}:${{ inputs.mapdl-version }}"
options: -u=0:0 --oom-kill-disable --memory=6656MB --memory-swap=16896MB --shm-size=1gb --entrypoint /bin/bash
credentials:
username: ${{ secrets.username }}
password: ${{ secrets.token }}
steps:
- name: "Freeing some space and show space consumption (pre-test)"
shell: bash
run: |
echo "Deleting CodeQL..."
rm -rf /__t/CodeQL || echo "CodeQL not found"
echo "Disk space:"
df -h
- name: "Install Git and checkout project"
uses: actions/checkout@v4.2.2
with:
repository: ansys/pymapdl
- name: "Get if running student version"
id: student_check
shell: bash
run: |
if [[ "${{ inputs.mapdl-version }}" == *"student"* ]];
then export ON_STUDENT=true; export TAG_STUDENT="student";
else export ON_STUDENT=false; export TAG_STUDENT="non-student";
fi
if [[ "${{ inputs.mapdl-version }}" == *"cicd"* ]]; then
echo "CICD MAPDL version detected, testing DPF backend for results module.";
echo "TEST_DPF_BACKEND=true" >> $GITHUB_ENV;
fi
echo "ON_STUDENT: $ON_STUDENT"
echo "TAG_STUDENT: $TAG_STUDENT"
echo "ON_STUDENT=$(echo $ON_STUDENT)" >> $GITHUB_OUTPUT
echo "TAG_STUDENT=$(echo $TAG_STUDENT)" >> $GITHUB_OUTPUT
- name: "Install gcc"
shell: bash
if: ${{ contains(inputs.mapdl-version, 'cicd') }}
run: |
apt-get update && apt-get -y install gcc mono-mcs g++
- name: "Installing minimal OS packages"
shell: bash
if: inputs.testing-minimal == true
run: |
apt-get update && apt install -y libgomp1 graphviz curl && apt-get clean
- name: "Installing OS packages"
shell: bash
if: inputs.testing-minimal == false
run: |
apt-get update && apt install -y libgl1-mesa-glx xvfb libgomp1 graphviz curl && apt-get clean
- name: "Setup Python"
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: "Checking Python"
shell: bash
run: |
python --version
python -m pip install --upgrade pip
- name: "Install ansys-mapdl-core"
if: inputs.testing-minimal == false
shell: bash
run: |
python -m pip install build
python -m build
python -m pip install dist/*.whl
xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())"
- name: "Install ansys-mapdl-core with minimal requirements"
shell: bash
if: inputs.testing-minimal == true
run: |
python -m pip install . --no-deps
python -m pip install -r minimum_requirements.txt
python -c "from ansys.mapdl import core as pymapdl; print('Import successfull')"
- name: "Unit testing requirements installation"
if: inputs.testing-minimal == false
shell: bash
run: |
python -m pip install .[tests]
- name: "Unit testing requirements installation"
if: inputs.testing-minimal == true
shell: bash
run: |
python -m pip install -r .ci/requirements_testing_minimal.txt
- name: "Unit testing"
env:
ON_STUDENT: ${{ steps.student_check.outputs.ON_STUDENT }}
ON_MINIMAL: ${{ inputs.testing-minimal }}
ON_CONSOLE: ${{ inputs.on-console }}
ANSYSLMD_LICENSE_FILE: "1055@${{ secrets.license-server }}"
file_name: ${{ inputs.file-name }}
shell: bash
run: |
echo "ON_UBUNTU: $ON_UBUNTU"
echo "ON_STUDENT: $ON_STUDENT"
# Because there is no 'ansys-tools-path' we need to input the
# executable path with the env var: PYMAPDL_MAPDL_EXEC.
if [[ "${{ inputs.mapdl-version }}" == *"latest-ubuntu"* ]] ; then
version=${{ inputs.latest-version }}
else
version=$(echo "${{ inputs.mapdl-version }}" | head -c 5 | tail -c 4 | tr -d '.')
fi;
echo "Version: $version"
# If minimal is true, we need to set the executable path.
if [[ "${{ inputs.testing-minimal }}" == "true" ]]; then
echo "PYMAPDL_MAPDL_EXEC: $PYMAPDL_MAPDL_EXEC"
export PYMAPDL_MAPDL_EXEC=/ansys_inc/v"$version"/ansys/bin/ansys"$version"
export cmd="pytest"
else
export cmd="xvfb-run pytest"
fi;
unset PYMAPDL_START_INSTANCE
unset PYMAPDL_PORT
$cmd ${{ inputs.pytest-arguments }} \
${{ env.PYTEST_ARGUMENTS }} \
--report-log=$file_name.jsonl \
--cov-report=xml:$file_name.xml
- name: "Upload pytest reports to GitHub"
if: always()
uses: actions/upload-artifact@v4.6.2
with:
name: "reports-${{ inputs.file-name }}"
path: ./${{ inputs.file-name }}.jsonl
- name: "Collect logs on failure"
if: always()
env:
LOG_NAMES: logs-${{ inputs.file-name }}
shell: bash
run: |
.ci/collect_mapdl_logs_locals.sh
- name: "Upload logs to GitHub"
if: always()
uses: actions/upload-artifact@v4.6.2
with:
name: logs-${{ inputs.file-name }}.tgz
path: ./logs-${{ inputs.file-name }}.tgz
- name: "Display files structure"
if: always()
env:
LOG_NAMES: logs-${{ inputs.file-name }}
shell: bash
run: |
.ci/display_logs_locals.sh
- uses: codecov/codecov-action@v5
name: "Upload coverage to Codecov"
if: inputs.codecov-report == true
with:
token: ${{ secrets.codecov-token }} # required
root_dir: ${{ github.workspace }}
name: ${{ inputs.file-name }}.xml
flags: local-ubuntu-${{ inputs.mapdl-version }}-dmp-${{ steps.student_check.outputs.TAG_STUDENT }}-${{ inputs.tags }}
- name: "Upload coverage artifacts"
uses: actions/upload-artifact@v4
if: inputs.codecov-report == true
with:
name: ${{ inputs.file-name }}.xml
path: ./${{ inputs.file-name }}.xml
- name: "Show space consumption (post-test)"
if: always()
shell: bash
run: |
echo "Disk space:"
df -h