Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions .github/actions/docker-login/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: 'Docker Login'
description: 'Login to GitHub Container Registry'
runs:
using: 'composite'
steps:
- name: Login in Github Container registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
57 changes: 57 additions & 0 deletions .github/actions/launch-mechanical/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: 'Launch Mechanical Docker Container'
description: 'Pull and launch Mechanical Docker container'
inputs:
mechanical-image:
description: 'Docker image for Mechanical'
required: true
container-name:
description: 'Name for the Docker container'
required: true
license-server:
description: 'License server address'
required: true
port:
description: 'Port to expose'
required: true
default: '10000'
runs:
using: 'composite'
steps:
- name: Pull and launch Mechanical service
shell: bash
env:
MECHANICAL_IMAGE: ${{ inputs.mechanical-image }}
DOCKER_MECH_CONTAINER_NAME: ${{ inputs.container-name }}
LICENSE_SERVER: ${{ inputs.license-server }}
PYMECHANICAL_PORT: ${{ inputs.port }}
run: |
docker pull ${MECHANICAL_IMAGE}

echo "Run docker in detached mode"
docker run -d --name ${DOCKER_MECH_CONTAINER_NAME} -e ANSYSLMD_LICENSE_FILE=1055@${LICENSE_SERVER} -p ${PYMECHANICAL_PORT}:10000 ${MECHANICAL_IMAGE}

# Wait for Mechanical to initialize with intelligent polling
max_wait=300 # Maximum wait time in seconds
check_interval=10 # Check every 10 seconds
elapsed=0

echo "Waiting for Mechanical to initialize..."
while [ $elapsed -lt $max_wait ]; do
docker logs ${DOCKER_MECH_CONTAINER_NAME} > log.txt
if grep -q 'WB Initialize Done' log.txt 2>/dev/null; then
echo "Mechanical initialized successfully after ${elapsed} seconds"
break
fi
echo "Waiting for initialization... (${elapsed}/${max_wait}s)"
sleep $check_interval
elapsed=$((elapsed + check_interval))
done

# Final check
docker logs ${DOCKER_MECH_CONTAINER_NAME} > log.txt
if ! grep -q 'WB Initialize Done' log.txt 2>/dev/null; then
echo "ERROR: Mechanical failed to initialize within ${max_wait} seconds"
echo "=== Last 50 lines of log.txt ==="
tail -n 50 log.txt || echo "No log file found"
exit 1
fi
42 changes: 42 additions & 0 deletions .github/actions/setup-python-container/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 'Setup Python Environment in Container'
description: 'Setup Python environment with uv in a container'
inputs:
python-version:
description: 'Python version to install'
required: true
install-testing-deps:
description: 'Whether to install testing dependencies'
required: false
default: 'true'
install-doc-deps:
description: 'Whether to install documentation dependencies'
required: false
default: 'false'
runs:
using: 'composite'
steps:
- name: Set up Python
shell: bash
run: |
apt update
apt install lsb-release xvfb git curl make -y
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
uv python install python${{ inputs.python-version }}
uv venv /env

- name: Install packages for testing
if: inputs.install-testing-deps == 'true'
shell: bash
run: |
. /env/bin/activate
uv pip install --upgrade pip
uv pip install -e .[tests]

- name: Install packages for documentation
if: inputs.install-doc-deps == 'true'
shell: bash
run: |
. /env/bin/activate
uv pip install --upgrade pip
uv pip install -e .[doc]
26 changes: 26 additions & 0 deletions .github/actions/setup-test-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Setup Test Environment Variables'
description: 'Set common environment variables for testing jobs'
inputs:
container-stable-exit:
description: 'Whether container tests should exit on failure'
required: true
python-version:
description: 'Python version being tested'
required: true
num-cores:
description: 'Number of cores to use'
required: false
default: '1'
runs:
using: 'composite'
steps:
- name: Set common test environment
shell: bash
run: |
echo "ANSYS_WORKBENCH_LOGGING_CONSOLE=0" >> $GITHUB_ENV
echo "ANSYS_WORKBENCH_LOGGING=0" >> $GITHUB_ENV
echo "ANSYS_WORKBENCH_LOGGING_FILTER_LEVEL=2" >> $GITHUB_ENV
echo "CONTAINER_STABLE_EXIT=${{ inputs.container-stable-exit }}" >> $GITHUB_ENV
echo "MATRIX_PYTHON_VERSION=${{ inputs.python-version }}" >> $GITHUB_ENV
echo "NUM_CORES=${{ inputs.num-cores }}" >> $GITHUB_ENV
echo "PYTHONUNBUFFERED=1" >> $GITHUB_ENV
32 changes: 32 additions & 0 deletions .github/actions/upload-coverage/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 'Upload Coverage Results'
description: 'Upload coverage results as artifacts'
inputs:
coverage-name:
description: 'Name suffix for coverage artifacts'
required: true
python-version:
description: 'Python version being tested'
required: true
main-python-version:
description: 'Main Python version to compare against'
required: true
runs:
using: 'composite'
steps:
- name: Upload coverage results (.cov)
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: inputs.python-version == inputs.main-python-version
with:
include-hidden-files: true
name: coverage-${{ inputs.coverage-name }}
path: .cov
retention-days: 7

- name: Upload coverage results (.coverage)
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: inputs.python-version == inputs.main-python-version
with:
include-hidden-files: true
name: coverage-file-${{ inputs.coverage-name }}
path: .coverage
retention-days: 7
Loading
Loading