From 8be236dc22c7fd887a77bea3325743a5b6e172b1 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Tue, 21 Jan 2025 15:42:35 +0100 Subject: [PATCH] ci: adding-profiling-to-unit-tests (#3676) * ci: adding profiling to pytest * fix: plugin registering * ci: adding graphviz to dependencies for profiling plotting * ci: adding prof file to gitignore * chore: adding changelog file 3676.dependencies.md [dependabot-skip] * chore: adding changelog file 3676.dependencies.md [dependabot-skip] * ci: adding library to minimal testing requirements when using minimal or console. * fix: not attaching prof files --------- Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> --- .ci/collect_mapdl_logs_locals.sh | 4 ++++ .ci/collect_mapdl_logs_remote.sh | 3 +++ .ci/requirements_minimal.txt | 1 + .github/workflows/ci.yml | 10 +++++----- .gitignore | 4 +++- doc/changelog.d/3676.dependencies.md | 1 + pyproject.toml | 1 + tests/conftest.py | 1 - 8 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 doc/changelog.d/3676.dependencies.md diff --git a/.ci/collect_mapdl_logs_locals.sh b/.ci/collect_mapdl_logs_locals.sh index 5b4eff1c4a..b6082b4f18 100755 --- a/.ci/collect_mapdl_logs_locals.sh +++ b/.ci/collect_mapdl_logs_locals.sh @@ -1,10 +1,14 @@ mkdir "$LOG_NAMES" && echo "Successfully generated directory $LOG_NAMES" +echo "Copying the log files..." cp *.log ./"$LOG_NAMES"/ || echo "No log files could be found" cp *apdl.out ./"$LOG_NAMES"/ || echo "No APDL log files could be found" cp *pymapdl.apdl ./"$LOG_NAMES"/ || echo "No PYMAPDL APDL log files could be found" +echo "Copying the profiling files..." +cp -r prof ./"$LOG_NAMES"/prof || echo "No profile files could be found" + ls -la ./"$LOG_NAMES" diff --git a/.ci/collect_mapdl_logs_remote.sh b/.ci/collect_mapdl_logs_remote.sh index 57ce2bedaf..b7311c357e 100755 --- a/.ci/collect_mapdl_logs_remote.sh +++ b/.ci/collect_mapdl_logs_remote.sh @@ -35,6 +35,9 @@ echo "Copying docker launch log..." cp mapdl_launch_0.log ./"$LOG_NAMES"/mapdl_launch_0.log || echo "MAPDL launch docker log not found." cp mapdl_launch_1.log ./"$LOG_NAMES"/mapdl_launch_1.log || echo "MAPDL launch docker log not found." +echo "Copying the profiling files..." +cp -r prof ./"$LOG_NAMES"/prof || echo "No profile files could be found" + echo "Collecting file structure..." ls -R > ./"$LOG_NAMES"/files_structure.txt || echo "Failed to copy file structure to a file" diff --git a/.ci/requirements_minimal.txt b/.ci/requirements_minimal.txt index 8d55e3ac3c..39430b2718 100644 --- a/.ci/requirements_minimal.txt +++ b/.ci/requirements_minimal.txt @@ -1,5 +1,6 @@ pyfakefs==5.7.2 pytest-cov==6.0.0 +pytest-profiling==1.8.1 pytest-random-order==1.1.1 pytest-rerunfailures==15.0 pytest-timeout==2.3.1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5251b30361..8a90f39a1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ env: DPF_PORT: 21004 MAPDL_PACKAGE: ghcr.io/ansys/mapdl ON_CI: True - PYTEST_ARGUMENTS: '-vvv -rxXsa --color=yes --durations=10 --random-order --random-order-bucket=class --maxfail=10 --reruns 3 --reruns-delay 4 --cov=ansys.mapdl.core --cov-report=html --timeout=180' + PYTEST_ARGUMENTS: '-vvv -rxXsa --color=yes --durations=30 --random-order --random-order-bucket=class --maxfail=10 --reruns 3 --reruns-delay 4 --cov=ansys.mapdl.core --cov-report=html --timeout=180 --profile-svg --profile' BUILD_CHEATSHEET: True PYMAPDL_DEBUG_TESTING: True @@ -513,7 +513,7 @@ jobs: - name: "Install os packages" run: | sudo apt update - sudo apt install libgl1-mesa-glx xvfb + sudo apt install libgl1-mesa-glx xvfb graphviz - name: "Test virtual framebuffer" run: | @@ -685,7 +685,7 @@ jobs: - name: "Install OS packages" run: | apt update - apt install -y libgl1-mesa-glx xvfb libgomp1 + apt install -y libgl1-mesa-glx xvfb libgomp1 graphviz - name: "Test virtual framebuffer" run: | @@ -827,7 +827,7 @@ jobs: - name: "Installing missing package" run: | sudo apt-get update - sudo apt-get install -y libgomp1 + sudo apt-get install -y libgomp1 graphviz - name: "Setup Python" uses: actions/setup-python@v5 @@ -957,7 +957,7 @@ jobs: - name: "Installing missing package" run: | sudo apt-get update - sudo apt-get install -y libgomp1 + sudo apt-get install -y libgomp1 graphviz - name: "Setup Python" uses: actions/setup-python@v5 diff --git a/.gitignore b/.gitignore index ee27c203f2..d36f8c19b8 100755 --- a/.gitignore +++ b/.gitignore @@ -79,7 +79,6 @@ docker/mapdl/v212 docker/mapdl/_old docker/mapdl/*.sh - # temp testing tmp.out @@ -101,3 +100,6 @@ doc/source/sg_execution_times.rst *prin-stresses.html doc/webserver.log doc/webserver.pid + +# Profiling +prof \ No newline at end of file diff --git a/doc/changelog.d/3676.dependencies.md b/doc/changelog.d/3676.dependencies.md new file mode 100644 index 0000000000..1fe6cb2913 --- /dev/null +++ b/doc/changelog.d/3676.dependencies.md @@ -0,0 +1 @@ +ci: adding-profiling-to-unit-tests \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 0d5b2e6dee..5db768103d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,6 +63,7 @@ tests = [ "pyfakefs==5.7.4", "pyiges[full]==0.3.1", "pytest-cov==6.0.0", + "pytest-profiling==1.8.1", "pytest-pyvista==0.1.9", "pytest-random-order==1.1.1", "pytest-rerunfailures==15.0", diff --git a/tests/conftest.py b/tests/conftest.py index 3f87e5fedd..e3c59e07e0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -57,7 +57,6 @@ # Setting testing environment # --------------------------- # - DEBUG_TESTING = debug_testing() TESTING_MINIMAL = testing_minimal()