Skip to content

tests

tests #38

Workflow file for this run

name: tests
on:
# Can be called by the CI
workflow_call:
inputs:
python_versions:
required: false
type: string
default: '["3.10"]'
ANSYS_VERSION:
required: false
type: string
wheel:
required: false
type: string
default: 'false'
wheelhouse:
required: false
type: string
default: 'false'
DOCSTRING:
required: false
type: string
default: 'true'
standalone_suffix:
description: "Suffix of the branch on standalone"
required: false
type: string
default: ''
test_any:
description: "Test the any version of the wheel"
required: false
type: string
default: 'false'
# Can be called manually
workflow_dispatch:
inputs:
python_versions:
description: "Python interpreters to test."
required: true
type: string
default: '["3.10", "3.11", "3.12"]'
ANSYS_VERSION:
description: "ANSYS version"
required: false
type: string
wheel:
description: "Generate a wheel"
required: false
type: string
default: 'false'
wheelhouse:
description: "Generate a wheelhouse"
required: false
type: string
default: 'false'
DOCSTRING:
description: "Whether to test docstrings"
required: false
type: string
default: 'true'
standalone_suffix:
description: "Suffix of the branch on standalone"
required: false
type: string
default: ''
test_any:
description: "Test the any version of the wheel"
required: false
type: string
default: 'false'
env:
PACKAGE_NAME: ansys-dpf-core
MODULE: core
jobs:
setup:
name: "Setup"
runs-on: ubuntu-latest
outputs:
python_versions: ${{ steps.set_array.outputs.python_versions }}
steps:
- id: set_array
run: |
echo "python_versions=${{ toJSON(inputs.python_versions) }}" >> $GITHUB_OUTPUT
tests:
name: "Tests"
needs: setup
timeout-minutes: 120
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(needs.setup.outputs.python_versions) }}
os: ["windows-latest", "ubuntu-latest"]
steps:
- uses: actions/checkout@v4
- name: "Set licensing if necessary"
if: ${{ (inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT) > '231' }}
shell: bash
run: |
echo "ANSYS_DPF_ACCEPT_LA=Y" >> $GITHUB_ENV
echo "ANSYSLMD_LICENSE_FILE=1055@${{ secrets.LICENSE_SERVER }}" >> $GITHUB_ENV
- name: "Setup Python"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: "Setup Graphviz"
uses: ts-graphviz/setup-graphviz@v2
- name: "Update pip to the latest version and install tox"
shell: pwsh
run: |
python -m pip install -U pip
python -m pip install -U tox tox-uv
- name: "Build the wheel"
shell: bash
run: |
if [ ${{ inputs.test_any }} == 'true' ]; then
export platform="any"
elif [ ${{ matrix.os }} == "ubuntu-latest" ]; then
export platform="manylinux_2_17"
else
export platform="win"
fi
tox -e build-wheel -- $platform
- name: "Expose the wheel"
shell: bash
id: wheel
working-directory: dist
run: |
export name=`ls ansys_dpf_core*.whl`
echo ${name}
echo "wheel_name=${name[0]}" >> $GITHUB_OUTPUT
- name: "Upload wheel to artifacts"
if: (inputs.wheel == 'true') && !( (inputs.test_any == 'true') && (matrix.os == 'ubuntu-latest') )
uses: actions/upload-artifact@v4
with:
name: ${{ steps.wheel.outputs.wheel_name }}
path: dist/${{ steps.wheel.outputs.wheel_name }}
- name: "Define wheelhouse name"
if: inputs.wheelhouse == 'true'
shell: bash
id: wheelhouse
run: |
export wheel_name=${{ steps.wheel.outputs.wheel_name }}
export IFS='-'
read -a strarr <<< $wheel_name
export version="${strarr[1]}"
echo $version
export name=ansys-dpf-core-v${version}-wheelhouse-${{ runner.os }}-${{ matrix.python-version }}.zip
echo "name=${name}" >> "$GITHUB_OUTPUT"
- name: "Zip wheelhouse"
if: inputs.wheelhouse == 'true'
uses: vimtor/[email protected]
with:
files: dist
dest: ${{ steps.wheelhouse.outputs.name }}
- name: "Upload wheelhouse to artifacts"
if: inputs.wheelhouse == 'true'
uses: actions/upload-artifact@v4
with:
name: ${{ steps.wheelhouse.outputs.name }}
path: ${{ steps.wheelhouse.outputs.name }}
retention-days: 7
- name: "Install DPF"
id: set-server-path
uses: ansys/pydpf-actions/[email protected]
with:
dpf-standalone-TOKEN: ${{secrets.PYANSYS_CI_BOT_TOKEN}}
standalone_suffix: ${{ inputs.standalone_suffix }}
ANSYS_VERSION : ${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }}
- name: "Check licences of packages"
uses: ansys/pydpf-actions/[email protected]
- name: "Test import"
shell: bash
run: |
python -m pip install dist/${{ steps.wheel.outputs.wheel_name }}
python -c "from ansys.dpf import core"
- name: "Prepare Testing Environment"
uses: ansys/pydpf-actions/prepare_tests@dependencies/bump_pyvista_setup-headless-display-action_to_v4
with:
DEBUG: true
- name: "Test Docstrings"
if: (inputs.DOCSTRING == 'true')
uses: ansys/pydpf-actions/[email protected]
with:
MODULE: ${{env.MODULE}}
PACKAGE_NAME: ${{env.PACKAGE_NAME}}
working-directory: src
- name: "Set tox extra CLI arguments"
id: tox-cli-arguments
shell: bash
run: |
if [ $MODE == 'PIP' ]; then
echo 'TOX_EXTRA_ARG=--installpkg dist/${{ steps.wheel.outputs.wheel_name }} -x testenv.deps+="-e dpf-standalone/v${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }}"' >> "$GITHUB_OUTPUT"
else
echo 'TOX_EXTRA_ARG=--installpkg dist/${{ steps.wheel.outputs.wheel_name }}' >> "$GITHUB_OUTPUT"
fi
- name: "Organize test files"
shell: bash
run: |
tox -e pretest
- name: "Test API test_entry"
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 2
shell: bash
command: |
tox -e test-api_entry,kill-servers ${{ steps.tox-cli-arguments.outputs.TOX_EXTRA_ARG }}
- name: "Run compatible tests in parallel"
uses: nick-fields/retry@v3
with:
timeout_minutes: 15
max_attempts: 2
shell: bash
command: |
tox run-parallel -m ciparalleltests ${{ steps.tox-cli-arguments.outputs.TOX_EXTRA_ARG }}
- name: "Test API test_server"
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 2
shell: bash
command: |
tox -e test-server,kill-servers ${{ steps.tox-cli-arguments.outputs.TOX_EXTRA_ARG }}
- name: "Test API test_remote_workflow"
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
shell: bash
command: |
tox -e test-remote_workflow,kill-servers ${{ steps.tox-cli-arguments.outputs.TOX_EXTRA_ARG }}
- name: "Test API test_remote_operator"
shell: bash
run: |
tox -e test-remote_operator,kill-servers ${{ steps.tox-cli-arguments.outputs.TOX_EXTRA_ARG }}
- name: "Test API test_workflow"
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 4
shell: bash
command: |
tox -e test-workflow,kill-servers ${{ steps.tox-cli-arguments.outputs.TOX_EXTRA_ARG }}
- name: "Test API test_service"
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 2
shell: bash
command: |
tox -e test-service,kill-servers ${{ steps.tox-cli-arguments.outputs.TOX_EXTRA_ARG }}
- name: "Combine coverage results"
shell: bash
run: |
tox -e covreport
- name: "Upload Test Results"
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}_${{ matrix.python-version }}_${{ matrix.os }}_pytest_${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }}${{ inputs.test_any == 'true' && '_any' || '' }}
path: tests/junit/test-results.xml
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }} # required
file: ./.tox/.cov/coverage.xml
name: ${{ env.PACKAGE_NAME }}_${{ matrix.python-version }}_${{ matrix.os }}_pytest_${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }}${{ inputs.test_any == 'true' && '_any' || '' }}.xml
flags: ${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }},${{ matrix.os }},${{ matrix.python-version }}${{ inputs.test_any == 'true' && ',any' || '' }}
- name: "Upload test analytics results to Codecov"
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: test_results_${{ env.PACKAGE_NAME }}_${{ matrix.python-version }}_${{ matrix.os }}_${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }}${{ inputs.test_any == 'true' && '_any' || '' }}
flags: ${{ inputs.ANSYS_VERSION || vars.ANSYS_VERSION_DEFAULT }},${{ matrix.os }},${{ matrix.python-version }}${{ inputs.test_any == 'true' && ',any' || '' }}