Skip to content

Commit 9a24218

Browse files
jacobrkerstetterpre-commit-ci[bot]pyansys-ci-botRobPasMue
authored
ci: adding testing for v1 protos (#2389)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Roberto Pastor Muela <[email protected]>
1 parent 9bf1d05 commit 9a24218

File tree

4 files changed

+179
-2
lines changed

4 files changed

+179
-2
lines changed

.github/workflows/v1_testing.yml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
name: v1 Protos Testing
2+
on:
3+
workflow_dispatch:
4+
5+
env:
6+
MAIN_PYTHON_VERSION: '3.13'
7+
ANSRV_GEO_IMAGE: 'ghcr.io/ansys/geometry'
8+
ANSRV_GEO_PORT: 700
9+
ANSRV_GEO_LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
10+
GEO_CONT_NAME: ans_geo
11+
RESET_IMAGE_CACHE: 0
12+
13+
permissions:
14+
contents: read
15+
packages: read
16+
17+
jobs:
18+
testing-windows-v1:
19+
name: Testing and coverage (Windows - v1 Protos)
20+
runs-on: windows-latest
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
python-version: ['3.10', '3.13']
25+
26+
steps:
27+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
28+
with:
29+
persist-credentials: false
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
36+
- name: Set up headless display
37+
uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2
38+
39+
- name: Install packages for testing
40+
run: |
41+
python -m pip install --upgrade pip
42+
pip install --upgrade build wheel
43+
pip install -e . --group tests
44+
45+
- name: Login to GitHub Container Registry
46+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
47+
with:
48+
registry: ghcr.io
49+
username: ${{ github.actor }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Download Geometry service container (if needed)
53+
env:
54+
FULL_IMAGE_NAME: "${{ env.ANSRV_GEO_IMAGE }}:core-windows-latest"
55+
run: |
56+
Write-Host "Pulling Docker image: $env:FULL_IMAGE_NAME"
57+
docker pull $env:FULL_IMAGE_NAME
58+
59+
- name: Start Geometry service and verify start
60+
env:
61+
FULL_IMAGE_NAME: "${{ env.ANSRV_GEO_IMAGE }}:core-windows-latest"
62+
PORT_MAPPING: "${{ env.ANSRV_GEO_PORT }}:50051"
63+
TRANSPORT_MODE_SELECTION: ${{ secrets.TRANSPORT_MODE_SELECTION }}
64+
run: |
65+
# Write command to file launch.txt for sanitizing purposes
66+
echo "docker run --detach --name $env:GEO_CONT_NAME -e LICENSE_SERVER=$env:ANSRV_GEO_LICENSE_SERVER -p $env:PORT_MAPPING $env:FULL_IMAGE_NAME $env:TRANSPORT_MODE_SELECTION" | Out-File -FilePath launch.txt
67+
# Read the file and execute the command
68+
$command = Get-Content -Path launch.txt | Select-String -Pattern "docker run"
69+
Invoke-Expression $command.Line
70+
Start-Sleep -Seconds 10
71+
python -c "from ansys.geometry.core.connection.validate import validate; validate()"
72+
73+
- name: Restore images cache
74+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
75+
with:
76+
path: .\tests\integration\image_cache
77+
key: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }}-${{ hashFiles('pyproject.toml') }}
78+
restore-keys: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }}
79+
lookup-only: true
80+
81+
- name: Testing
82+
timeout-minutes: 20 # Sometimes hangs...
83+
run: |
84+
pytest -v --proto-version=v1
85+
86+
- name: Stop the Geometry service
87+
if: always()
88+
run: |
89+
docker stop $env:GEO_CONT_NAME
90+
docker logs $env:GEO_CONT_NAME
91+
docker rm $env:GEO_CONT_NAME
92+
93+
testing-linux-v1:
94+
name: Testing and coverage (Linux - v1 Protos)
95+
runs-on: ubuntu-latest
96+
strategy:
97+
fail-fast: false
98+
matrix:
99+
python-version: ['3.10', '3.13']
100+
101+
steps:
102+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
103+
with:
104+
persist-credentials: false
105+
106+
- name: Set up Python
107+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
108+
with:
109+
python-version: ${{ matrix.python-version }}
110+
111+
- name: Set up headless display
112+
uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2
113+
114+
- name: Install packages for testing
115+
run: |
116+
python -m pip install --upgrade pip
117+
pip install --upgrade build wheel
118+
pip install -e . --group tests
119+
120+
- name: Login to GitHub Container Registry
121+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
122+
with:
123+
registry: ghcr.io
124+
username: ${{ github.actor }}
125+
password: ${{ secrets.GITHUB_TOKEN }}
126+
127+
- name: Download Geometry service container (if needed)
128+
env:
129+
FULL_IMAGE_NAME: "${{ env.ANSRV_GEO_IMAGE }}:core-linux-latest"
130+
run: |
131+
echo "Pulling Docker image: ${FULL_IMAGE_NAME}"
132+
docker pull ${FULL_IMAGE_NAME}
133+
134+
- name: Start Geometry service and verify start
135+
env:
136+
FULL_IMAGE_NAME: "${{ env.ANSRV_GEO_IMAGE }}:core-linux-latest"
137+
TRANSPORT_MODE_SELECTION: ${{ secrets.TRANSPORT_MODE_SELECTION }}
138+
run: |
139+
docker run --detach --name ${GEO_CONT_NAME} -e LICENSE_SERVER=${ANSRV_GEO_LICENSE_SERVER} -p ${ANSRV_GEO_PORT}:50051 ${FULL_IMAGE_NAME} ${TRANSPORT_MODE_SELECTION}
140+
python -c "from ansys.geometry.core.connection.validate import validate; validate()"
141+
142+
- name: Restore images cache
143+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
144+
with:
145+
path: tests/integration/image_cache
146+
key: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }}-${{ hashFiles('pyproject.toml') }}
147+
restore-keys: pyvista-image-cache-${{ runner.os }}-v-${{ env.RESET_IMAGE_CACHE }}
148+
lookup-only: true
149+
150+
- name: Testing
151+
timeout-minutes: 20 # Sometimes hangs...
152+
run: |
153+
pytest -v --proto-version=v1
154+
155+
- name: Stop the Geometry service
156+
if: always()
157+
run: |
158+
docker stop ${GEO_CONT_NAME}
159+
docker logs ${GEO_CONT_NAME}
160+
docker rm ${GEO_CONT_NAME}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adding testing for v1 protos

