Skip to content

chore: pre-commit automatic update (#174) #369

chore: pre-commit automatic update (#174)

chore: pre-commit automatic update (#174) #369

name: Geometry Mechanical DPF Workflow
on:
workflow_dispatch:
inputs:
doc-build:
required: false
default: false
type: boolean
description: 'Whether to build the documentation'
workflow_call:
inputs:
doc-build:
required: false
default: false
type: boolean
description: 'Whether to build the documentation'
push:
branches:
- main
pull_request:
paths:
- 'geometry-mechanical-dpf/**'
env:
MAIN_PYTHON_VERSION: '3.12'
GEOMETRY_DOCKER_IMAGE: 'ghcr.io/ansys/geometry'
MECHANICAL_DOCKER_IMAGE: 'ghcr.io/ansys/mechanical'
ANSRV_GEO_PORT: 700
ANSRV_GEO_LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER )}}
PYANSYS_WORKFLOWS_CI: true
ANSYS_RELEASE_FOR_DOCS: 25.1
jobs:
is-only-docs-required:
uses: ./.github/workflows/check-docs-required.yml
with:
doc-build: ${{ inputs.doc-build || false }}
geometry:
name: Geometry
runs-on: [self-hosted, Windows, pyansys-workflows]
needs: is-only-docs-required
strategy:
fail-fast: false
matrix:
ansys-release: ${{ needs.is-only-docs-required.outputs.only-docs == 'true' && fromJSON('[25.1]') || fromJSON('[24.1, 24.2, 25.1]') }}
steps:
- name: Checkout code
uses: actions/checkout@v6.0.2
with:
sparse-checkout: |
geometry-mechanical-dpf
doc
- name: Set up Python ${{ env.MAIN_PYTHON_VERSION }}
uses: actions/setup-python@v6
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: Setup headless display
uses: pyvista/setup-headless-display-action@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m venv .venv
.venv/Scripts/activate
pip install -r geometry-mechanical-dpf/requirements_${{ matrix.ansys-release }}.txt
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download (if needed) and run Geometry service container
run: |
# If we are on 25.1 or above - the tag name is different - remember we are on powershell
if (${{ matrix.ansys-release }} -ge 25.2) {
$env:ANSYS_GEOMETRY_RELEASE = "${{ env.GEOMETRY_DOCKER_IMAGE }}:core-windows-${{ matrix.ansys-release }}"
} else {
$env:ANSYS_GEOMETRY_RELEASE = "${{ env.GEOMETRY_DOCKER_IMAGE }}:windows-${{ matrix.ansys-release }}"
}
Write-Host "Running Geometry service container: $env:ANSYS_GEOMETRY_RELEASE"
# Pull the container image
docker pull $env:ANSYS_GEOMETRY_RELEASE
# Define the ANSYS_GEOMETRY_RELEASE environment variable to be used in the next stages
echo "ANSYS_GEOMETRY_RELEASE=$env:ANSYS_GEOMETRY_RELEASE" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Run the PyAnsys Geometry script
run: |
.venv/Scripts/activate
python geometry-mechanical-dpf/wf_gmd_01_geometry.py
- name: Store the outputs
uses: actions/upload-artifact@v6
with:
name: geometry-mechanical-dpf-workflow-geometry-outputs-${{ matrix.ansys-release }}
path: geometry-mechanical-dpf/outputs
- name: (DOCS) Build the documentation (only on ${{ env.ANSYS_RELEASE_FOR_DOCS }})
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
env:
BUILD_DOCS_SCRIPT: 'geometry-mechanical-dpf/wf_gmd_01_geometry.py'
run: |
.venv/Scripts/activate
cd doc
pip install -r requirements.txt
./make.bat html
- name: (DOCS) Upload docs artifacts
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
uses: actions/upload-artifact@v6
with:
name: geometry-mechanical-dpf-docs-stage-geometry
path: |
doc/_build/
doc/source/examples/geometry-mechanical-dpf/
- name: Stop any remaining containers
if: always()
run: |
$dockerContainers = docker ps -a -q
if (-not [string]::IsNullOrEmpty($dockerContainers)) {
docker rm -f $dockerContainers
}
mech-dpf:
name: Mechanical - Dpf
runs-on: public-ubuntu-latest-8-cores
needs: [geometry, is-only-docs-required]
strategy:
fail-fast: false
matrix:
ansys-release: ${{ needs.is-only-docs-required.outputs.only-docs == 'true' && fromJSON('[25.1]') || fromJSON('[24.1, 24.2, 25.1]') }}
container:
image: 'ghcr.io/ansys/mechanical:${{ matrix.ansys-release }}.0'
options: --entrypoint /bin/bash
steps:
- name: Checkout code
uses: actions/checkout@v6.0.2
with:
sparse-checkout: |
geometry-mechanical-dpf
doc
- name: "Set up Python and activate virtual environment"
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${{ env.MAIN_PYTHON_VERSION }}
uv venv /.venv
- name: Install dependencies
run: |
. /.venv/bin/activate
uv pip install --upgrade pip
uv pip install -r geometry-mechanical-dpf/requirements_${{ matrix.ansys-release }}.txt
- name: Check out the geometry outputs
uses: actions/download-artifact@v7
with:
name: geometry-mechanical-dpf-workflow-geometry-outputs-${{ matrix.ansys-release }}
path: geometry-mechanical-dpf/outputs
- name: Run the PyMechanical script
env:
NUM_CORES: 1
ANSYS_WORKBENCH_LOGGING_CONSOLE: 0
ANSYS_WORKBENCH_LOGGING: 0
ANSYS_WORKBENCH_LOGGING_FILTER_LEVEL: 2
run: |
. /.venv/bin/activate
xvfb-run mechanical-env python geometry-mechanical-dpf/wf_gmd_02_mechanical.py > pymechlogs${{ matrix.ansys-release }}.txt 2>&1 || true
cat pymechlogs${{ matrix.ansys-release }}.txt
- name: Run the PyDPF script
run: |
. /.venv/bin/activate
xvfb-run python geometry-mechanical-dpf/wf_gmd_03_dpf.py > pydpflogs${{ matrix.ansys-release }}.txt 2>&1 || true
cat pydpflogs${{ matrix.ansys-release }}.txt
- name: Store the outputs
uses: actions/upload-artifact@v6
with:
name: geometry-mechanical-dpf-workflow-mechanical-dpf-outputs-${{ matrix.ansys-release }}
path: geometry-mechanical-dpf/outputs
- name: (DOCS) Download the docs artifacts
uses: actions/download-artifact@v7
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
with:
name: geometry-mechanical-dpf-docs-stage-geometry
path: doc
- name: (DOCS) Build the documentation for the Mechanical script (only on ${{ env.ANSYS_RELEASE_FOR_DOCS }})
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
env:
NUM_CORES: 1
ANSYS_WORKBENCH_LOGGING_CONSOLE: 0
ANSYS_WORKBENCH_LOGGING: 0
ANSYS_WORKBENCH_LOGGING_FILTER_LEVEL: 2
BUILD_DOCS_SCRIPT: 'geometry-mechanical-dpf/wf_gmd_02_mechanical.py'
run: |
. /.venv/bin/activate
find . -type f -exec sed -i 's|C:\\Users\\ansys\\actions-runner\\_work\\pyansys-workflows\\pyansys-workflows\\doc\\source\\examples\\geometry-mechanical-dpf\\images\\|./images/|g' {} +
uv pip install -r ./doc/requirements.txt
xvfb-run mechanical-env make -C doc html > pymech-docs-logs${{ matrix.ansys-release }}.txt 2>&1 || true
cat pymech-docs-logs${{ matrix.ansys-release }}.txt
- name: (DOCS) Build the documentation for the DPF script (only on ${{ env.ANSYS_RELEASE_FOR_DOCS }})
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
env:
BUILD_DOCS_SCRIPT: 'geometry-mechanical-dpf/wf_gmd_03_dpf.py'
run: |
. /.venv/bin/activate
uv pip install -r ./doc/requirements.txt
xvfb-run make -C doc html > dpf-docs-logs${{ matrix.ansys-release }}.txt 2>&1 || true
cat dpf-docs-logs${{ matrix.ansys-release }}.txt
- name: (DOCS) Adapt the documentation paths
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
run: |
find . -type f -exec sed -i 's|/__w/pyansys-workflows/pyansys-workflows/doc/source/examples/geometry-mechanical-dpf/images|./images/|g' {} +
- name: (DOCS) Upload docs artifacts
if: needs.is-only-docs-required.outputs.only-docs == 'true' && matrix.ansys-release == env.ANSYS_RELEASE_FOR_DOCS
uses: actions/upload-artifact@v6
with:
name: geometry-mechanical-dpf-docs
path: |
doc/_build/
doc/source/examples/geometry-mechanical-dpf/
overwrite: true