Skip to content

Commit 05c03ba

Browse files
committed
feat: update conftest and test_docker to support windows containers
1 parent 8a03320 commit 05c03ba

File tree

3 files changed

+52
-15
lines changed

3 files changed

+52
-15
lines changed

.github/workflows/test_docker.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,22 @@ env:
3030
MODULE: core
3131
ANSYS_DPF_ACCEPT_LA: Y
3232
ANSYSLMD_LICENSE_FILE: 1055@${{secrets.LICENSE_SERVER}}
33-
DPF_DOCKER: ghcr.io/ansys-dpf/dpf-standalone:linux-25.1
3433

3534
jobs:
3635
docker_tests:
3736
name: "Build and Test On Docker"
38-
runs-on: ${{ matrix.os }}
37+
runs-on: ${{ matrix.platform.os }}
3938
strategy:
4039
fail-fast: false
4140
matrix:
4241
python-version: ["3.10"]
43-
os: ["ubuntu-latest"]
42+
platform:
43+
- os: "ubuntu-latest"
44+
image-name: ghcr.io/ansys-dpf/dpf-standalone:linux-26.1
45+
- os: "windows-latest"
46+
image-name: ghcr.io/ansys-dpf/dpf-standalone:windows-26.1
47+
env:
48+
DPF_DOCKER: ${{ matrix.platform.os }}
4449

4550
steps:
4651
- uses: actions/checkout@v4
@@ -59,7 +64,7 @@ jobs:
5964
- name: "Build the wheel"
6065
shell: bash
6166
run: |
62-
if [ ${{ matrix.os }} == "ubuntu-latest" ]; then
67+
if [ ${{ matrix.platform.os }} == "ubuntu-latest" ]; then
6368
export platform="manylinux_2_17"
6469
else
6570
export platform="win"
@@ -240,21 +245,21 @@ jobs:
240245
- name: "Upload Test Results"
241246
uses: actions/upload-artifact@v4
242247
with:
243-
name: ${{ env.PACKAGE_NAME }}_${{ matrix.python-version }}_${{ matrix.os }}_pytest_${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }}_docker
248+
name: ${{ env.PACKAGE_NAME }}_${{ matrix.python-version }}_${{ matrix.platform.os }}_pytest_${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }}_docker
244249
path: tests/junit/test-results.xml
245250
timeout-minutes: 5
246251

247252
- name: "Upload coverage to Codecov"
248253
uses: codecov/codecov-action@v4
249254
with:
250255
token: ${{ secrets.CODECOV_TOKEN }} # required
251-
name: ${{ env.PACKAGE_NAME }}_${{ matrix.python-version }}_${{ matrix.os }}_pytest_${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }}_docker.xml
252-
flags: docker,${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }},${{ matrix.os }},${{ matrix.python-version }}
256+
name: ${{ env.PACKAGE_NAME }}_${{ matrix.python-version }}_${{ matrix.platform.os }}_pytest_${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }}_docker.xml
257+
flags: docker,${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }},${{ matrix.platform.os }},${{ matrix.python-version }}
253258

254259
- name: "Upload test analytics results to Codecov"
255260
if: ${{ !cancelled() }}
256261
uses: codecov/test-results-action@v1
257262
with:
258263
token: ${{ secrets.CODECOV_TOKEN }}
259-
name: test_results_${{ env.PACKAGE_NAME }}_${{ matrix.python-version }}_${{ matrix.os }}_${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }}${{ inputs.test_any == 'true' && '_any' || '' }}
260-
flags: ${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }},${{ matrix.os }},${{ matrix.python-version }}${{ inputs.test_any == 'true' && ',any' || '' }}
264+
name: test_results_${{ env.PACKAGE_NAME }}_${{ matrix.python-version }}_${{ matrix.platform.os }}_${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }}${{ inputs.test_any == 'true' && '_any' || '' }}
265+
flags: ${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }},${{ matrix.platform.os }},${{ matrix.python-version }}${{ inputs.test_any == 'true' && ',any' || '' }}

tests/conftest.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
"""
2828

2929
import functools
30+
import json
3031
import os
3132
from pathlib import Path
33+
import subprocess
3234
import warnings
3335

3436
import psutil
@@ -67,9 +69,23 @@ def _get_test_files_directory():
6769
ssl._create_default_https_context = ssl._create_unverified_context
6870

6971
if running_docker:
70-
ansys.dpf.core.server_types.RUNNING_DOCKER.mounted_volumes[_get_test_files_directory()] = (
71-
"/tmp/test_files"
72-
)
72+
docker_name = ansys.dpf.core.server_types.RUNNING_DOCKER.docker_name
73+
args = ["docker", "inspect", "-f", "json", docker_name]
74+
inspect_docker_image = subprocess.run(args, capture_output=True)
75+
if inspect_docker_image.stderr:
76+
raise Exception(
77+
f"Specified docker image not found. Verify that the image name '{docker_name}' is valid and the image file is available locally."
78+
)
79+
output = json.loads(inspect_docker_image.stdout)
80+
image_os = output[0]["Os"]
81+
if image_os == "linux":
82+
ansys.dpf.core.server_types.RUNNING_DOCKER.mounted_volumes[_get_test_files_directory()] = (
83+
"/tmp/test_files"
84+
)
85+
else: # image is windows
86+
ansys.dpf.core.server_types.RUNNING_DOCKER.mounted_volumes[_get_test_files_directory()] = (
87+
"C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\test_files"
88+
)
7389

7490

7591
@pytest.hookimpl()

tests/entry/conftest.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@
2929
"""
3030

3131
import functools
32+
import json
3233
import os
3334
from pathlib import Path
35+
import subprocess
3436

3537
import pytest
3638

@@ -67,9 +69,23 @@ def _get_test_files_directory():
6769
ssl._create_default_https_context = ssl._create_unverified_context
6870

6971
if running_docker:
70-
ansys.dpf.core.server_types.RUNNING_DOCKER.mounted_volumes[_get_test_files_directory()] = (
71-
"/tmp/test_files"
72-
)
72+
docker_name = ansys.dpf.core.server_types.RUNNING_DOCKER.docker_name
73+
args = ["docker", "inspect", "-f", "json", docker_name]
74+
inspect_docker_image = subprocess.run(args, capture_output=True)
75+
if inspect_docker_image.stderr:
76+
raise Exception(
77+
f"Specified docker image not found. Verify that the image name '{docker_name}' is valid and the image file is available locally."
78+
)
79+
output = json.loads(inspect_docker_image.stdout)
80+
image_os = output[0]["Os"]
81+
if image_os == "linux":
82+
ansys.dpf.core.server_types.RUNNING_DOCKER.mounted_volumes[_get_test_files_directory()] = (
83+
"/tmp/test_files"
84+
)
85+
else: # image is windows
86+
ansys.dpf.core.server_types.RUNNING_DOCKER.mounted_volumes[_get_test_files_directory()] = (
87+
"C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\test_files"
88+
)
7389

7490
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_1 = meets_version(
7591
get_server_version(core._global_server()), "8.1"

0 commit comments

Comments
 (0)