Skip to content

Commit

Permalink
REFACTOR: Test architecture and CICD (#5351)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
SMoraisAnsys and pre-commit-ci[bot] authored Oct 31, 2024
1 parent 25c9ca1 commit dafbb23
Show file tree
Hide file tree
Showing 754 changed files with 1,413 additions and 926 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.github/* @MaxJPRey @maxcapodi78 @Samuelopez-ansys
.github/* @MaxJPRey @maxcapodi78 @Samuelopez-ansys @SMoraisAnsys

/_unittest/test_26_emit.py @jsalant22 @myoung301
/tests/system/solvers/test_26_emit.py @jsalant22 @myoung301
/src/ansys/aedt/core/emit.py @jsalant22 @myoung301
/src/ansys/aedt/core/emit_core/ @jsalant22 @myoung301
/src/ansys/aedt/core/modeler/circuits/PrimitivesEmit.py @jsalant22 @myoung301
Expand Down
8 changes: 5 additions & 3 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ maintenance:
testing:
- changed-files:
- any-glob-to-any-file:
- "_unittest/conftest.py"
- "_unittest_ironpython/run_unittests.py"
- "_unittest_ironpython/run_unittests_batchmode.cmd"
- "tests/conftest.py"
- "tests/unit/conftest.py"
- "tests/system/conftest.py"
- "tests/system/solvers/conftest.py"
- "tests/system/general/conftest.py"

examples:
- changed-files:
Expand Down
88 changes: 55 additions & 33 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ env:
MEILISEARCH_HOST_URL: ${{ vars.MEILISEARCH_HOST_URL }}
MEILISEARCH_PUBLIC_API_KEY: ${{ secrets.MEILISEARCH_PUBLIC_API_KEY }}
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'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -32,13 +33,12 @@ jobs:
name: Check the title of the pull request
runs-on: ubuntu-latest
steps:
- name: Check commit name
- name: Check the title of the pull request
uses: ansys/actions/check-pr-title@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
use-upper-case: true

# TODO: Update to ansys/actions/doc-style@v6
doc-style:
name: Documentation style check
runs-on: ubuntu-latest
Expand All @@ -48,6 +48,19 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}

doc-build:
name: Documentation build
runs-on: ubuntu-latest
needs: [doc-style]
steps:
- name: Documentation build
uses: ansys/actions/doc-build@v8
with:
dependencies: "graphviz texlive-latex-extra latexmk texlive-xetex texlive-fonts-extra"
python-version: ${{ env.MAIN_PYTHON_VERSION }}
sphinxopts: '-j auto --color -w build_errors.txt'
check-links: false

smoke-tests:
name: Build wheelhouse and smoke tests
runs-on: ${{ matrix.os }}
Expand All @@ -70,27 +83,42 @@ jobs:
run: |
python -c "import ansys.aedt.core; from ansys.aedt.core import __version__"
doc-build:
name: Documentation build
unit-tests:
name: Running unit tests
needs: [smoke-tests]
runs-on: ubuntu-latest
needs: [doc-style]
steps:
- name: Documentation build
uses: ansys/actions/doc-build@v8
- name: Run unit tests
uses: ansys/actions/tests-pytest@v8
with:
dependencies: "graphviz texlive-latex-extra latexmk texlive-xetex texlive-fonts-extra"
pytest-markers: -m unit
pytest-extra-args: ${{ env.PYTEST_ARGUMENTS }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
sphinxopts: '-j auto --color -w build_errors.txt'
check-links: false
optional-dependencies-name: unit-tests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: codecov-unit-tests
file: ./coverage.xml
flags: unit

- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: pytest-unit
path: junit/test-results.xml
if: ${{ always() }}

# # =================================================================================================
# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# # =================================================================================================

test-solvers-windows:
system-tests-solvers-windows:
name: Testing solvers and coverage (Windows)
needs: [unit-tests]
if: github.event.pull_request.draft == false
needs: [smoke-tests]
runs-on: [ self-hosted, Windows, pyaedt ]
steps:
- name: Install Git and checkout project
Expand All @@ -113,7 +141,6 @@ jobs:
run: |
.venv\Scripts\Activate.ps1
pip install .[tests]
pip install pytest-azurepipelines
- name: Install CI dependencies (e.g. vtk-osmesa)
run: |
Expand All @@ -122,12 +149,12 @@ jobs:
pip uninstall --yes vtk
pip install --extra-index-url https://wheels.vtk.org vtk-osmesa
- name: Run tests on _unittest_solvers
- name: Run tests marked with 'solvers'
env:
PYTHONMALLOC: malloc
run: |
.venv\Scripts\Activate.ps1
pytest --durations=50 -v --cov=ansys.aedt.core --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest_solvers
pytest ${{ env.PYTEST_ARGUMENTS }} -m solvers
- uses: codecov/codecov-action@v4
with:
Expand All @@ -147,11 +174,10 @@ jobs:
# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# # =================================================================================================

# TODO: Si if we can use ansys/actions
test-solvers-linux:
system-tests-solvers-linux:
name: Testing solvers and coverage (Linux)
needs: [unit-tests]
if: github.event.pull_request.draft == false
needs: [smoke-tests]
runs-on: [ self-hosted, Linux, pyaedt ]
env:
ANSYSEM_ROOT242: '/opt/AnsysEM/v242/Linux64'
Expand Down Expand Up @@ -179,13 +205,12 @@ jobs:
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT242 }}/common/mono/Linux64/lib64:${{ env.ANSYSEM_ROOT242 }}/Delcross:$LD_LIBRARY_PATH
source .venv/bin/activate
pip install .[tests]
pip install pytest-azurepipelines
- name: Run tests on _unittest_solvers
- name: Run tests marked with 'solvers'
run: |
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT242 }}/common/mono/Linux64/lib64:${{ env.ANSYSEM_ROOT242 }}/Delcross:$LD_LIBRARY_PATH
source .venv/bin/activate
pytest --durations=50 -v --cov=ansys.aedt.core --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest_solvers
pytest ${{ env.PYTEST_ARGUMENTS }} -m solvers
- uses: codecov/codecov-action@v4
with:
Expand All @@ -205,10 +230,10 @@ jobs:
# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# # =================================================================================================

test-windows:
system-tests-general-windows:
name: Testing and coverage (Windows)
needs: [unit-tests]
if: github.event.pull_request.draft == false
needs: [smoke-tests]
runs-on: [ self-hosted, Windows, pyaedt ]
steps:
- name: Install Git and checkout project
Expand All @@ -231,7 +256,6 @@ jobs:
run: |
.venv\Scripts\Activate.ps1
pip install .[tests]
pip install pytest-azurepipelines
- name: Install CI dependencies (e.g. vtk-osmesa)
run: |
Expand All @@ -240,7 +264,7 @@ jobs:
pip uninstall --yes vtk
pip install --extra-index-url https://wheels.vtk.org vtk-osmesa
- name: Run tests on _unittest
- name: Run tests marked with 'general'
uses: nick-fields/retry@v3
env:
PYTHONMALLOC: malloc
Expand All @@ -250,7 +274,7 @@ jobs:
timeout_minutes: 50
command: |
.venv\Scripts\Activate.ps1
pytest -n 4 --dist loadfile --durations=50 -v --cov=ansys.aedt.core --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest
pytest ${{ env.PYTEST_ARGUMENTS }} -n 4 --dist loadfile -m general
- uses: codecov/codecov-action@v4
with:
Expand All @@ -270,11 +294,10 @@ jobs:
# # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv RUNNING ON SELF-HOSTED RUNNER vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# # =================================================================================================

# TODO: Si if we can use ansys/actions
test-linux:
system-tests-general-linux:
name: Testing and coverage (Linux)
if: github.event.pull_request.draft == false
needs: [smoke-tests]
needs: [unit-tests]
runs-on: [ self-hosted, Linux, pyaedt ]
env:
ANSYSEM_ROOT242: '/opt/AnsysEM/v242/Linux64'
Expand Down Expand Up @@ -302,7 +325,6 @@ jobs:
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT242 }}/common/mono/Linux64/lib64:${{ env.ANSYSEM_ROOT242 }}/Delcross:$LD_LIBRARY_PATH
source .venv/bin/activate
pip install .[tests]
pip install pytest-azurepipelines
- name: Install CI dependencies (e.g. vtk-osmesa)
run: |
Expand All @@ -311,7 +333,7 @@ jobs:
pip uninstall --yes vtk
pip install --extra-index-url https://wheels.vtk.org vtk-osmesa
- name: Run tests on _unittest
- name: Run tests marked with 'general'
uses: nick-fields/retry@v3
with:
max_attempts: 2
Expand All @@ -320,7 +342,7 @@ jobs:
command: |
export LD_LIBRARY_PATH=${{ env.ANSYSEM_ROOT242 }}/common/mono/Linux64/lib64:${{ env.ANSYSEM_ROOT242 }}/Delcross:$LD_LIBRARY_PATH
source .venv/bin/activate
pytest -n 2 --dist loadfile --durations=50 -v --cov=ansys.aedt.core --cov-report=xml --cov-report=html --junitxml=junit/test-results.xml _unittest
pytest ${{ env.PYTEST_ARGUMENTS }} -n 4 --dist loadfile -m general
- uses: codecov/codecov-action@v4
with:
Expand All @@ -338,7 +360,7 @@ jobs:

package:
name: Package library
needs: [test-windows, test-solvers-windows, test-linux, test-solvers-linux, doc-build]
needs: [system-tests-general-windows, system-tests-general-linux, system-tests-solvers-windows, system-tests-solvers-linux, doc-build]
runs-on: ubuntu-latest
steps:
- name: Build library source and wheel artifacts
Expand Down
Loading

0 comments on commit dafbb23

Please sign in to comment.