diff --git a/.github/actions/check-cache/action.yml b/.github/actions/check-cache/action.yml new file mode 100644 index 00000000000..53df6c795dc --- /dev/null +++ b/.github/actions/check-cache/action.yml @@ -0,0 +1,72 @@ +name: 'Wait for main Cache Update' +description: 'Waits for the main cache update workflow to complete before proceeding with tests' + +runs: + using: 'composite' + steps: + - name: Wait for main cache update + if: github.event_name == 'pull_request' + shell: bash + run: | + echo "Checking if main cache update is running..." + + # First check if the workflow file exists on the main branch + if ! gh api repos/${GITHUB_REPOSITORY}/actions/workflows/update-testmondata-cache.yml --silent 2>/dev/null; then + echo "::notice::Cache update workflow (update-testmondata-cache.yml) not found on main branch yet." + echo "::notice::This is expected before the workflow is merged. Skip for now" + exit 0 + fi + + max_attempts=60 + attempt=0 + final_conclusion="" + + while [ $attempt -lt $max_attempts ]; do + # Check workflow conclusion for base commit + WORKFLOW_CONCLUSION=$(gh run list \ + --workflow=update-testmondata-cache.yml \ + --branch=main \ + --json status,conclusion,headSha \ + --jq ".[] | select(.headSha == \"$BASE_SHA\") | .conclusion") + + if [ "$WORKFLOW_CONCLUSION" == "success" ]; then + echo "::notice::main cache update completed successfully" + final_conclusion="success" + break + elif [ "$WORKFLOW_CONCLUSION" == "failure" ] || [ "$WORKFLOW_CONCLUSION" == "cancelled" ]; then + echo "::warning::main cache update workflow failed or was cancelled" + final_conclusion="$WORKFLOW_CONCLUSION" + break + elif [ -z "$WORKFLOW_CONCLUSION" ]; then + # Check if workflow exists but hasn't completed + WORKFLOW_EXISTS=$(gh run list \ + --workflow=update-testmondata-cache.yml \ + --branch=main \ + --json headSha \ + --jq ".[] | select(.headSha == \"$BASE_SHA\") | .headSha") + + if [ -z "$WORKFLOW_EXISTS" ]; then + echo "::notice::No cache update workflow found for base commit (using existing cache)" + break + fi + fi + + attempt=$((attempt + 1)) + echo "::notice::Attempt $attempt/$max_attempts: Cache update still running, waiting 10s..." + sleep 10 + done + + if [ $attempt -eq $max_attempts ]; then + echo "::error::Timeout waiting for cache update. Cannot proceed without verified cache." + exit 1 + fi + + # Verify the workflow completed successfully + if [ "$final_conclusion" == "failure" ] || [ "$final_conclusion" == "cancelled" ]; then + echo "::error::Cache update workflow did not complete successfully (status: $final_conclusion). Cannot proceed with tests." + exit 1 + fi + env: + GITHUB_REPOSITORY: ${{ github.repository }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + GH_TOKEN: ${{ github.token }} diff --git a/.github/actions/testmon-cache/action.yml b/.github/actions/testmon-cache/action.yml new file mode 100644 index 00000000000..7a437811832 --- /dev/null +++ b/.github/actions/testmon-cache/action.yml @@ -0,0 +1,37 @@ +name: 'Restore Testmon Cache' +description: 'Restores testmon data from cache' +inputs: + testmon-datafile: + description: 'Path to the testmon data file' + required: true + default: '.testmondata' + cache-key: + description: 'Base cache key for testmon data' + required: true + default: 'testmondata-all' + +runs: + using: "composite" + steps: + - name: Restore testmondata cache + id: testmon-cache + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 + with: + path: ${{ inputs.testmon-datafile }} + key: ${{ inputs.cache-key }}-${{ github.base_ref || 'main' }}-${{ github.sha }} + restore-keys: | + ${{ inputs.cache-key }}-${{ github.base_ref || 'main' }}- + ${{ inputs.cache-key }}-main- + + - name: Check testmon cache status + shell: bash + env: + EVENT_NAME: ${{ github.event_name }} + TESTMON_FILE: ${{ inputs.testmon-datafile }} + run: | + if [ -f "$TESTMON_FILE" ]; then + echo "Testmon cache restored successfully" + ls -lh "$TESTMON_FILE" + else + echo "No testmon cache found - will run all tests" + fi diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 2a8bb6685e1..2eaf600caf0 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -8,8 +8,6 @@ on: push: tags: - "*" - branches: - - main env: ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} @@ -18,8 +16,25 @@ env: PACKAGE_NAME: 'PyAEDT' DOCUMENTATION_CNAME: 'aedt.docs.pyansys.com' ON_CI: True - PYTEST_ARGUMENTS: -vvv --color=yes -ra --durations=25 --maxfail=10 --cov=ansys.aedt.core --cov-report=html --cov-report=xml --junitxml=junit/test-results.xml + PYTEST_ARGUMENTS: -vvv --color=yes -ra --durations=25 --maxfail=10 --cov=ansys.aedt.core --cov-report=html --cov-report=xml --junitxml=junit/test-results.xml --testmon PYAEDT_LOCAL_SETTINGS_PATH: 'tests/pyaedt_settings.yaml' + TESTMON_DATAFILE: '.testmondata' + TESTMON_CACHE_KEY_UNIT_LINUX: 'testmondata-unit-linux' + TESTMON_CACHE_KEY_INTEGRATION_LINUX: 'testmondata-integration-linux' + TESTMON_CACHE_KEY_SOLVERS_WIN: 'testmondata-solvers-win' + TESTMON_CACHE_KEY_SOLVERS_LINUX: 'testmondata-solvers-linux' + TESTMON_CACHE_KEY_GENERAL_WIN: 'testmondata-general-win' + TESTMON_CACHE_KEY_GENERAL_LINUX: 'testmondata-general-linux' + TESTMON_CACHE_KEY_VISUALIZATION_WIN: 'testmondata-visualization-win' + TESTMON_CACHE_KEY_VISUALIZATION_LINUX: 'testmondata-visualization-linux' + TESTMON_CACHE_KEY_ICEPAK_WIN: 'testmondata-icepak-win' + TESTMON_CACHE_KEY_ICEPAK_LINUX: 'testmondata-icepak-linux' + TESTMON_CACHE_KEY_LAYOUT_WIN: 'testmondata-layout-win' + TESTMON_CACHE_KEY_LAYOUT_LINUX: 'testmondata-layout-linux' + TESTMON_CACHE_KEY_EXTENSIONS_WIN: 'testmondata-extensions-win' + TESTMON_CACHE_KEY_EXTENSIONS_LINUX: 'testmondata-extensions-linux' + TESTMON_CACHE_KEY_FILTER_WIN: 'testmondata-filter-win' + TESTMON_CACHE_KEY_EMIT_WIN: 'testmondata-emit-win' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -78,8 +93,6 @@ jobs: echo "::warning::PyAnsys CI bot is not allowed to trigger this workflow in dependabot's PR. Please review carefully the changes before running the workflow manually." exit 1 - - vulnerabilities: name: "Vulnerabilities" runs-on: ubuntu-latest @@ -197,13 +210,25 @@ jobs: ${ACTIVATE_VENV} python -c "import ansys.aedt.core; from ansys.aedt.core import __version__" - - unit-tests: name: Unit tests needs: [smoke-tests] runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Wait for master cache update + uses: ./.github/actions/check-cache + + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_UNIT_LINUX }} + - name: Run unit tests uses: ansys/actions/tests-pytest@41f86da4c9ead510db9135e428e33df9cc6f92e1 # v10.2.3 with: @@ -232,6 +257,20 @@ jobs: needs: [unit-tests] runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Wait for master cache update + uses: ./.github/actions/check-cache + + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_INTEGRATION_LINUX }} + - name: Run integration tests uses: ansys/actions/tests-pytest@41f86da4c9ead510db9135e428e33df9cc6f92e1 # v10.2.3 with: @@ -269,6 +308,15 @@ jobs: with: persist-credentials: false + - name: Wait for master cache update + uses: ./.github/actions/check-cache + + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_SOLVERS_WIN }} + - name: Setup Python uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: @@ -288,13 +336,11 @@ jobs: .venv\Scripts\Activate.ps1 uv pip install -U wheel setuptools - - name: Install pyaedt and tests dependencies run: | .venv\Scripts\Activate.ps1 uv pip install .[tests] - - name: Remove Ansys processes (if any) shell: powershell run: | @@ -305,7 +351,6 @@ jobs: Stop-Process -Id $_.Id -Force } - - name: Run tests marked with 'solvers' env: PYTHONMALLOC: malloc @@ -315,7 +360,6 @@ jobs: $args = $env:PYTEST_ARGUMENTS -split ' ' pytest @args --timeout=600 -m solvers - - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: name: codecov-system-solvers-tests-windows @@ -347,6 +391,15 @@ jobs: with: persist-credentials: false + - name: Wait for master cache update + uses: ./.github/actions/check-cache + + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_SOLVERS_LINUX }} + - name: Setup Python uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: @@ -366,13 +419,11 @@ jobs: source .venv/bin/activate uv pip install -U wheel setuptools - - name: Install pyaedt and tests dependencies run: | source .venv/bin/activate uv pip install .[tests] - - name: Remove Ansys processes (if any) shell: bash run: | @@ -381,7 +432,6 @@ jobs: kill -9 "$pid" done - - name: Run tests marked with 'solvers' env: ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} @@ -390,7 +440,6 @@ jobs: source .venv/bin/activate pytest ${PYTEST_ARGUMENTS} --timeout=600 -m solvers - - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: name: codecov-system-solvers-tests-linux @@ -419,6 +468,15 @@ jobs: with: persist-credentials: false + - name: Wait for master cache update + uses: ./.github/actions/check-cache + + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_GENERAL_WIN }} + - name: Set up headless display uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 @@ -441,13 +499,11 @@ jobs: .venv\Scripts\Activate.ps1 uv pip install -U wheel setuptools - - name: Install pyaedt and tests dependencies run: | .venv\Scripts\Activate.ps1 uv pip install .[tests] - - name: Remove Ansys processes (if any) shell: powershell run: | @@ -458,7 +514,6 @@ jobs: Stop-Process -Id $_.Id -Force } - - name: Run tests marked with 'general' uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 env: @@ -473,7 +528,6 @@ jobs: $args = $env:PYTEST_ARGUMENTS -split ' ' pytest @args -n 4 --dist loadfile --timeout=600 -m general - - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: name: codecov-system-general-tests-windows @@ -505,6 +559,15 @@ jobs: with: persist-credentials: false + - name: Wait for master cache update + uses: ./.github/actions/check-cache + + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_GENERAL_LINUX }} + - name: Set up headless display uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 @@ -527,13 +590,11 @@ jobs: source .venv/bin/activate uv pip install -U wheel setuptools - - name: Install pyaedt and tests dependencies run: | source .venv/bin/activate uv pip install .[tests] - - name: Remove Ansys processes (if any) shell: bash run: | @@ -542,7 +603,6 @@ jobs: kill -9 "$pid" done - - name: Run tests marked with 'general' env: ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} @@ -555,7 +615,6 @@ jobs: source .venv/bin/activate pytest ${PYTEST_ARGUMENTS} -n 4 --dist loadfile --timeout=600 -m general - - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: name: codecov-system-general-tests-linux @@ -586,6 +645,15 @@ jobs: with: persist-credentials: false + - name: Wait for master cache update + uses: ./.github/actions/check-cache + + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_VISUALIZATION_WIN }} + - name: Set up headless display uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 @@ -608,13 +676,11 @@ jobs: .venv\Scripts\Activate.ps1 uv pip install -U wheel setuptools - - name: Install pyaedt and tests dependencies run: | .venv\Scripts\Activate.ps1 uv pip install .[tests] - - name: Remove Ansys processes (if any) shell: powershell run: | @@ -625,7 +691,6 @@ jobs: Stop-Process -Id $_.Id -Force } - - name: Run tests marked with 'visualization' uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 env: @@ -640,7 +705,6 @@ jobs: $args = $env:PYTEST_ARGUMENTS -split ' ' pytest @args -n 4 --dist loadfile --timeout=600 -m visualization -x - - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: name: codecov-system-visualization-tests-windows @@ -673,6 +737,15 @@ jobs: with: persist-credentials: false + - name: Wait for master cache update + uses: ./.github/actions/check-cache + + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_VISUALIZATION_LINUX }} + - name: Set up headless display uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 @@ -695,15 +768,11 @@ jobs: source .venv/bin/activate uv pip install -U wheel setuptools - - - name: Install pyaedt and tests dependencies run: | source .venv/bin/activate uv pip install .[tests] - - - name: Remove Ansys processes (if any) shell: bash run: | @@ -712,8 +781,6 @@ jobs: kill -9 "$pid" done - - - name: Run tests marked with 'visualization' env: ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} @@ -726,8 +793,6 @@ jobs: source .venv/bin/activate pytest ${PYTEST_ARGUMENTS} -n 4 --dist loadfile --timeout=300 -m visualization -x - - - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: name: codecov-system-visualization-tests-linux @@ -756,6 +821,15 @@ jobs: with: persist-credentials: false + - name: Wait for master cache update + uses: ./.github/actions/check-cache + + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_ICEPAK_WIN }} + - name: Setup Python uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: @@ -830,6 +904,15 @@ jobs: with: persist-credentials: false + - name: Wait for master cache update + uses: ./.github/actions/check-cache + + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_ICEPAK_LINUX }} + - name: Setup Python uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: @@ -898,6 +981,15 @@ jobs: with: persist-credentials: false + - name: Wait for master cache update + uses: ./.github/actions/check-cache + + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_LAYOUT_WIN }} + - name: Setup Python uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: @@ -917,13 +1009,11 @@ jobs: .venv\Scripts\Activate.ps1 uv pip install -U wheel setuptools - - name: Install pyaedt and tests dependencies run: | .venv\Scripts\Activate.ps1 uv pip install .[tests] - - name: Remove Ansys processes (if any) shell: powershell run: | @@ -934,7 +1024,6 @@ jobs: Stop-Process -Id $_.Id -Force } - - name: Run tests marked with 'layout' env: PYTHONMALLOC: malloc @@ -944,7 +1033,6 @@ jobs: $args = $env:PYTEST_ARGUMENTS -split ' ' pytest @args --timeout=600 -m layout - - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: name: codecov-system-layout-tests-windows @@ -976,6 +1064,15 @@ jobs: with: persist-credentials: false + - name: Wait for master cache update + uses: ./.github/actions/check-cache + + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_LAYOUT_LINUX }} + - name: Setup Python uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: @@ -995,13 +1092,11 @@ jobs: source .venv/bin/activate uv pip install -U wheel setuptools - - name: Install pyaedt and tests dependencies run: | source .venv/bin/activate uv pip install .[tests] - - name: Remove Ansys processes (if any) shell: bash run: | @@ -1010,7 +1105,6 @@ jobs: kill -9 "$pid" done - - name: Run tests marked with 'layout' env: ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} @@ -1019,7 +1113,6 @@ jobs: source .venv/bin/activate pytest ${PYTEST_ARGUMENTS} --timeout=600 -m layout - - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: name: codecov-system-layout-tests-linux @@ -1038,7 +1131,7 @@ jobs: # ================================================================================================= system-tests-extensions-windows: - name: Test extensions - windows (if needed) + name: Test extensions (windows) needs: [integration-tests] if: github.event.pull_request.draft == false runs-on: [ self-hosted, Windows, pyaedt ] @@ -1047,79 +1140,44 @@ jobs: uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: persist-credentials: false - fetch-depth: 0 - - name: Check for changes in extensions folder - id: changes - env: - GITHUB_REF: ${{ github.ref }} - shell: powershell - run: | - $GITHUB_REF = "${env:GITHUB_REF}" - $is_main_branch = $GITHUB_REF -eq "refs/heads/main" - $changed_files = git diff --name-only origin/main...HEAD - $run_tests = $false - foreach ($file in $changed_files) { - if ($file -like "src/ansys/aedt/core/extensions/*" -or $file -eq "tests/system/extensions/*") { - $run_tests = $true - break - } - } - # Always run tests on main branch for code coverage - if ($is_main_branch) { - $run_tests = $true - echo "Running on main branch - all tests will be executed" - } elseif ($run_tests) { - echo "Changes detected in extensions folder" - } else { - echo "No changes in extensions folder" - } - $run_tests_str = if ($run_tests) { "true" } else { "false" } - Add-Content -Path $env:GITHUB_OUTPUT -Value "run_tests=$run_tests_str" + - name: Wait for master cache update + uses: ./.github/actions/check-cache - - - name: Skip extensions tests - if: steps.changes.outputs.run_tests == 'false' - shell: bash - run: echo "Skipped - No changes in src/ansys/aedt/core/extensions" + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_EXTENSIONS_WIN }} - name: Set up headless display - if: steps.changes.outputs.run_tests == 'true' uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 - name: Setup Python - if: steps.changes.outputs.run_tests == 'true' uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: ${{ env.TESTS_VERSION }} - name: Set up uv - if: steps.changes.outputs.run_tests == 'true' uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 with: enable-cache: false prune-cache: true - name: Create virtual environment - if: steps.changes.outputs.run_tests == 'true' run: uv venv .venv - name: Upgrade wheel and setuptools - if: steps.changes.outputs.run_tests == 'true' run: | .venv\Scripts\Activate.ps1 uv pip install -U wheel setuptools - - name: Install pyaedt and tests dependencies - if: steps.changes.outputs.run_tests == 'true' run: | .venv\Scripts\Activate.ps1 uv pip install .[tests] - - name: Remove Ansys processes (if any) - if: steps.changes.outputs.run_tests == 'true' shell: powershell run: | Get-Process | Where-Object { @@ -1129,9 +1187,7 @@ jobs: Stop-Process -Id $_.Id -Force } - - name: Run tests marked with 'extensions' - if: steps.changes.outputs.run_tests == 'true' uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 env: PYTHONMALLOC: malloc @@ -1145,27 +1201,25 @@ jobs: $args = $env:PYTEST_ARGUMENTS -split ' ' pytest @args --timeout=600 -m extensions - - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 - if: steps.changes.outputs.run_tests == 'true' with: name: codecov-system-extensions-tests-windows files: ./coverage.xml flags: windows_system_extensions - name: Upload pytest test results - if: steps.changes.outputs.run_tests == 'true' uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: name: pytest-extensions-windows path: junit/test-results.xml + if: ${{ always() }} # ================================================================================================= # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv # ================================================================================================= system-tests-extensions-linux: - name: Test extensions - linux (if needed) + name: Test extensions (linux) if: github.event.pull_request.draft == false needs: [integration-tests] runs-on: [ self-hosted, Linux, pyaedt ] @@ -1177,77 +1231,44 @@ jobs: uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: persist-credentials: false - fetch-depth: 0 - - name: Check for changes in extensions folder - id: changes - env: - GITHUB_REF: ${{ github.ref }} - shell: bash - run: | - is_main_branch=false - if [ "$GITHUB_REF" = "refs/heads/main" ]; then - is_main_branch=true - fi - changed_files=$(git diff --name-only origin/main...HEAD) - run_tests=false - for file in $changed_files; do - if [[ $file == src/ansys/aedt/core/extensions/* ]] || [[ $file == tests/system/extensions/* ]]; then - run_tests=true - break - fi - done - # Always run tests on main branch for code coverage - if [ "$is_main_branch" = "true" ]; then - run_tests=true - echo "Running on main branch - all tests will be executed" - elif [ "$run_tests" = "true" ]; then - echo "Changes detected in extensions folder" - else - echo "No changes in extensions folder" - fi - echo "run_tests=$run_tests" >> $GITHUB_OUTPUT - - - - name: Skip extensions tests - if: steps.changes.outputs.run_tests == 'false' - run: echo "Skipped - No changes in src/ansys/aedt/core/extensions" + - name: Wait for master cache update + uses: ./.github/actions/check-cache + + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_EXTENSIONS_LINUX }} - name: Set up headless display - if: steps.changes.outputs.run_tests == 'true' uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 - name: Setup Python - if: steps.changes.outputs.run_tests == 'true' uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: ${{ env.TESTS_VERSION }} - name: Set up uv - if: steps.changes.outputs.run_tests == 'true' uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 with: enable-cache: false prune-cache: true - name: Create virtual environment - if: steps.changes.outputs.run_tests == 'true' run: uv venv .venv - name: Upgrade wheel and setuptools - if: steps.changes.outputs.run_tests == 'true' run: | source .venv/bin/activate uv pip install -U wheel setuptools - name: Install pyaedt and tests dependencies - if: steps.changes.outputs.run_tests == 'true' run: | source .venv/bin/activate uv pip install .[tests] - name: Remove Ansys processes (if any) - if: steps.changes.outputs.run_tests == 'true' shell: bash run: | for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do @@ -1256,7 +1277,6 @@ jobs: done - name: Run tests marked with 'extensions' - if: steps.changes.outputs.run_tests == 'true' env: ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 @@ -1269,25 +1289,24 @@ jobs: pytest ${PYTEST_ARGUMENTS} --timeout=600 -m extensions - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 - if: steps.changes.outputs.run_tests == 'true' with: name: codecov-system-extensions-tests-linux files: ./coverage.xml flags: linux_system_extensions - name: Upload pytest test results - if: steps.changes.outputs.run_tests == 'true' uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: name: pytest-extensions-linux path: junit/test-results.xml + if: ${{ always() }} # ================================================================================================= # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv # ================================================================================================= system-tests-filter-windows: - name: Test filter solutions - windows (if needed) + name: Test filter solutions (windows) needs: [integration-tests] if: github.event.pull_request.draft == false runs-on: [ self-hosted, Windows, pyaedt ] @@ -1296,72 +1315,41 @@ jobs: uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: persist-credentials: false - fetch-depth: 0 - - name: Check for changes in filter solutions - id: changes - env: - GITHUB_REF: ${{ github.ref }} - shell: powershell - run: | - $github_ref = "${env:GITHUB_REF}" - $is_main_branch = $github_ref -eq "refs/heads/main" - $changed_files = git diff --name-only origin/main...HEAD - $run_tests = $false - foreach ($file in $changed_files) { - if ($file -like "src/ansys/aedt/core/filtersolutions_core/*" -or $file -eq "src/ansys/aedt/core/filtersolutions.py" -or $file -eq "tests/system/filter_solutions/*") { - $run_tests = $true - break - } - } - # Always run tests on main branch for code coverage - if ($is_main_branch) { - $run_tests = $true - echo "Running on main branch - all tests will be executed" - } elseif ($run_tests) { - echo "Changes detected in filter solutions folder" - } else { - echo "No changes in filter solutions folder" - } - $run_tests_str = if ($run_tests) { "true" } else { "false" } - Add-Content -Path $env:GITHUB_OUTPUT -Value "run_tests=$run_tests_str" + - name: Wait for master cache update + uses: ./.github/actions/check-cache - - name: Skip filter solutions tests - if: steps.changes.outputs.run_tests == 'false' - shell: bash - run: echo "Skipped - No changes in src/ansys/aedt/core/filtersolutions_core" + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_FILTER_WIN }} - name: Setup Python - if: steps.changes.outputs.run_tests == 'true' uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: ${{ env.TESTS_VERSION }} - name: Set up uv - if: steps.changes.outputs.run_tests == 'true' uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 with: enable-cache: false prune-cache: true - name: Create virtual environment - if: steps.changes.outputs.run_tests == 'true' run: uv venv .venv - name: Upgrade wheel and setuptools - if: steps.changes.outputs.run_tests == 'true' run: | .venv\Scripts\Activate.ps1 uv pip install -U wheel setuptools - name: Install pyaedt and tests dependencies - if: steps.changes.outputs.run_tests == 'true' run: | .venv\Scripts\Activate.ps1 uv pip install .[tests] - name: Remove Ansys processes (if any) - if: steps.changes.outputs.run_tests == 'true' shell: powershell run: | Get-Process | Where-Object { @@ -1372,7 +1360,6 @@ jobs: } - name: Run tests marked with 'filter_solutions' - if: steps.changes.outputs.run_tests == 'true' uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 env: PYTHONMALLOC: malloc @@ -1387,25 +1374,24 @@ jobs: pytest @args --timeout=600 -m filter_solutions - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 - if: steps.changes.outputs.run_tests == 'true' with: name: codecov-system-filter-tests-windows files: ./coverage.xml flags: windows_system_filter - name: Upload pytest test results - if: steps.changes.outputs.run_tests == 'true' uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: name: pytest-filter_solutions-windows path: junit/test-results.xml + if: ${{ always() }} # ================================================================================================= # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv # ================================================================================================= system-tests-emit-windows: - name: Test EMIT - windows (if needed) + name: Test EMIT (windows) needs: [integration-tests] if: github.event.pull_request.draft == false runs-on: [ self-hosted, Windows, pyaedt ] @@ -1414,75 +1400,41 @@ jobs: uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: persist-credentials: false - fetch-depth: 0 - - - name: Check for changes in EMIT - id: changes - env: - GITHUB_REF: ${{ github.ref }} - shell: powershell - run: | - $github_ref = "${env:GITHUB_REF}" - $is_main_branch = $github_ref -eq "refs/heads/main" - $changed_files = git diff --name-only origin/main...HEAD - $run_tests = $false - foreach ($file in $changed_files) { - if ($file -like "src/ansys/aedt/core/emit_core/*" -or $file -eq "src/ansys/aedt/core/emit.py" -or $file -eq "tests/system/emit/*") { - $run_tests = $true - break - } - } - # Always run tests on main branch for code coverage - if ($is_main_branch) { - $run_tests = $true - echo "Running on main branch - all tests will be executed" - } elseif ($run_tests) { - echo "Changes detected in EMIT folder" - } else { - echo "No changes in EMIT folder" - } - $run_tests_str = if ($run_tests) { "true" } else { "false" } - Add-Content -Path $env:GITHUB_OUTPUT -Value "run_tests=$run_tests_str" + - name: Wait for master cache update + uses: ./.github/actions/check-cache - - name: Skip EMIT tests - if: steps.changes.outputs.run_tests == 'false' - shell: bash - run: echo "Skipped - No changes in src/ansys/aedt/core/emit_core" + - name: Restore testmondata cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_EMIT_WIN }} - name: Setup Python - if: steps.changes.outputs.run_tests == 'true' uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: python-version: ${{ env.TESTS_VERSION }} - name: Set up uv - if: steps.changes.outputs.run_tests == 'true' uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 with: enable-cache: false prune-cache: true - name: Create virtual environment - if: steps.changes.outputs.run_tests == 'true' run: uv venv .venv - name: Upgrade wheel and setuptools - if: steps.changes.outputs.run_tests == 'true' run: | .venv\Scripts\Activate.ps1 uv pip install -U wheel setuptools - - name: Install pyaedt and tests dependencies - if: steps.changes.outputs.run_tests == 'true' run: | .venv\Scripts\Activate.ps1 uv pip install .[tests] - - name: Remove Ansys processes (if any) - if: steps.changes.outputs.run_tests == 'true' shell: powershell run: | Get-Process | Where-Object { @@ -1492,9 +1444,7 @@ jobs: Stop-Process -Id $_.Id -Force } - - name: Run tests marked with 'emit' - if: steps.changes.outputs.run_tests == 'true' uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 env: PYTHONMALLOC: malloc @@ -1508,20 +1458,18 @@ jobs: $args = $env:PYTEST_ARGUMENTS -split ' ' pytest @args --timeout=600 -v -rA --color=yes -m emit - - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 - if: steps.changes.outputs.run_tests == 'true' with: name: codecov-system-emit-tests-windows files: ./coverage.xml flags: windows_system_emit - name: Upload pytest test results - if: steps.changes.outputs.run_tests == 'true' uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: name: pytest-emit-windows path: junit/test-results.xml + if: ${{ always() }} package: name: Package library diff --git a/.github/workflows/manual_draft.yml b/.github/workflows/manual_draft.yml index 93c3e7f6f0b..ffb37b127b8 100644 --- a/.github/workflows/manual_draft.yml +++ b/.github/workflows/manual_draft.yml @@ -769,4 +769,4 @@ jobs: uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: name: pytest-filter_solutions-windows - path: junit/test-results.xml + path: junit/test-results.xml \ No newline at end of file diff --git a/.github/workflows/nightly-tests.yml b/.github/workflows/nightly-tests.yml index 46db34a2358..ebb91958664 100644 --- a/.github/workflows/nightly-tests.yml +++ b/.github/workflows/nightly-tests.yml @@ -22,6 +22,792 @@ permissions: {} jobs: + unit-tests: + name: Unit tests + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Run unit tests + uses: ansys/actions/tests-pytest@41f86da4c9ead510db9135e428e33df9cc6f92e1 # v10.2.3 + with: + pytest-postargs: 'tests/unit' + pytest-extra-args: ${{ env.PYTEST_ARGUMENTS }} + python-version: ${{ env.MAIN_PYTHON_VERSION }} + optional-dependencies-name: unit-tests + requires-xvfb: true + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + with: + name: codecov-unit-tests + files: ./coverage.xml + flags: linux_unit + + - name: Upload pytest test results + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: pytest-unit + path: junit/test-results.xml + if: ${{ always() }} + + integration-tests: + name: Integration tests + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Run integration tests + uses: ansys/actions/tests-pytest@41f86da4c9ead510db9135e428e33df9cc6f92e1 # v10.2.3 + with: + pytest-postargs: 'tests/integration' + pytest-extra-args: ${{ env.PYTEST_ARGUMENTS }} + python-version: ${{ env.MAIN_PYTHON_VERSION }} + optional-dependencies-name: integration-tests + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + with: + name: codecov-integration-tests + files: ./coverage.xml + flags: linux_integration + + - name: Upload pytest test results + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: pytest-integration + path: junit/test-results.xml + if: ${{ always() }} + +# # ================================================================================================= +# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +# # ================================================================================================= + + system-tests-solvers-windows: + name: Test solvers (windows) + runs-on: [ self-hosted, Windows, pyaedt ] + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'solvers' + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m solvers + + - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + with: + name: codecov-system-solvers-tests-windows + files: ./coverage.xml + flags: windows_system_solvers + + - name: Upload pytest test results + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: pytest-solvers-windows + path: junit/test-results.xml + if: ${{ always() }} + +# # ================================================================================================= +# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +# # ================================================================================================= + + system-tests-solvers-linux: + name: Test solvers (linux) + runs-on: [ self-hosted, Linux, pyaedt ] + env: + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'solvers' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} --timeout=600 -m solvers + + - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + with: + name: codecov-system-solvers-tests-linux + files: ./coverage.xml + flags: linux_system_solvers + + - name: Upload pytest test results + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: pytest-solvers-linux + path: junit/test-results.xml + if: ${{ always() }} + +# # ================================================================================================= +# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +# # ================================================================================================= + + system-tests-general-windows: + name: Test general (windows) + runs-on: [ self-hosted, Windows, pyaedt ] + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'general' + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args -n 4 --dist loadfile --timeout=600 -m general + + - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + with: + name: codecov-system-general-tests-windows + files: ./coverage.xml + flags: windows_system_general + + - name: Upload pytest test results + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: pytest-general-windows + path: junit/test-results.xml + if: ${{ always() }} + +# # ================================================================================================= +# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +# # ================================================================================================= + + system-tests-general-linux: + name: Test general (linux) + runs-on: [ self-hosted, Linux, pyaedt ] + env: + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'general' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} -n 4 --dist loadfile --timeout=600 -m general + + - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + with: + name: codecov-system-general-tests-linux + files: ./coverage.xml + flags: linux_system_general + + - name: Upload pytest test results + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: pytest-general-linux + path: junit/test-results.xml + if: ${{ always() }} + +# # ================================================================================================= +# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +# # ================================================================================================= + + system-tests-visualization-windows: + name: Test visualization (windows) + runs-on: [ self-hosted, Windows, pyaedt ] + env: + MPLBACKEND: 'Agg' + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'visualization' + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args -n 4 --dist loadfile --timeout=600 -m visualization -x + + - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + with: + name: codecov-system-visualization-tests-windows + files: ./coverage.xml + flags: windows_system_visualization + + - name: Upload pytest test results + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: pytest-visualization-windows + path: junit/test-results.xml + if: ${{ always() }} + +# # ================================================================================================= +# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +# # ================================================================================================= + + system-tests-visualization-linux: + name: Test visualization (linux) + runs-on: [ self-hosted, Linux, pyaedt ] + env: + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + MPLBACKEND: 'Agg' + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'visualization' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} -n 4 --dist loadfile --timeout=300 -m visualization -x + + - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + with: + name: codecov-system-visualization-tests-linux + files: ./coverage.xml + flags: linux_system_visualization + + - name: Upload pytest test results + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: pytest-visualization-linux + path: junit/test-results.xml + if: ${{ always() }} + +# # ================================================================================================= +# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +# # ================================================================================================= + + system-tests-icepak-windows: + name: Test icepak (windows) + runs-on: [ self-hosted, Windows, pyaedt ] + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'icepak' + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m icepak + + - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + with: + name: codecov-system-icepak-tests-windows + files: ./coverage.xml + flags: windows_system_icepak + + - name: Upload pytest test results + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: pytest-icepak-windows + path: junit/test-results.xml + if: ${{ always() }} + +# # ================================================================================================= +# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +# # ================================================================================================= + + system-tests-icepak-linux: + name: Test icepak (linux) + runs-on: [ self-hosted, Linux, pyaedt ] + env: + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'icepak' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} --timeout=600 -m icepak + + - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + with: + name: codecov-system-icepak-tests-linux + files: ./coverage.xml + flags: linux_system_icepak + + - name: Upload pytest test results + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: pytest-icepak-linux + path: junit/test-results.xml + if: ${{ always() }} + +# # ================================================================================================= +# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +# # ================================================================================================= + + system-tests-layout-windows: + name: Test layout (windows) + runs-on: [ self-hosted, Windows, pyaedt ] + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'layout' + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m layout + + - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + with: + name: codecov-system-layout-tests-windows + files: ./coverage.xml + flags: windows_system_layout + + - name: Upload pytest test results + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: pytest-layout-windows + path: junit/test-results.xml + if: ${{ always() }} + +# # ================================================================================================= +# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +# # ================================================================================================= + + system-tests-layout-linux: + name: Test layout (linux) + runs-on: [ self-hosted, Linux, pyaedt ] + env: + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'layout' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} --timeout=600 -m layout + + - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + with: + name: codecov-system-layout-tests-linux + files: ./coverage.xml + flags: linux_system_layout + + - name: Upload pytest test results + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: pytest-layout-linux + path: junit/test-results.xml + if: ${{ always() }} + # # ================================================================================================= # # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv # # ================================================================================================= @@ -77,13 +863,15 @@ jobs: uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 env: PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} with: max_attempts: 2 retry_on: error timeout_minutes: 120 command: | .venv\Scripts\Activate.ps1 - pytest ${{ env.PYTEST_ARGUMENTS }} --timeout=600 -m extensions + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m extensions - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: @@ -96,6 +884,7 @@ jobs: with: name: pytest-extensions-windows path: junit/test-results.xml + if: ${{ always() }} # # ================================================================================================= # # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv @@ -151,15 +940,15 @@ jobs: - name: Run tests marked with 'extensions' env: ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 with: max_attempts: 2 retry_on: error timeout_minutes: 120 command: | - export LD_LIBRARY_PATH="${ANSYSEM}/common/mono/Linux64/lib64${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" source .venv/bin/activate - pytest ${{ env.PYTEST_ARGUMENTS }} --timeout=600 -m extensions + pytest ${PYTEST_ARGUMENTS} --timeout=600 -m extensions - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: @@ -172,6 +961,7 @@ jobs: with: name: pytest-extensions-linux path: junit/test-results.xml + if: ${{ always() }} # # ================================================================================================= # # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv @@ -225,13 +1015,15 @@ jobs: uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 env: PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} with: max_attempts: 2 retry_on: error timeout_minutes: 120 command: | .venv\Scripts\Activate.ps1 - pytest ${{ env.PYTEST_ARGUMENTS }} --timeout=600 -m filter_solutions + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m filter_solutions - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: @@ -244,6 +1036,7 @@ jobs: with: name: pytest-filter_solutions-windows path: junit/test-results.xml + if: ${{ always() }} # # ================================================================================================= # # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv @@ -297,13 +1090,15 @@ jobs: uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 env: PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} with: max_attempts: 2 retry_on: error - timeout_minutes: 30 + timeout_minutes: 40 command: | .venv\Scripts\Activate.ps1 - pytest ${{ env.PYTEST_ARGUMENTS }} --timeout=600 -v -rA --color=yes -m emit + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -v -rA --color=yes -m emit - uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: diff --git a/.github/workflows/update-testmondata-cache.yml b/.github/workflows/update-testmondata-cache.yml new file mode 100644 index 00000000000..aae6c4d72db --- /dev/null +++ b/.github/workflows/update-testmondata-cache.yml @@ -0,0 +1,1359 @@ +name: Update Testmon Cache on Merge + +on: + pull_request: + types: + - closed + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: {} + +env: + ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} + ON_CI: True + PYTEST_ARGUMENTS: -vvv --color=yes -ra --durations=25 --maxfail=10 --cov=ansys.aedt.core --cov-report=html --cov-report=xml --junitxml=junit/test-results.xml --testmon + PYAEDT_LOCAL_SETTINGS_PATH: 'tests/pyaedt_settings.yaml' + TESTMON_DATAFILE: '.testmondata' + TESTMON_CACHE_KEY_UNIT_LINUX: 'testmondata-unit-linux' + TESTMON_CACHE_KEY_INTEGRATION_LINUX: 'testmondata-integration-linux' + TESTMON_CACHE_KEY_SOLVERS_WIN: 'testmondata-solvers-win' + TESTMON_CACHE_KEY_SOLVERS_LINUX: 'testmondata-solvers-linux' + TESTMON_CACHE_KEY_GENERAL_WIN: 'testmondata-general-win' + TESTMON_CACHE_KEY_GENERAL_LINUX: 'testmondata-general-linux' + TESTMON_CACHE_KEY_VISUALIZATION_WIN: 'testmondata-visualization-win' + TESTMON_CACHE_KEY_VISUALIZATION_LINUX: 'testmondata-visualization-linux' + TESTMON_CACHE_KEY_ICEPAK_WIN: 'testmondata-icepak-win' + TESTMON_CACHE_KEY_ICEPAK_LINUX: 'testmondata-icepak-linux' + TESTMON_CACHE_KEY_LAYOUT_WIN: 'testmondata-layout-win' + TESTMON_CACHE_KEY_LAYOUT_LINUX: 'testmondata-layout-linux' + TESTMON_CACHE_KEY_EXTENSIONS_WIN: 'testmondata-extensions-win' + TESTMON_CACHE_KEY_EXTENSIONS_LINUX: 'testmondata-extensions-linux' + TESTMON_CACHE_KEY_FILTER_WIN: 'testmondata-filter-win' + TESTMON_CACHE_KEY_EMIT_WIN: 'testmondata-emit-win' + +jobs: + # ------------------------------------------------------------------ + # UNIT TESTS CACHE UPDATE (LINUX) + # ------------------------------------------------------------------ + update-unit-linux: + name: Update unit test cache (Linux) + runs-on: ubuntu-latest + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_UNIT_LINUX }} + + - name: Run unit tests + uses: ansys/actions/tests-pytest@41f86da4c9ead510db9135e428e33df9cc6f92e1 # v10.2.3 + with: + pytest-postargs: 'tests/unit' + pytest-extra-args: ${{ env.PYTEST_ARGUMENTS }} + python-version: ${{ env.TESTS_VERSION }} + optional-dependencies-name: unit-tests + requires-xvfb: true + + - name: Prepare testmon data for caching + run: python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_UNIT_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_UNIT_LINUX }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # INTEGRATION TESTS CACHE UPDATE (LINUX) + # ------------------------------------------------------------------ + update-integration-linux: + name: Update integration test cache (Linux) + runs-on: ubuntu-latest + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_INTEGRATION_LINUX }} + + - name: Run integration tests + uses: ansys/actions/tests-pytest@41f86da4c9ead510db9135e428e33df9cc6f92e1 # v10.2.3 + with: + pytest-postargs: 'tests/integration' + pytest-extra-args: ${{ env.PYTEST_ARGUMENTS }} + python-version: ${{ env.TESTS_VERSION }} + optional-dependencies-name: integration-tests + + - name: Prepare testmon data for caching + run: python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_INTEGRATION_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_INTEGRATION_LINUX }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # SOLVERS TESTS CACHE UPDATE (WINDOWS) + # ------------------------------------------------------------------ + update-solvers-win: + name: Update solvers test cache (Windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_SOLVERS_WIN }} + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.TESTS_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'solvers' + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m solvers + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_SOLVERS_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_SOLVERS_WIN }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # SOLVERS TESTS CACHE UPDATE (LINUX) + # ------------------------------------------------------------------ + update-solvers-linux: + name: Update solvers test cache (Linux) + runs-on: [ self-hosted, Linux, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_SOLVERS_LINUX }} + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.TESTS_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'solvers' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} --timeout=600 -m solvers + + - name: Prepare testmon data for caching + run: | + source .venv/bin/activate + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_SOLVERS_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_SOLVERS_LINUX }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # GENERAL TESTS CACHE UPDATE (WINDOWS) + # ------------------------------------------------------------------ + update-general-win: + name: Update general test cache (Windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_GENERAL_WIN }} + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.TESTS_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'general' + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args -n 4 --dist loadfile --timeout=600 -m general + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_GENERAL_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_GENERAL_WIN }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # GENERAL TESTS CACHE UPDATE (LINUX) + # ------------------------------------------------------------------ + update-general-linux: + name: Update general test cache (Linux) + runs-on: [ self-hosted, Linux, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_GENERAL_LINUX }} + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.TESTS_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'general' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} -n 4 --dist loadfile --timeout=600 -m general + + - name: Prepare testmon data for caching + run: | + source .venv/bin/activate + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_GENERAL_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_GENERAL_LINUX }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # VISUALIZATION TESTS CACHE UPDATE (WINDOWS) + # ------------------------------------------------------------------ + update-visualization-win: + name: Update visualization test cache (Windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + MPLBACKEND: 'Agg' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_VISUALIZATION_WIN }} + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.TESTS_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'visualization' + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args -n 4 --dist loadfile --timeout=600 -m visualization -x + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_VISUALIZATION_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_VISUALIZATION_WIN }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # VISUALIZATION TESTS CACHE UPDATE (LINUX) + # ------------------------------------------------------------------ + update-visualization-linux: + name: Update visualization test cache (Linux) + runs-on: [ self-hosted, Linux, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + MPLBACKEND: 'Agg' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_VISUALIZATION_LINUX }} + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.TESTS_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'visualization' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} -n 4 --dist loadfile --timeout=300 -m visualization -x + + - name: Prepare testmon data for caching + run: | + source .venv/bin/activate + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_VISUALIZATION_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_VISUALIZATION_LINUX }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # ICEPAK TESTS CACHE UPDATE (WINDOWS) + # ------------------------------------------------------------------ + update-icepak-win: + name: Update icepak test cache (Windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_ICEPAK_WIN }} + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.TESTS_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'icepak' + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m icepak + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_ICEPAK_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_ICEPAK_WIN }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # ICEPAK TESTS CACHE UPDATE (LINUX) + # ------------------------------------------------------------------ + update-icepak-linux: + name: Update icepak test cache (Linux) + runs-on: [ self-hosted, Linux, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_ICEPAK_LINUX }} + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.TESTS_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'icepak' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} --timeout=600 -m icepak + + - name: Prepare testmon data for caching + run: | + source .venv/bin/activate + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_ICEPAK_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_ICEPAK_LINUX }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # LAYOUT TESTS CACHE UPDATE (WINDOWS) + # ------------------------------------------------------------------ + update-layout-win: + name: Update layout test cache (Windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_LAYOUT_WIN }} + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.TESTS_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'layout' + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m layout + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_LAYOUT_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_LAYOUT_WIN }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # LAYOUT TESTS CACHE UPDATE (LINUX) + # ------------------------------------------------------------------ + update-layout-linux: + name: Update layout test cache (Linux) + runs-on: [ self-hosted, Linux, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_LAYOUT_LINUX }} + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.TESTS_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'layout' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} --timeout=600 -m layout + + - name: Prepare testmon data for caching + run: | + source .venv/bin/activate + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_LAYOUT_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_LAYOUT_LINUX }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # EXTENSIONS TESTS CACHE UPDATE (WINDOWS) + # ------------------------------------------------------------------ + update-extensions-win: + name: Update extensions test cache (Windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_EXTENSIONS_WIN }} + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.TESTS_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'extensions' + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m extensions + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_EXTENSIONS_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_EXTENSIONS_WIN }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # EXTENSIONS TESTS CACHE UPDATE (LINUX) + # ------------------------------------------------------------------ + update-extensions-linux: + name: Update extensions test cache (Linux) + runs-on: [ self-hosted, Linux, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_EXTENSIONS_LINUX }} + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.TESTS_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'extensions' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} --timeout=600 -m extensions + + - name: Prepare testmon data for caching + run: | + source .venv/bin/activate + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_EXTENSIONS_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_EXTENSIONS_LINUX }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # FILTER TESTS CACHE UPDATE (WINDOWS) + # ------------------------------------------------------------------ + update-filter-win: + name: Update filter test cache (Windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_FILTER_WIN }} + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.TESTS_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'filter_solutions' + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m filter_solutions + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_FILTER_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_FILTER_WIN }}-main-${{ github.sha }} + + # ------------------------------------------------------------------ + # EMIT TESTS CACHE UPDATE (WINDOWS) + # ------------------------------------------------------------------ + update-emit-win: + name: Update emit test cache (Windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + TESTS_VERSION: '3.10' + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Restore testmon cache + uses: ./.github/actions/testmon-cache + with: + testmon-datafile: ${{ env.TESTMON_DATAFILE }} + cache-key: ${{ env.TESTMON_CACHE_KEY_EMIT_WIN }} + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.TESTS_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'emit' + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 40 + command: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -v -rA --color=yes -m emit + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_EMIT_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_EMIT_WIN }}-main-${{ github.sha }} \ No newline at end of file diff --git a/.github/workflows/weekly-tests.yml b/.github/workflows/weekly-tests.yml new file mode 100644 index 00000000000..a9a6662cccf --- /dev/null +++ b/.github/workflows/weekly-tests.yml @@ -0,0 +1,1197 @@ +name: Weekly Tests Updating Testmon Caches + +on: + workflow_dispatch: + schedule: # UTC at 2pm on Saturday + - cron: '0 14 * * 6' + +env: + ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} + MAIN_PYTHON_VERSION: '3.10' + ON_CI: True + PYAEDT_LOCAL_SETTINGS_PATH: 'tests/pyaedt_settings.yaml' + PYTEST_ARGUMENTS: -vvv --color=yes -ra --durations=25 --maxfail=10 --cov=ansys.aedt.core --cov-report=html --cov-report=xml --junitxml=junit/test-results.xml --testmon + TESTMON_DATAFILE: '.testmondata' + TESTMON_CACHE_KEY_UNIT_LINUX: 'testmondata-unit-linux' + TESTMON_CACHE_KEY_INTEGRATION_LINUX: 'testmondata-integration-linux' + TESTMON_CACHE_KEY_SOLVERS_WIN: 'testmondata-solvers-win' + TESTMON_CACHE_KEY_SOLVERS_LINUX: 'testmondata-solvers-linux' + TESTMON_CACHE_KEY_GENERAL_WIN: 'testmondata-general-win' + TESTMON_CACHE_KEY_GENERAL_LINUX: 'testmondata-general-linux' + TESTMON_CACHE_KEY_VISUALIZATION_WIN: 'testmondata-visualization-win' + TESTMON_CACHE_KEY_VISUALIZATION_LINUX: 'testmondata-visualization-linux' + TESTMON_CACHE_KEY_ICEPAK_WIN: 'testmondata-icepak-win' + TESTMON_CACHE_KEY_ICEPAK_LINUX: 'testmondata-icepak-linux' + TESTMON_CACHE_KEY_LAYOUT_WIN: 'testmondata-layout-win' + TESTMON_CACHE_KEY_LAYOUT_LINUX: 'testmondata-layout-linux' + TESTMON_CACHE_KEY_EXTENSIONS_WIN: 'testmondata-extensions-win' + TESTMON_CACHE_KEY_EXTENSIONS_LINUX: 'testmondata-extensions-linux' + TESTMON_CACHE_KEY_FILTER_WIN: 'testmondata-filter-win' + TESTMON_CACHE_KEY_EMIT_WIN: 'testmondata-emit-win' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +# Disable all default permissions at workflow level for security (least privilege principle) +# Individual jobs will explicitly request only the permissions they need +permissions: {} + +jobs: + + unit-tests: + name: Unit tests + runs-on: ubuntu-latest + permissions: + contents: write # Needed to save cache + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Run unit tests + uses: ansys/actions/tests-pytest@41f86da4c9ead510db9135e428e33df9cc6f92e1 # v10.2.3 + with: + pytest-postargs: 'tests/unit' + pytest-extra-args: ${{ env.PYTEST_ARGUMENTS }} + python-version: ${{ env.MAIN_PYTHON_VERSION }} + optional-dependencies-name: unit-tests + requires-xvfb: true + + - name: Prepare testmon data for caching + run: python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_UNIT_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_UNIT_LINUX }}-main-${{ github.sha }} + + integration-tests: + name: Integration tests + runs-on: ubuntu-latest + permissions: + contents: write # Needed to save cache + steps: + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Run integration tests + uses: ansys/actions/tests-pytest@41f86da4c9ead510db9135e428e33df9cc6f92e1 # v10.2.3 + with: + pytest-postargs: 'tests/integration' + pytest-extra-args: ${{ env.PYTEST_ARGUMENTS }} + python-version: ${{ env.MAIN_PYTHON_VERSION }} + optional-dependencies-name: integration-tests + + - name: Prepare testmon data for caching + run: python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_INTEGRATION_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_INTEGRATION_LINUX }}-main-${{ github.sha }} + + system-tests-solvers-windows: + name: Test solvers (windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'solvers' + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m solvers + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_SOLVERS_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_SOLVERS_WIN }}-main-${{ github.sha }} + + system-tests-solvers-linux: + name: Test solvers (linux) + runs-on: [ self-hosted, Linux, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'solvers' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} --timeout=600 -m solvers + + - name: Prepare testmon data for caching + run: | + source .venv/bin/activate + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_SOLVERS_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_SOLVERS_LINUX }}-main-${{ github.sha }} + + system-tests-general-windows: + name: Test general (windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'general' + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args -n 4 --dist loadfile --timeout=600 -m general + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_GENERAL_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_GENERAL_WIN }}-main-${{ github.sha }} + + system-tests-general-linux: + name: Test general (linux) + runs-on: [ self-hosted, Linux, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'general' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} -n 4 --dist loadfile --timeout=600 -m general + + - name: Prepare testmon data for caching + run: | + source .venv/bin/activate + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_GENERAL_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_GENERAL_LINUX }}-main-${{ github.sha }} + + system-tests-visualization-windows: + name: Test visualization (windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + MPLBACKEND: 'Agg' + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'visualization' + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args -n 4 --dist loadfile --timeout=600 -m visualization -x + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_VISUALIZATION_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_VISUALIZATION_WIN }}-main-${{ github.sha }} + + system-tests-visualization-linux: + name: Test visualization (linux) + runs-on: [ self-hosted, Linux, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + MPLBACKEND: 'Agg' + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'visualization' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} -n 4 --dist loadfile --timeout=300 -m visualization -x + + - name: Prepare testmon data for caching + run: | + source .venv/bin/activate + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_VISUALIZATION_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_VISUALIZATION_LINUX }}-main-${{ github.sha }} + + system-tests-icepak-windows: + name: Test icepak (windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'icepak' + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m icepak + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_ICEPAK_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_ICEPAK_WIN }}-main-${{ github.sha }} + + system-tests-icepak-linux: + name: Test icepak (linux) + runs-on: [ self-hosted, Linux, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'icepak' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} --timeout=600 -m icepak + + - name: Prepare testmon data for caching + run: | + source .venv/bin/activate + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_ICEPAK_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_ICEPAK_LINUX }}-main-${{ github.sha }} + + system-tests-layout-windows: + name: Test layout (windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'layout' + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m layout + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_LAYOUT_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_LAYOUT_WIN }}-main-${{ github.sha }} + + system-tests-layout-linux: + name: Test layout (linux) + runs-on: [ self-hosted, Linux, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v7.1.5 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'layout' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + run: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} --timeout=600 -m layout + + - name: Prepare testmon data for caching + run: | + source .venv/bin/activate + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_LAYOUT_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_LAYOUT_LINUX }}-main-${{ github.sha }} + + system-tests-extensions-windows: + name: Test extensions (windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + # NOTE: Our windows runners are impacted by nodejs/node#56645 so we cannot use astral-sh/setup-uv@v7 + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'extensions' + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m extensions + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_EXTENSIONS_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_EXTENSIONS_WIN }}-main-${{ github.sha }} + + system-tests-extensions-linux: + name: Test extensions (linux) + runs-on: [ self-hosted, Linux, pyaedt ] + permissions: + contents: write # Needed to save cache + env: + ANSYSEM_ROOT252: '/usr/ansys_inc/v252/AnsysEM' + ANS_NODEPCHECK: '1' + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Set up headless display + uses: pyvista/setup-headless-display-action@7d84ae825e6d9297a8e99bdbbae20d1b919a0b19 # v4.2 + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + source .venv/bin/activate + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + source .venv/bin/activate + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: bash + run: | + for pid in $(ps -eo pid,comm,args | grep -iE "ansys.inc|ansysem" | grep -v grep | awk '{print $1}'); do + echo "Killing PID $pid" + kill -9 "$pid" + done + + - name: Run tests marked with 'extensions' + env: + ANSYSEM: ${{ env.ANSYSEM_ROOT252 }} + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + source .venv/bin/activate + pytest ${PYTEST_ARGUMENTS} --timeout=600 -m extensions + + - name: Prepare testmon data for caching + run: | + source .venv/bin/activate + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_EXTENSIONS_LINUX }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_EXTENSIONS_LINUX }}-main-${{ github.sha }} + + system-tests-filter-windows: + name: Test filter solutions (windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + # NOTE: Our windows runners are impacted by nodejs/node#56645 so we cannot use astral-sh/setup-uv@v7 + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'filter_solutions' + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 120 + command: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -m filter_solutions + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_FILTER_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_FILTER_WIN }}-main-${{ github.sha }} + + system-tests-emit-windows: + name: Test EMIT (windows) + runs-on: [ self-hosted, Windows, pyaedt ] + permissions: + contents: write # Needed to save cache + steps: + - name: Install Git and checkout project + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + # NOTE: Our windows runners are impacted by nodejs/node#56645 so we cannot use astral-sh/setup-uv@v7 + - name: Set up uv + uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0 + with: + enable-cache: false + prune-cache: true + + - name: Create virtual environment + run: uv venv .venv + + - name: Upgrade wheel and setuptools + run: | + .venv\Scripts\Activate.ps1 + uv pip install -U wheel setuptools + + - name: Install pyaedt and tests dependencies + run: | + .venv\Scripts\Activate.ps1 + uv pip install .[tests] + + - name: Remove Ansys processes (if any) + shell: powershell + run: | + Get-Process | Where-Object { + $_.Path -like "*ansys inc*" -or $_.Path -like "*ansysem*" + } | ForEach-Object { + Write-Output "Killing $($_.Name) (PID: $($_.Id))" + Stop-Process -Id $_.Id -Force + } + + - name: Run tests marked with 'emit' + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + env: + PYTHONMALLOC: malloc + PYTEST_ARGUMENTS: ${{ env.PYTEST_ARGUMENTS }} + with: + max_attempts: 2 + retry_on: error + timeout_minutes: 40 + command: | + .venv\Scripts\Activate.ps1 + $args = $env:PYTEST_ARGUMENTS -split ' ' + pytest @args --timeout=600 -v -rA --color=yes -m emit + + - name: Prepare testmon data for caching + run: | + .venv\Scripts\Activate.ps1 + python -c "import sqlite3; conn = sqlite3.connect('.testmondata'); conn.execute('PRAGMA journal_mode = OFF'); conn.close()" + + - name: Delete old testmon caches + shell: bash + run: | + gh cache list --key ${CACHE_KEY}-main- --json key --jq '.[].key' | xargs -I {} gh cache delete {} || true + env: + CACHE_KEY: ${{ env.TESTMON_CACHE_KEY_EMIT_WIN }} + GH_TOKEN: ${{ github.token }} + + - name: Save updated testmon cache + uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 + with: + path: ${{ env.TESTMON_DATAFILE }} + key: ${{ env.TESTMON_CACHE_KEY_EMIT_WIN }}-main-${{ github.sha }} diff --git a/.gitignore b/.gitignore index caf3b538220..0140d96178e 100644 --- a/.gitignore +++ b/.gitignore @@ -401,5 +401,10 @@ model.index\+ # test coverage output /.cov/ +# testmon +.testmondata +.testmondata-shm +.testmondata-wal + # Custom instructions for GitHub Copilot .github/copilot-instructions.md diff --git a/doc/changelog.d/7035.maintenance.md b/doc/changelog.d/7035.maintenance.md new file mode 100644 index 00000000000..5dfd350a1b5 --- /dev/null +++ b/doc/changelog.d/7035.maintenance.md @@ -0,0 +1 @@ +Add Testmon cache restoration for test selective run diff --git a/pyproject.toml b/pyproject.toml index 434937a08f7..7f351a60b2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,7 @@ dependencies = [ unit-tests = [ "pytest>=7.4.0,<9.1", "pytest-cov>=4.0.0,<7.1", + "pytest-testmon>=2.0.0,<3.0", "mock>=5.1.0,<5.3", "fpdf2", "requests", @@ -56,6 +57,7 @@ unit-tests = [ ] integration-tests = [ "matplotlib>=3.5.0,<3.11", + "pytest-testmon>=2.0.0,<3.0", "pandas>=1.1.0,<2.4", "pyaedt[unit-tests]", ] @@ -66,6 +68,7 @@ tests = [ "pyaedt[integration-tests]", "pytest-timeout>=2.3.0,<2.5", "pytest-xdist>=3.5.0,<3.9", + "pytest-testmon>=2.0.0,<3.0", "pyvista[io]>=0.38.0,<0.47", "scikit-rf>=0.30.0,<1.10", "tables", diff --git a/tests/system/filter_solutions/test_export_to_aedt/test_optimization_goals_table.py b/tests/system/filter_solutions/test_export_to_aedt/test_optimization_goals_table.py index 1b554e87f9f..85be24abc71 100644 --- a/tests/system/filter_solutions/test_export_to_aedt/test_optimization_goals_table.py +++ b/tests/system/filter_solutions/test_export_to_aedt/test_optimization_goals_table.py @@ -65,15 +65,16 @@ def test_row(self, lumped_design): "1", "Y", ] - assert lumped_design.optimization_goals_table.row(1) == [ + row_1 = lumped_design.optimization_goals_table.row(1) + assert row_1[:5] == [ "1.5849 GHz", "1.9019 GHz", "-23.01", "<=", "dB(S(Port2,Port1))", - "0.5", - "Y", ] + assert row_1[5] in ["0.5", "0,5"] + assert row_1[6] == "Y" assert ( lumped_design.optimization_goals_table.row(0)[OptimizationGoalParameter.PARAMETER_NAME.value] == "dB(S(Port1,Port1))"