Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/build_matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# List of versions
versions=(
# if added more "latest", change "$LATEST"
'latest-ubuntu'
'v25.2-ubuntu-cicd'
'latest-ubuntu-student'
'v25.2.0'
'v25.1.0'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ jobs:
strategy:
fail-fast: false
matrix:
mapdl-version: ['latest-ubuntu', 'v25.1-ubuntu']
mapdl-version: ['v25.2-ubuntu-cicd', 'v25.1-ubuntu']
secrets:
license-server: ${{ secrets.LICENSE_SERVER }}
codecov-token: ${{ secrets.CODECOV_TOKEN }}
Expand All @@ -245,7 +245,7 @@ jobs:
strategy:
fail-fast: false
matrix:
mapdl-version: ['latest-ubuntu', 'v25.1-ubuntu']
mapdl-version: ['v25.2-ubuntu-cicd', 'v25.1-ubuntu']
secrets:
license-server: ${{ secrets.LICENSE_SERVER }}
codecov-token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
38 changes: 33 additions & 5 deletions .github/workflows/test-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,31 @@ on:
tags:
description: |
Tags to add to the coverage report.
required: true
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

secrets:
license-server:
description: |
Expand All @@ -74,7 +96,7 @@ on:

jobs:
test-local:
runs-on: ubuntu-22.04
runs-on: ${{ inputs.runner }}
env:
ON_CI: True
ON_LOCAL: true
Expand All @@ -85,9 +107,11 @@ jobs:
P_SCHEMA: "/ansys_inc/v241/ansys/ac4/schema"
PYTEST_TIMEOUT: 120 # seconds. Limit the duration for each unit test
PYTEST_ARGUMENTS: '-vvv -rxXsa --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'
OMPI_ALLOW_RUN_AS_ROOT: 1
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1

container:
image: ghcr.io/ansys/mapdl:${{ inputs.mapdl-version }}
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 }}
Expand All @@ -96,6 +120,8 @@ jobs:
steps:
- name: "Install Git and checkout project"
uses: actions/[email protected]
with:
repository: ansys/pymapdl

- name: "Get if running student version"
id: student_check
Expand All @@ -115,13 +141,13 @@ jobs:
shell: bash
if: inputs.testing-minimal == true
run: |
sudo apt-get update && apt install -y libgomp1 graphviz
apt-get update && apt install -y libgomp1 graphviz

- name: "Installing OS packages"
shell: bash
if: inputs.testing-minimal == false
run: |
sudo apt-get update && apt install -y libgl1-mesa-glx xvfb libgomp1 graphviz
apt-get update && apt install -y libgl1-mesa-glx xvfb libgomp1 graphviz

- name: "Setup Python"
uses: actions/setup-python@v5
Expand Down Expand Up @@ -228,6 +254,7 @@ jobs:

- 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 }}
Expand All @@ -236,6 +263,7 @@ jobs:

- 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
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/3805.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ci: adapting workflow for new docker container
14 changes: 7 additions & 7 deletions src/ansys/mapdl/core/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@


def check_mapdl_launch(
process: subprocess.Popen, run_location: str, timeout: int, cmd: str
process: subprocess.Popen[bytes], run_location: str, timeout: int, cmd: str
) -> None:
"""Check MAPDL launching process.

Expand Down Expand Up @@ -554,7 +554,7 @@
MAPDL did not start.
"""
LOG.debug("Generating queue object for stdout")
stdout_queue, thread = _create_queue_for_std(process.stdout)
stdout_queue, _ = _create_queue_for_std(process.stdout)

Check warning on line 557 in src/ansys/mapdl/core/launcher.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/mapdl/core/launcher.py#L557

Added line #L557 was not covered by tests

# Checking connection
try:
Expand All @@ -564,7 +564,7 @@
LOG.debug("Checking file error is created")
_check_file_error_created(run_location, timeout)

if os.name == "posix" and not ON_WSL:
if os.name == "posix" and not ON_WSL and stdout_queue is not None:

Check warning on line 567 in src/ansys/mapdl/core/launcher.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/mapdl/core/launcher.py#L567