tests/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ def pytest_addoption(parser):
5151
help=("Enable the tracker to update the design. Options: 'yes' or 'no'. By default, 'no'."),
5252
choices=("yes", "no"),
5353
)
54+
parser.addoption(
55+
"--proto-version",
56+
action="store",
57+
default="v0",
58+
help=("Specify the proto version to use for the tests. By default, 'v0'."),
59+
)
5460

5561
parser.addoption(
5662
"--backwards-compatibility",
@@ -159,6 +165,13 @@ def use_tracker(request):
159165
pyansys_geometry.USE_TRACKER_TO_UPDATE_DESIGN = False
160166

161167

168+
@pytest.fixture(scope="session")
169+
def proto_version(request):
170+
"""Fixture to determine proto files version to be used."""
171+
value: str = request.config.getoption("--proto-version", default="v0")
172+
return value.lower()
173+
174+
162175
@pytest.fixture
163176
def fake_record():
164177
def inner_fake_record(

tests/integration/conftest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def docker_instance(use_existing_service):
158158

159159

160160
@pytest.fixture(scope="session")
161-
def session_modeler(docker_instance):
161+
def session_modeler(docker_instance, proto_version):
162162
# Log to file - accepts str or Path objects, Path is passed for testing/coverage purposes.
163163
log_file_path = Path(__file__).absolute().parent / "logs" / "integration_tests_logs.txt"
164164

@@ -168,7 +168,10 @@ def session_modeler(docker_instance):
168168
pass
169169

170170
modeler = Modeler(
171-
docker_instance=docker_instance, logging_level=logging.DEBUG, logging_file=log_file_path
171+
docker_instance=docker_instance,
172+
logging_level=logging.DEBUG,
173+
logging_file=log_file_path,
174+
proto_version=proto_version,
172175
)
173176

174177
yield modeler

0 commit comments

Comments
 (0)