Skip to content

Commit 2cce41b

Browse files
CI: Use flaky marker to avoid rerunning all tests (#6789)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent ef3ef80 commit 2cce41b

File tree

5 files changed

+104
-6
lines changed

5 files changed

+104
-6
lines changed

.github/workflows/ci_cd.yml

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ jobs:
843843
command: |
844844
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT252 }}/common/mono/Linux64/lib64:$LD_LIBRARY_PATH
845845
source .venv/bin/activate
846-
xvfb-run pytest ${{ env.PYTEST_ARGUMENTS }} --timeout=600 -m extensions
846+
xvfb-run pytest ${{ env.PYTEST_ARGUMENTS }} --timeout=600 -m "extensions and not flaky_linux"
847847
848848
- uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
849849
with:
@@ -1008,6 +1008,92 @@ jobs:
10081008
path: junit/test-results.xml
10091009
if: ${{ always() }}
10101010

1011+
# # =================================================================================================
1012+
# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1013+
# # =================================================================================================
1014+
1015+
system-tests-flaky-linux:
1016+
name: Test flaky (linux)
1017+
if: github.event.pull_request.draft == false
1018+
needs: [integration-tests]
1019+
runs-on: [ self-hosted, Linux, pyaedt ]
1020+
env:
1021+
ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM'
1022+
ANS_NODEPCHECK: '1'
1023+
steps:
1024+
- name: Install Git and checkout project
1025+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1026+
with:
1027+
persist-credentials: false
1028+
1029+
- name: Setup Python
1030+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
1031+
with:
1032+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
1033+
1034+
- name: Create virtual environment
1035+
env:
1036+
ANSYSEM: ${{ env.ANSYSEM_ROOT252 }}
1037+
run: |
1038+
export LD_LIBRARY_PATH=${ANSYSEM}/common/mono/Linux64/lib64:$LD_LIBRARY_PATH
1039+
python -m venv .venv
1040+
source .venv/bin/activate
1041+
python -m pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org pip -U
1042+
python -m pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org wheel setuptools -U
1043+
python -c "import sys; print(sys.executable)"
1044+
1045+
- name: Install pyaedt and tests dependencies
1046+
env:
1047+
ANSYSEM: ${{ env.ANSYSEM_ROOT252 }}
1048+
run: |
1049+
export LD_LIBRARY_PATH=${ANSYSEM}/common/mono/Linux64/lib64:$LD_LIBRARY_PATH
1050+
source .venv/bin/activate
1051+
pip install .[tests]
1052+
1053+
- name: Install CI dependencies (e.g. vtk-osmesa)
1054+
run: |
1055+
source .venv/bin/activate
1056+
# Uninstall conflicting dependencies
1057+
pip uninstall --yes vtk
1058+
pip install --index-url https://wheels.vtk.org vtk-osmesa==9.3.1
1059+
1060+
- name: "Install X Virtual Frame Buffer"
1061+
run: |
1062+
sudo apt-get update
1063+
sudo apt-get install -y xvfb
1064+
1065+
- name: Remove Ansys processes (if any)
1066+
shell: bash
1067+
run: |
1068+
for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do
1069+
echo "Killing PID $pid"
1070+
kill -9 "$pid"
1071+
done
1072+
1073+
- name: Run tests marked with 'flaky'
1074+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
1075+
with:
1076+
max_attempts: 2
1077+
retry_on: error
1078+
timeout_minutes: 120
1079+
command: |
1080+
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT252 }}/common/mono/Linux64/lib64:$LD_LIBRARY_PATH
1081+
source .venv/bin/activate
1082+
xvfb-run pytest ${{ env.PYTEST_ARGUMENTS }} --timeout=600 -m flaky_linux
1083+
1084+
- uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
1085+
with:
1086+
name: codecov-system-flaky-tests-linux
1087+
files: ./coverage.xml
1088+
flags: linux_system_flaky
1089+
1090+
- name: Upload pytest test results
1091+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
1092+
with:
1093+
name: pytest-flaky-linux
1094+
path: junit/test-results.xml
1095+
if: ${{ always() }}
1096+
10111097
package:
10121098
name: Package library
10131099
needs: [system-tests-general-windows,
@@ -1020,6 +1106,7 @@ jobs:
10201106
system-tests-extensions-linux,
10211107
system-tests-filter-windows,
10221108
system-tests-emit-windows,
1109+
system-tests-flaky-linux,
10231110
doc-build]
10241111
runs-on: ubuntu-latest
10251112
permissions:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use flaky marker to avoid rerunning all tests

pyproject.toml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,17 @@ omit = ["src/ansys/aedt/core/rpc/*.py"]
260260

261261
[tool.pytest.ini_options]
262262
markers = [
263-
"unit",
264-
"integration",
265-
"system",
266-
"solvers",
267-
"general",
263+
"unit: mark a test as a unit test.",
264+
"integration: mark a test as an integration test.",
265+
"system: mark a test as a system test.",
266+
"solvers: mark a test as related to solvers.",
267+
"general: mark a test as related to general features.",
268+
"visualization: mark a test as related to visualization features.",
269+
"extensions: mark a test as related to extensions.",
270+
"filter_solutions: mark a test as related to filter solutions.",
271+
"emit: mark a test as related to EMIT features.",
272+
"flaky_linux: mark a test as flaky on Linux systems.",
273+
"flaky_windows: mark a test as flaky on Windows systems.",
268274
]
269275
filterwarnings = [
270276
"ignore::UserWarning:src.ansys.aedt.core.*",

tests/system/extensions/test_configure_layout.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def test_get_active_db(extension_under_test, test_folder, add_app):
100100
app.close_project(app.project_name)
101101

102102

103+
@pytest.mark.flaky_linux
103104
@patch(
104105
"ansys.aedt.core.extensions.hfss3dlayout.configure_layout.ConfigureLayoutExtension.selected_edb",
105106
new_callable=PropertyMock,

tests/system/extensions/test_export_layout.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import json
2626
from pathlib import Path
2727

28+
import pytest
29+
2830
from ansys.aedt.core.edb import Edb
2931
from ansys.aedt.core.extensions.hfss3dlayout.export_layout import ExportLayoutExtensionData
3032
from ansys.aedt.core.extensions.hfss3dlayout.export_layout import main
@@ -43,6 +45,7 @@ def cleanup_files(*files):
4345
export_file.unlink()
4446

4547

48+
@pytest.mark.flaky_linux
4649
def test_export_layout_all_options(add_app, local_scratch):
4750
"""Test successful execution of export layout with all options enabled."""
4851
data = ExportLayoutExtensionData(

0 commit comments

Comments
 (0)