Added line #L567 was not covered by tests
LOG.debug("Checking if gRPC server is alive.")
_check_server_is_alive(stdout_queue, timeout)

Expand Down Expand Up @@ -608,7 +608,7 @@
raise MapdlDidNotStart(msg)


def _check_server_is_alive(stdout_queue, timeout):
def _check_server_is_alive(stdout_queue: Queue[str], timeout: int):
if not stdout_queue:
LOG.debug("No STDOUT queue. Not checking MAPDL this way.")
return
Expand Down Expand Up @@ -644,11 +644,11 @@
raise MapdlDidNotStart("MAPDL failed to start the gRPC server")


def _get_std_output(std_queue, timeout=1):
def _get_std_output(std_queue: Queue[str], timeout: int = 1) -> List[str]:
if not std_queue:
return [None]
return [""]

lines = []
lines: List[str] = []
reach_empty = False
t0 = time.time()
while (not reach_empty) or (time.time() < (t0 + timeout)):
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def _multi_connect(self, n_attempts=5, timeout=15):
# Process is alive
raise MapdlConnectionError(
msg
+ f"The MAPDL process seems to be alive (PID: {self._mapdl_process.pid}) but PyMAPDL cannot connect to it."
+ f" The MAPDL process seems to be alive (PID: {self._mapdl_process.pid}) but PyMAPDL cannot connect to it."
)
else:
pid_msg = (
Expand Down
7 changes: 3 additions & 4 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import subprocess
import time
from typing import Dict, List
from warnings import warn

import psutil

Expand Down Expand Up @@ -268,13 +267,13 @@ def is_exited(mapdl: Mapdl):
try:
# to connect
mapdl = Mapdl(port=port, ip=ip)
warn("MAPDL disconnected during testing, reconnected.")
LOG.warning("MAPDL disconnected during testing, reconnected.")

except MapdlConnectionError as err:
from conftest import DEBUG_TESTING, ON_LOCAL

# Registering error.
LOG.info(str(err))
LOG.warning(str(err))

# we cannot connect.
# Kill the instance
Expand All @@ -296,7 +295,7 @@ def is_exited(mapdl: Mapdl):
log_apdl="pymapdl.apdl" if DEBUG_TESTING else None,
mapdl_output="apdl.out" if (DEBUG_TESTING and ON_LOCAL) else None,
)
warn("MAPDL died during testing, relaunched.")
LOG.info("MAPDL died during testing, relaunched.")

LOG.info("Successfully re-connected to MAPDL")

Expand Down
19 changes: 19 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@

QUICK_LAUNCH_SWITCHES = "-smp -m 100 -db 100"
VALID_PORTS = []
ACCEPTABLE_FAILURE_RATE = 50

## Skip ifs
skip_on_windows = pytest.mark.skipif(ON_WINDOWS, reason="Skip on Windows")
Expand Down Expand Up @@ -372,6 +373,24 @@ def pytest_collection_modifyitems(session, config, items):
item.add_marker(skip_grpc)


@pytest.hookimpl()
def pytest_sessionfinish(session: pytest.Session, exitstatus: pytest.ExitCode):
if os.environ.get("ALLOW_FAILURE_RATE") is None:
return

else:
acceptable_failure_rate = float(
os.environ.get("ALLOW_FAILURE_RATE", ACCEPTABLE_FAILURE_RATE)
)

if exitstatus != pytest.ExitCode.TESTS_FAILED:
return

failure_rate = (100.0 * session.testsfailed) / session.testscollected
if failure_rate <= acceptable_failure_rate:
session.exitstatus = 0


################################################################
#
# Setting configuration fixtures
Expand Down
2 changes: 1 addition & 1 deletion tests/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,7 @@ def test_check_server_is_alive_no_queue():
def test_get_std_output_no_queue():
from ansys.mapdl.core.launcher import _get_std_output

assert _get_std_output(None, 30) == [None]
assert _get_std_output(None, 30) == [""]


def test_create_queue_for_std_no_queue():
Expand Down