From efad1ba9221178f651611356c65c7d478aedf026 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 13:29:09 +0100 Subject: [PATCH 01/40] feat: add GitHub Action for testing PyMAPDL with remote MAPDL instances --- .github/actions/test_remote/action.yml | 218 +++++++++++++++++++++++++ .github/workflows/ci.yml | 181 +------------------- 2 files changed, 224 insertions(+), 175 deletions(-) create mode 100644 .github/actions/test_remote/action.yml diff --git a/.github/actions/test_remote/action.yml b/.github/actions/test_remote/action.yml new file mode 100644 index 00000000000..929d5c86363 --- /dev/null +++ b/.github/actions/test_remote/action.yml @@ -0,0 +1,218 @@ + +name: | + Test PyMAPDL with remote MAPDL instances + +description: | + This action starts a MAPDL instance in a Docker container and runs the PyMAPDL test suite against it + +inputs: + + # Required inputs + + username: + description: | + Username for the GitHub container registry. + required: true + type: string + + password: + description: | + Password for the GitHub container registry. + required: true + type: string + + mapdl-version: + description: | + MAPDL version to test. + required: true + type: string + + codecov_token: + description: | + Token for Codecov. + required: true + type: string + + +runs: + using: "composite" + + steps: + - name: "Install Git and checkout project" + uses: actions/checkout@v4.2.2 + + - name: "Login in Github container registry" + uses: docker/login-action@v3.3.0 + with: + registry: ghcr.io + username: ${{ inputs.username }} + password: ${{ inputs.password }} + + - name: "Getting SMP/DMP mode" + id: distributed_mode + run: | + image=${{ inputs.mapdl-version }} + export distributed_mode="smp" + if [[ $image == *".1."* ]]; then + export distributed_mode="dmp"; + fi + echo "Distributed mode: $distributed_mode" + echo "distributed_mode=$(echo $distributed_mode)" >> $GITHUB_OUTPUT + + - name: "Get if running on Ubuntu" + id: ubuntu_check + run: | + if [[ "${{ inputs.mapdl-version }}" == *"ubuntu"* ]]; + then export ON_UBUNTU=true; export TAG_UBUNTU="ubuntu"; + else export ON_UBUNTU=false; export TAG_UBUNTU="centos"; + fi + echo "ON_UBUNTU: $ON_UBUNTU" + echo "TAG_UBUNTU: $TAG_UBUNTU" + echo "ON_UBUNTU=$(echo $ON_UBUNTU)" >> $GITHUB_OUTPUT + echo "TAG_UBUNTU=$(echo $TAG_UBUNTU)" >> $GITHUB_OUTPUT + + - name: "Get if running student version" + id: student_check + run: | + if [[ "${{ inputs.mapdl-version }}" == *"student"* ]]; + then export ON_STUDENT=true; export TAG_STUDENT="student"; + else export ON_STUDENT=false; export TAG_STUDENT="non-student"; + fi + echo "ON_STUDENT: $ON_STUDENT" + echo "TAG_STUDENT: $TAG_STUDENT" + echo "ON_STUDENT=$(echo $ON_STUDENT)" >> $GITHUB_OUTPUT + echo "TAG_STUDENT=$(echo $TAG_STUDENT)" >> $GITHUB_OUTPUT + + - name: "Pull, launch, and validate MAPDL service" + id: start_mapdl + env: + LICENSE_SERVER: ${{ inputs.LICENSE_SERVER }} + MAPDL_VERSION: ${{ inputs.mapdl-version }} + DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} + run: | + echo "Launching first MAPDL instance..." + export INSTANCE_NAME=MAPDL_0 + .ci/start_mapdl.sh &> mapdl_launch_0.log & export DOCKER_PID_0=$! + echo "Launching a second instance for MAPDL pool testing..." + export PYMAPDL_PORT=${{ env.PYMAPDL_PORT2 }} + export PYMAPDL_DB_PORT=${{ env.PYMAPDL_DB_PORT2 }} + export INSTANCE_NAME=MAPDL_1 + .ci/start_mapdl.sh &> mapdl_launch_1.log & export DOCKER_PID_1=$! + echo "Launching MAPDL service 0 at PID: $DOCKER_PID_0" + echo "Launching MAPDL service 1 at PID: $DOCKER_PID_2" + echo "DOCKER_PID_0=$(echo $DOCKER_PID_0)" >> $GITHUB_OUTPUT + echo "DOCKER_PID_1=$(echo $DOCKER_PID_1)" >> $GITHUB_OUTPUT + + - name: "DPF server activation" + run: | + $(docker pull ghcr.io/ansys/dpf-core:22.2dev && docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}.") & + + - name: "Getting files change filters" + uses: dorny/paths-filter@v3 + id: changes + with: + filters: | + workflows: + - '.github/workflows/**' + + - name: "Setup Python with cache" + uses: actions/setup-python@v5 + if: steps.changes.outputs.workflows != 'true' + with: + cache: 'pip' + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: "Setup Python without cache" + uses: actions/setup-python@v5 + if: steps.changes.outputs.workflows == 'true' + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: "Install os packages" + run: | + sudo apt update + sudo apt install libgl1-mesa-glx xvfb graphviz + + - name: "Test virtual framebuffer" + run: | + pip install -r .ci/requirements_test_xvfb.txt + xvfb-run python .ci/display_test.py + + - name: Install ansys-mapdl-core + run: | + python -m pip install build + python -m build + python -m pip install dist/*.whl + xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" + + - name: "Unit testing requirements installation" + run: | + python -m pip install .[tests] + + - name: "Waiting for the services to be up" + run: | + .ci/waiting_services.sh + + - name: "Unit testing" + env: + DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} + ON_UBUNTU: ${{ steps.ubuntu_check.outputs.ON_UBUNTU }} + ON_STUDENT: ${{ steps.student_check.outputs.ON_STUDENT }} + file_name: "${{ inputs.mapdl-version }}-remote" + run: | + echo "ON_UBUNTU: $ON_UBUNTU" + echo "ON_STUDENT: $ON_STUDENT" + xvfb-run pytest \ + ${{ env.PYTEST_ARGUMENTS }} \ + --ignore_image_cache \ + --report-log=$file_name.jsonl \ + --cov-report=xml:$file_name.xml + + - uses: codecov/codecov-action@v5 + name: "Upload coverage to Codecov" + with: + token: ${{ inputs.codecov_token }} # required + name: ${{ inputs.mapdl-version }}-remote.xml + flags: remote,${{ steps.ubuntu_check.outputs.TAG_UBUNTU }},${{ inputs.mapdl-version }},${{ steps.distributed_mode.outputs.distributed_mode }},${{ steps.student_check.outputs.TAG_STUDENT }} + + - name: Upload coverage artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.mapdl-version }}-remote.xml + path: ./${{ inputs.mapdl-version }}-remote.xml + + - name: "Check package" + run: | + pip install twine + twine check dist/* + + - name: "Upload wheel and binaries" + uses: actions/upload-artifact@v4 + with: + name: PyMAPDL-packages-${{ inputs.mapdl-version }} + path: dist/ + retention-days: 7 + + - name: "Collect logs on failure" + if: always() + env: + MAPDL_VERSION: ${{ inputs.mapdl-version }} + MAPDL_INSTANCE: MAPDL_0 + LOG_NAMES: logs-remote-${{ inputs.mapdl-version }} + run: | + .ci/collect_mapdl_logs_remote.sh + + - name: "Upload logs to GitHub" + if: always() + uses: actions/upload-artifact@v4 + with: + name: logs-remote-${{ inputs.mapdl-version }}.tgz + path: ./logs-remote-${{ inputs.mapdl-version }}.tgz + + - name: "Display files structure" + if: always() + env: + MAPDL_INSTANCE: MAPDL_0 + LOG_NAMES: logs-remote-${{ inputs.mapdl-version }} + run: | + .ci/display_logs_remote.sh \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ab9b203b6c..e44232a2efc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -415,189 +415,20 @@ jobs: PYMAPDL_START_INSTANCE: FALSE ON_LOCAL: FALSE ON_UBUNTU: FALSE + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} outputs: DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} steps: - - name: "Install Git and checkout project" - uses: actions/checkout@v4.2.2 - - - name: "Login in Github container registry" - uses: docker/login-action@v3.3.0 + - name: Run Pytest for ${{ matrix.mapdl-version }} on remote mode + uses: ansys/pymapdl/.github/actions/test_remote@${{ env.BRANCH_NAME }} with: - registry: ghcr.io + mapdl-version: ${{ matrix.mapdl-version }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: "Getting SMP/DMP mode" - id: distributed_mode - run: | - image=${{ matrix.mapdl-version }} - export distributed_mode="smp" - if [[ $image == *".1."* ]]; then - export distributed_mode="dmp"; - fi - echo "Distributed mode: $distributed_mode" - echo "distributed_mode=$(echo $distributed_mode)" >> $GITHUB_OUTPUT - - - name: "Get if running on Ubuntu" - id: ubuntu_check - run: | - if [[ "${{ matrix.mapdl-version }}" == *"ubuntu"* ]]; - then export ON_UBUNTU=true; export TAG_UBUNTU="ubuntu"; - else export ON_UBUNTU=false; export TAG_UBUNTU="centos"; - fi - echo "ON_UBUNTU: $ON_UBUNTU" - echo "TAG_UBUNTU: $TAG_UBUNTU" - echo "ON_UBUNTU=$(echo $ON_UBUNTU)" >> $GITHUB_OUTPUT - echo "TAG_UBUNTU=$(echo $TAG_UBUNTU)" >> $GITHUB_OUTPUT - - - name: "Get if running student version" - id: student_check - run: | - if [[ "${{ matrix.mapdl-version }}" == *"student"* ]]; - then export ON_STUDENT=true; export TAG_STUDENT="student"; - else export ON_STUDENT=false; export TAG_STUDENT="non-student"; - fi - echo "ON_STUDENT: $ON_STUDENT" - echo "TAG_STUDENT: $TAG_STUDENT" - echo "ON_STUDENT=$(echo $ON_STUDENT)" >> $GITHUB_OUTPUT - echo "TAG_STUDENT=$(echo $TAG_STUDENT)" >> $GITHUB_OUTPUT - - - name: "Pull, launch, and validate MAPDL service" - id: start_mapdl - env: - LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }} - MAPDL_VERSION: ${{ matrix.mapdl-version }} - DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} - run: | - echo "Launching first MAPDL instance..." - export INSTANCE_NAME=MAPDL_0 - .ci/start_mapdl.sh &> mapdl_launch_0.log & export DOCKER_PID_0=$! - echo "Launching a second instance for MAPDL pool testing..." - export PYMAPDL_PORT=${{ env.PYMAPDL_PORT2 }} - export PYMAPDL_DB_PORT=${{ env.PYMAPDL_DB_PORT2 }} - export INSTANCE_NAME=MAPDL_1 - .ci/start_mapdl.sh &> mapdl_launch_1.log & export DOCKER_PID_1=$! - echo "Launching MAPDL service 0 at PID: $DOCKER_PID_0" - echo "Launching MAPDL service 1 at PID: $DOCKER_PID_2" - echo "DOCKER_PID_0=$(echo $DOCKER_PID_0)" >> $GITHUB_OUTPUT - echo "DOCKER_PID_1=$(echo $DOCKER_PID_1)" >> $GITHUB_OUTPUT - - - name: "DPF server activation" - run: | - $(docker pull ghcr.io/ansys/dpf-core:22.2dev && docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}.") & - - - name: "Getting files change filters" - uses: dorny/paths-filter@v3 - id: changes - with: - filters: | - workflows: - - '.github/workflows/**' - - - name: "Setup Python with cache" - uses: actions/setup-python@v5 - if: steps.changes.outputs.workflows != 'true' - with: - cache: 'pip' - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: "Setup Python without cache" - uses: actions/setup-python@v5 - if: steps.changes.outputs.workflows == 'true' - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: "Install os packages" - run: | - sudo apt update - sudo apt install libgl1-mesa-glx xvfb graphviz - - - name: "Test virtual framebuffer" - run: | - pip install -r .ci/requirements_test_xvfb.txt - xvfb-run python .ci/display_test.py - - - name: Install ansys-mapdl-core - run: | - python -m pip install build - python -m build - python -m pip install dist/*.whl - xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" - - - name: "Unit testing requirements installation" - run: | - python -m pip install .[tests] - - - name: "Waiting for the services to be up" - run: | - .ci/waiting_services.sh - - - name: "Unit testing" - env: - DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} - ON_UBUNTU: ${{ steps.ubuntu_check.outputs.ON_UBUNTU }} - ON_STUDENT: ${{ steps.student_check.outputs.ON_STUDENT }} - file_name: "${{ matrix.mapdl-version }}-remote" - run: | - echo "ON_UBUNTU: $ON_UBUNTU" - echo "ON_STUDENT: $ON_STUDENT" - xvfb-run pytest \ - ${{ env.PYTEST_ARGUMENTS }} \ - --ignore_image_cache \ - --report-log=$file_name.jsonl \ - --cov-report=xml:$file_name.xml - - - uses: codecov/codecov-action@v5 - name: "Upload coverage to Codecov" - with: - token: ${{ secrets.CODECOV_TOKEN }} # required - name: ${{ matrix.mapdl-version }}-remote.xml - flags: remote,${{ steps.ubuntu_check.outputs.TAG_UBUNTU }},${{ matrix.mapdl-version }},${{ steps.distributed_mode.outputs.distributed_mode }},${{ steps.student_check.outputs.TAG_STUDENT }} - - - name: Upload coverage artifacts - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.mapdl-version }}-remote.xml - path: ./${{ matrix.mapdl-version }}-remote.xml - - - name: "Check package" - run: | - pip install twine - twine check dist/* - - - name: "Upload wheel and binaries" - uses: actions/upload-artifact@v4 - with: - name: PyMAPDL-packages-${{ matrix.mapdl-version }} - path: dist/ - retention-days: 7 - - - name: "Collect logs on failure" - if: always() - env: - MAPDL_VERSION: ${{ matrix.mapdl-version }} - MAPDL_INSTANCE: MAPDL_0 - LOG_NAMES: logs-remote-${{ matrix.mapdl-version }} - run: | - .ci/collect_mapdl_logs_remote.sh - - - name: "Upload logs to GitHub" - if: always() - uses: actions/upload-artifact@v4 - with: - name: logs-remote-${{ matrix.mapdl-version }}.tgz - path: ./logs-remote-${{ matrix.mapdl-version }}.tgz - - - name: "Display files structure" - if: always() - env: - MAPDL_INSTANCE: MAPDL_0 - LOG_NAMES: logs-remote-${{ matrix.mapdl-version }} - run: | - .ci/display_logs_remote.sh + codecov_token: ${{ secrets.CODECOV_TOKEN }} + license_server: ${{ secrets.LICENSE_SERVER }} build-test-local-minimal-matrix: name: "Build test matrix for minimal and local" From 53f97ca251d48b720f6006ec80c3586a73d14f29 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Thu, 6 Mar 2025 12:31:05 +0000 Subject: [PATCH 02/40] chore: adding changelog file 3785.maintenance.md [dependabot-skip] --- doc/changelog.d/3785.maintenance.md | 1 + doc/changelog.d/changelog_template.jinja | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 doc/changelog.d/3785.maintenance.md diff --git a/doc/changelog.d/3785.maintenance.md b/doc/changelog.d/3785.maintenance.md new file mode 100644 index 00000000000..aeaf2f52002 --- /dev/null +++ b/doc/changelog.d/3785.maintenance.md @@ -0,0 +1 @@ +feat: add GitHub Action for testing PyMAPDL with remote MAPDL instances \ No newline at end of file diff --git a/doc/changelog.d/changelog_template.jinja b/doc/changelog.d/changelog_template.jinja index a346bcd9d5b..3ca0146b8ab 100644 --- a/doc/changelog.d/changelog_template.jinja +++ b/doc/changelog.d/changelog_template.jinja @@ -1,17 +1,22 @@ {% if sections[""] %} -{% for category, val in definitions.items() if category in sections[""] %} -{{ definitions[category]['name'] }} -{% set underline = '^' * definitions[category]['name']|length %} -{{ underline }} +.. tab-set:: + +{%+ for category, val in definitions.items() if category in sections[""] %} + + .. tab-item:: {{ definitions[category]['name'] }} + + .. list-table:: + :header-rows: 0 + :widths: auto {% for text, values in sections[""][category].items() %} -- {{ text }} {{ values|join(', ') }} -{% endfor %} + * - {{ text }} + - {{ values|join(', ') }} {% endfor %} +{% endfor %} + {% else %} No significant changes. - - -{% endif %} \ No newline at end of file +{% endif %} From 55e4808e3da8d947d82ca2e7cb8d95e6930b0e2e Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 13:38:14 +0100 Subject: [PATCH 03/40] fix: update GitHub Action to use default branch for remote testing --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e44232a2efc..2c42d70586b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -415,14 +415,14 @@ jobs: PYMAPDL_START_INSTANCE: FALSE ON_LOCAL: FALSE ON_UBUNTU: FALSE - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + # BRANCH_NAME: ${{ github.head_ref || github.ref_name }} outputs: DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} steps: - name: Run Pytest for ${{ matrix.mapdl-version }} on remote mode - uses: ansys/pymapdl/.github/actions/test_remote@${{ env.BRANCH_NAME }} + uses: ansys/pymapdl/.github/actions/test_remote with: mapdl-version: ${{ matrix.mapdl-version }} username: ${{ github.actor }} From f7463dcb276fb773312ffdab2d4320deed142d51 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 13:46:20 +0100 Subject: [PATCH 04/40] feat: using file path --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c42d70586b..2cdcd1ef7f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -422,7 +422,7 @@ jobs: steps: - name: Run Pytest for ${{ matrix.mapdl-version }} on remote mode - uses: ansys/pymapdl/.github/actions/test_remote + uses: ./.github/actions/test_remote with: mapdl-version: ${{ matrix.mapdl-version }} username: ${{ github.actor }} From d1a20bcbd33d2e1aac0f6007d85e172b07bfe35a Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 13:46:46 +0100 Subject: [PATCH 05/40] fix: remove unused outputs from CI workflow --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2cdcd1ef7f6..0aa58d0e0e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -417,9 +417,6 @@ jobs: ON_UBUNTU: FALSE # BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - outputs: - DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} - steps: - name: Run Pytest for ${{ matrix.mapdl-version }} on remote mode uses: ./.github/actions/test_remote From 8e76c834c4d6649373892f51e5ebe305f53ee480 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 13:52:47 +0100 Subject: [PATCH 06/40] fix: restore Git installation step in CI workflow --- .github/actions/test_remote/action.yml | 3 --- .github/workflows/ci.yml | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/test_remote/action.yml b/.github/actions/test_remote/action.yml index 929d5c86363..9afbc3b6b96 100644 --- a/.github/actions/test_remote/action.yml +++ b/.github/actions/test_remote/action.yml @@ -38,9 +38,6 @@ runs: using: "composite" steps: - - name: "Install Git and checkout project" - uses: actions/checkout@v4.2.2 - - name: "Login in Github container registry" uses: docker/login-action@v3.3.0 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0aa58d0e0e3..44b28aa49bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -418,6 +418,9 @@ jobs: # BRANCH_NAME: ${{ github.head_ref || github.ref_name }} steps: + - name: "Install Git and checkout project" + uses: actions/checkout@v4.2.2 + - name: Run Pytest for ${{ matrix.mapdl-version }} on remote mode uses: ./.github/actions/test_remote with: From c5bab06293087c8735edf5613fb8f72c08326542 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 13:59:08 +0100 Subject: [PATCH 07/40] fix: set default shell to bash in GitHub Action for remote testing --- .github/actions/test_remote/action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/actions/test_remote/action.yml b/.github/actions/test_remote/action.yml index 9afbc3b6b96..522caa48f60 100644 --- a/.github/actions/test_remote/action.yml +++ b/.github/actions/test_remote/action.yml @@ -36,6 +36,9 @@ inputs: runs: using: "composite" + defaults: + run: + shell: bash steps: - name: "Login in Github container registry" From ac149101eb601da63905de3bac10fe466f002d2b Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 14:27:14 +0100 Subject: [PATCH 08/40] fix: enforce bash shell for all steps in remote testing action --- .github/actions/test_remote/action.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/actions/test_remote/action.yml b/.github/actions/test_remote/action.yml index 522caa48f60..27961b9c4c0 100644 --- a/.github/actions/test_remote/action.yml +++ b/.github/actions/test_remote/action.yml @@ -36,9 +36,6 @@ inputs: runs: using: "composite" - defaults: - run: - shell: bash steps: - name: "Login in Github container registry" @@ -50,6 +47,7 @@ runs: - name: "Getting SMP/DMP mode" id: distributed_mode + shell: bash run: | image=${{ inputs.mapdl-version }} export distributed_mode="smp" @@ -61,6 +59,7 @@ runs: - name: "Get if running on Ubuntu" id: ubuntu_check + shell: bash run: | if [[ "${{ inputs.mapdl-version }}" == *"ubuntu"* ]]; then export ON_UBUNTU=true; export TAG_UBUNTU="ubuntu"; @@ -73,6 +72,7 @@ runs: - name: "Get if running student version" id: student_check + shell: bash run: | if [[ "${{ inputs.mapdl-version }}" == *"student"* ]]; then export ON_STUDENT=true; export TAG_STUDENT="student"; @@ -89,6 +89,7 @@ runs: LICENSE_SERVER: ${{ inputs.LICENSE_SERVER }} MAPDL_VERSION: ${{ inputs.mapdl-version }} DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} + shell: bash run: | echo "Launching first MAPDL instance..." export INSTANCE_NAME=MAPDL_0 @@ -104,6 +105,7 @@ runs: echo "DOCKER_PID_1=$(echo $DOCKER_PID_1)" >> $GITHUB_OUTPUT - name: "DPF server activation" + shell: bash run: | $(docker pull ghcr.io/ansys/dpf-core:22.2dev && docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}.") & @@ -129,16 +131,19 @@ runs: python-version: ${{ env.MAIN_PYTHON_VERSION }} - name: "Install os packages" + shell: bash run: | sudo apt update sudo apt install libgl1-mesa-glx xvfb graphviz - name: "Test virtual framebuffer" + shell: bash run: | pip install -r .ci/requirements_test_xvfb.txt xvfb-run python .ci/display_test.py - name: Install ansys-mapdl-core + shell: bash run: | python -m pip install build python -m build @@ -146,10 +151,12 @@ runs: xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" - name: "Unit testing requirements installation" + shell: bash run: | python -m pip install .[tests] - name: "Waiting for the services to be up" + shell: bash run: | .ci/waiting_services.sh @@ -159,6 +166,7 @@ runs: ON_UBUNTU: ${{ steps.ubuntu_check.outputs.ON_UBUNTU }} ON_STUDENT: ${{ steps.student_check.outputs.ON_STUDENT }} file_name: "${{ inputs.mapdl-version }}-remote" + shell: bash run: | echo "ON_UBUNTU: $ON_UBUNTU" echo "ON_STUDENT: $ON_STUDENT" @@ -182,6 +190,7 @@ runs: path: ./${{ inputs.mapdl-version }}-remote.xml - name: "Check package" + shell: bash run: | pip install twine twine check dist/* @@ -199,6 +208,7 @@ runs: MAPDL_VERSION: ${{ inputs.mapdl-version }} MAPDL_INSTANCE: MAPDL_0 LOG_NAMES: logs-remote-${{ inputs.mapdl-version }} + shell: bash run: | .ci/collect_mapdl_logs_remote.sh @@ -214,5 +224,6 @@ runs: env: MAPDL_INSTANCE: MAPDL_0 LOG_NAMES: logs-remote-${{ inputs.mapdl-version }} + shell: bash run: | .ci/display_logs_remote.sh \ No newline at end of file From 035a598ba3f05009bf0f803a7ffbb8b12c5a14ff Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 16:50:55 +0100 Subject: [PATCH 09/40] ci: adding actions for local, windows, and summary. --- .github/actions/pytest-summary/action.yml | 63 +++ .github/actions/test-local/action.yml | 189 +++++++ .../{test_remote => test-remote}/action.yml | 14 +- .github/actions/test-windows/action.yml | 82 +++ .github/workflows/ci.yml | 467 ++---------------- 5 files changed, 380 insertions(+), 435 deletions(-) create mode 100644 .github/actions/pytest-summary/action.yml create mode 100644 .github/actions/test-local/action.yml rename .github/actions/{test_remote => test-remote}/action.yml (97%) create mode 100644 .github/actions/test-windows/action.yml diff --git a/.github/actions/pytest-summary/action.yml b/.github/actions/pytest-summary/action.yml new file mode 100644 index 00000000000..6f529d36496 --- /dev/null +++ b/.github/actions/pytest-summary/action.yml @@ -0,0 +1,63 @@ + +name: | + Pytest summary + +description: | + This action summarizes the duration of the tests and the standard deviation for all the jobs. + +inputs: + python-version: + description: | + Python version to use. + required: true + type: string + +runs: + using: "composite" + + steps: + + - name: "Setup Python with cache" + uses: actions/setup-python@v5 + with: + cache: 'pip' + python-version: ${{ inputs.python-version }} + + - name: "Install numpy" + shell: bash + run: python -m pip install numpy click + + - name: "Download artifacts" + uses: actions/download-artifact@v4 + with: + path: "artifacts" + + - name: "List directories" + shell: bash + run: | + echo "::group:: List directories:" && ls -Rla artifacts && echo "::endgroup::" + + - name: "Uncompress files" + shell: bash + run: | + find . -mindepth 1 -maxdepth 4 -type f -name 'logs-*.tgz' -exec tar -xzvf {} -C $(dirname {}) \; + + - name: "List directories" + shell: bash + run: | + echo "::group:: List directories:" && ls -Rla . && echo "::endgroup::" + + - name: "Create summary" + shell: bash + run: | + echo "# Test summary 🚀" >> $GITHUB_STEP_SUMMARY + echo -e "The followin tables show a summary of tests duration and standard desviation for all the jobs.\n" >> $GITHUB_STEP_SUMMARY + python .ci/pytest_summary.py --num 10 --save-file tests_durations.json >> summary.md + echo "$(cat summary.md)" >> $GITHUB_STEP_SUMMARY + cat summary.md + + - name: "Upload tests summary" + uses: actions/upload-artifact@v4 + with: + name: tests_durations.json + path: tests_durations.json \ No newline at end of file diff --git a/.github/actions/test-local/action.yml b/.github/actions/test-local/action.yml new file mode 100644 index 00000000000..778734629ac --- /dev/null +++ b/.github/actions/test-local/action.yml @@ -0,0 +1,189 @@ +name: "Local testing" + +description: | + This action tests PyMAPDL with MAPDL running locally. + It does support running with minimal requirements and with console interface. + +inputs: + + mapdl-version: + description: | + MAPDL version to test. + required: true + type: string + + license_server: + description: | + License server for ANSYS MAPDL + required: true + type: string + + minimal: + description: | + If true, the minimal requirements will be installed. + required: false + type: boolean + default: false + + pytest-arguments: + description: | + Arguments to pass to pytest, additionally to the ones in the environment variable PYTEST_ARGUMENTS. + required: false + type: string + default: "" + + file-name: + description: | + Name of the file to save the logs. + required: true + type: string + + codecov_token: + description: | + Token for Codecov. + required: true + type: string + + tags: + description: | + Tags to add to the coverage report. + required: true + type: string + + +runs: + using: "composite" + steps: + + - name: "Get if running student version" + id: student_check + shell: bash + run: | + if [[ "${{ inputs.mapdl-version }}" == *"student"* ]]; + then export ON_STUDENT=true; export TAG_STUDENT="student"; + else export ON_STUDENT=false; export TAG_STUDENT="non-student"; + fi + + echo "ON_STUDENT: $ON_STUDENT" + echo "TAG_STUDENT: $TAG_STUDENT" + echo "ON_STUDENT=$(echo $ON_STUDENT)" >> $GITHUB_OUTPUT + echo "TAG_STUDENT=$(echo $TAG_STUDENT)" >> $GITHUB_OUTPUT + + - name: "Installing OS packages" + shell: bash + run: | + sudo apt-get update && apt-get install -y libgomp1 graphviz + + - name: "Setup Python" + uses: actions/setup-python@v5 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: "Checking Python" + shell: bash + run: | + python --version + python -m pip install --upgrade pip + + - name: "Install ansys-mapdl-core" + if: ${{ !inputs.minimal }} + shell: bash + run: | + python -m pip install build + python -m build + python -m pip install dist/*.whl + xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" + + - name: "Install ansys-mapdl-core with minimal requirements" + shell: bash + if: ${{ inputs.minimal }} + run: | + python -m pip install . --no-deps + python -m pip install -r minimum_requirements.txt + python -c "from ansys.mapdl import core as pymapdl; print('Import successfull')" + + - name: "Unit testing requirements installation" + if: ${{ !inputs.minimal }} + shell: bash + run: | + python -m pip install .[tests] + + - name: "Unit testing requirements installation" + if: ${{ inputs.minimal }} + shell: bash + run: | + python -m pip install -r .ci/requirements_testing_minimal.txt + + - name: "Unit testing" + env: + ANSYSLMD_LICENSE_FILE: "1055@${{ inputs.license_server }}" + ON_STUDENT: ${{ steps.student_check.outputs.ON_STUDENT }} + file_name: ${{ inputs.file-name }} + ON_MINIMAL: ${{ inputs.minimal }} + shell: bash + run: | + echo "ON_UBUNTU: $ON_UBUNTU" + echo "ON_STUDENT: $ON_STUDENT" + + # Because there is no 'ansys-tools-path' we need to input the + # executable path with the env var: PYMAPDL_MAPDL_EXEC. + + if [[ "${{ inputs.mapdl-version }}" == *"latest-ubuntu"* ]] ; then + version=${{ env.LATEST_VERSION }} + else + version=$(echo "${{ inputs.mapdl-version }}" | head -c 5 | tail -c 4 | tr -d '.') + fi; + + echo "Version: $version" + + # If minimal is true, we need to set the executable path. + if [[ "${{ inputs.minimal }}" == "true" ]]; then + echo "PYMAPDL_MAPDL_EXEC: $PYMAPDL_MAPDL_EXEC" + export PYMAPDL_MAPDL_EXEC=/ansys_inc/v"$version"/ansys/bin/ansys"$version" + fi; + + unset PYMAPDL_START_INSTANCE + unset PYMAPDL_PORT + + pytest ${{ inputs.pytest-arguments }} \ + ${{ env.PYTEST_ARGUMENTS }} \ + --report-log=$file_name.jsonl \ + --cov-report=xml:$file_name.xml + + - name: "Collect logs on failure" + if: always() + env: + LOG_NAMES: logs-${{ inputs.file-name }} + shell: bash + run: | + .ci/collect_mapdl_logs_locals.sh + + - name: "Upload logs to GitHub" + if: always() + uses: actions/upload-artifact@master + with: + name: logs-${{ inputs.file-name }}.tgz + path: ./logs-${{ inputs.file-name }}.tgz + + - name: "Display files structure" + if: always() + env: + LOG_NAMES: logs-${{ inputs.file-name }} + shell: bash + run: | + .ci/display_logs_locals.sh + + - uses: codecov/codecov-action@v5 + name: "Upload coverage to Codecov" + with: + token: ${{ inputs.codecov_token }} # required + root_dir: ${{ github.workspace }} + name: ${{ inputs.file-name }}.xml + flags: ubuntu,local,${{ inputs.mapdl-version }},${{ inputs.tags }},${{ steps.student_check.outputs.TAG_STUDENT }},dmp + + - name: "Upload coverage artifacts" + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.file-name }}.xml + path: ./${{ inputs.file-name }}.xml + diff --git a/.github/actions/test_remote/action.yml b/.github/actions/test-remote/action.yml similarity index 97% rename from .github/actions/test_remote/action.yml rename to .github/actions/test-remote/action.yml index 27961b9c4c0..748459ef654 100644 --- a/.github/actions/test_remote/action.yml +++ b/.github/actions/test-remote/action.yml @@ -9,6 +9,12 @@ inputs: # Required inputs + mapdl-version: + description: | + MAPDL version to test. + required: true + type: string + username: description: | Username for the GitHub container registry. @@ -20,10 +26,10 @@ inputs: Password for the GitHub container registry. required: true type: string - - mapdl-version: + + license_server: description: | - MAPDL version to test. + License server for ANSYS MAPDL required: true type: string @@ -86,7 +92,7 @@ runs: - name: "Pull, launch, and validate MAPDL service" id: start_mapdl env: - LICENSE_SERVER: ${{ inputs.LICENSE_SERVER }} + LICENSE_SERVER: ${{ inputs.license_server }} MAPDL_VERSION: ${{ inputs.mapdl-version }} DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} shell: bash diff --git a/.github/actions/test-windows/action.yml b/.github/actions/test-windows/action.yml new file mode 100644 index 00000000000..4c1ae2f42f1 --- /dev/null +++ b/.github/actions/test-windows/action.yml @@ -0,0 +1,82 @@ + +name: | + Test Windows + +description: | + This action runs PyMAPDL tests on Windows + +inputs: + + # Required inputs + + codecov_token: + description: | + Token for Codecov. + required: true + type: string + +runs: + using: "composite" + steps: + + # Skipping because it is installed locally. + # - name: Setup Python + # uses: actions/setup-python@v5 + # with: + # python-version: 3.9 + + - name: "Checking Python" + shell: powershell + run: | + python -m pip install --upgrade pip + + - name: "Creating python venv" + shell: powershell + run: | + python -m venv .\.venv + .\.venv\Scripts\activate + + - name: "Install ansys-mapdl-core" + shell: powershell + run: | + python -m pip install build + python -m build + $FILE_=Resolve-Path '.\dist\*.whl' + python -m pip install $FILE_.Path --upgrade + python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" + + - name: "Unit testing requirements installation" + shell: powershell + run: | + python -m pip install .[tests] + + # - name: DPF Server Activation + # run: | + # docker pull ghcr.io/ansys/dpf-core:22.2dev + # docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}." + + - name: "Unit testing" + shell: powershell + env: + file_name: windows-v22.2.0-local + run: | + set PYMAPDL_PORT= + set PYMAPDL_START_INSTANCE= + python -m pytest -k "not test_database and not test_dpf" \ + ${{ env.PYTEST_ARGUMENTS }} \ + --ignore_image_cache \ + --report-log=$file_name.jsonl \ + --cov-report=xml:$file_name.xml + + - uses: codecov/codecov-action@v5 + name: "Upload coverage to Codecov" + with: + token: ${{ inputs.codecov_token }} # required + name: windows-v22.2.0-local.xml + flags: windows,local,v22.2.0 + + - name: "Upload coverage artifacts" + uses: actions/upload-artifact@v4 + with: + name: windows-v22.2.0-local.xml + path: ./windows_local.xml \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44b28aa49bd..5b8bd9070cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -490,134 +490,16 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} - - name: "Get if running student version" - id: student_check - run: | - if [[ "${{ matrix.mapdl-version }}" == *"student"* ]]; - then export ON_STUDENT=true; export TAG_STUDENT="student"; - else export ON_STUDENT=false; export TAG_STUDENT="non-student"; - fi - - echo "ON_STUDENT: $ON_STUDENT" - echo "TAG_STUDENT: $TAG_STUDENT" - echo "ON_STUDENT=$(echo $ON_STUDENT)" >> $GITHUB_OUTPUT - echo "TAG_STUDENT=$(echo $TAG_STUDENT)" >> $GITHUB_OUTPUT - - - name: "Setup Python" - uses: actions/setup-python@v5 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: "Checking Python" - run: | - python --version - python -m pip install --upgrade pip - python -m venv ./.venv - source ./.venv/bin/activate - - - name: "Install OS packages" - run: | - apt update - apt install -y libgl1-mesa-glx xvfb libgomp1 graphviz - - - name: "Test virtual framebuffer" - run: | - python -m pip install -r .ci/requirements_test_xvfb.txt - xvfb-run python .ci/display_test.py - - - name: "Install ansys-mapdl-core" - run: | - python -m pip install build - python -m build - python -m pip install dist/*.whl - xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" - - - name: "Unit testing requirements installation" - run: | - python -m pip install .[tests] - - - name: "Unit testing" - env: - ANSYSLMD_LICENSE_FILE: "1055@${{ secrets.LICENSE_SERVER }}" - ON_STUDENT: ${{ steps.student_check.outputs.ON_STUDENT }} - file_name: "${{ matrix.mapdl-version }}-local" - run: | - echo "ON_UBUNTU: $ON_UBUNTU" - echo "ON_STUDENT: $ON_STUDENT" - unset PYMAPDL_PORT - unset PYMAPDL_START_INSTANCE - xvfb-run pytest -k "not test_dpf" \ - ${{ env.PYTEST_ARGUMENTS }} \ - --reset_only_failed \ - --add_missing_images \ - --report-log=$file_name.jsonl \ - --cov-report=xml:$file_name.xml - - - name: "Collect logs on failure" - if: always() - env: - LOG_NAMES: logs-local-${{ matrix.mapdl-version }} - run: | - .ci/collect_mapdl_logs_locals.sh - - - name: "Upload logs to GitHub" - if: always() - uses: actions/upload-artifact@master - with: - name: logs-local-${{ matrix.mapdl-version }}.tgz - path: ./logs-local-${{ matrix.mapdl-version }}.tgz - - - name: "Display files structure" - if: always() - env: - LOG_NAMES: logs-local-${{ matrix.mapdl-version }} - run: | - .ci/display_logs_locals.sh - - - name: "Adding the directory as safe directory for later step" - run: | - git config --global --add safe.directory $GITHUB_WORKSPACE - - - name: "Attaching modified files to PR" - id: attatch-to-pr - uses: EndBug/add-and-commit@v9 - with: - message: "chore: update the image cache" - committer_name: GitHub Actions - committer_email: actions@github.com - add: './tests/.image_cache/*.png' - - - name: "PR comment with reactions" - if: ${{ steps.attatch-to-pr.outputs.pushed == 'true' }} - uses: thollander/actions-comment-pull-request@v3 - with: - message: | - Hello! :wave: - - Your PR is changing the image cache. So I am attaching the new image cache in a new [commit](https://github.com/ansys/pymapdl/commit/${{ steps.attatch-to-pr.outputs.commit_long_sha }}). - - This commit does not re-run the CICD workflows (since no changes are made in the codebase) therefore you will see the actions showing in their status `Expected — Waiting for status to be reported`. Do not worry. You commit workflow is still running [here](https://github.com/ansys/pymapdl/pull/${{ github.event.pull_request.number }}/checks?sha=${{ github.event.pull_request.head.sha }}) :smile: - - You might want to rerun the test to make sure that everything is passing. You can retrigger the CICD sending an empty commit `git commit -m "chore: empty comment to trigger CICD" --allow-empty`. - - You will see this message everytime your commit changes the image cache but you are not attaching the updated cache. :nerd_face: - - reactions: rocket - - - uses: codecov/codecov-action@v5 - name: "Upload coverage to Codecov" + - name: "Run pytest on local" + uses: ./.github/actions/test-local with: - token: ${{ secrets.CODECOV_TOKEN }} # required - root_dir: ${{ github.workspace }} - name: ${{ matrix.mapdl-version }}-local.xml - flags: ubuntu,local,${{ matrix.mapdl-version }},${{ steps.student_check.outputs.TAG_STUDENT }},dmp - - - name: "Upload coverage artifacts" - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.mapdl-version }}-local.xml - path: ./${{ matrix.mapdl-version }}-local.xml - + mapdl-version: ${{ matrix.mapdl-version }} + minimal: false + license_server: ${{ secrets.LICENSE_SERVER }} + pytest-arguments: '-k "not test_dpf" --reset_only_failed --add_missing_images' + file-name: "${{ matrix.mapdl-version }}-local" + tags: "local" + codecov_token: ${{ secrets.CODECOV_TOKEN }} build-test-ubuntu-minimal: name: "Local-min: ${{ matrix.mapdl-version }}" @@ -647,108 +529,16 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} - - name: "Get if running student version" - id: student_check - run: | - if [[ "${{ matrix.mapdl-version }}" == *"student"* ]]; - then export ON_STUDENT=true; export TAG_STUDENT="student"; - else export ON_STUDENT=false; export TAG_STUDENT="non-student"; - fi - - echo "ON_STUDENT: $ON_STUDENT" - echo "TAG_STUDENT: $TAG_STUDENT" - echo "ON_STUDENT=$(echo $ON_STUDENT)" >> $GITHUB_OUTPUT - echo "TAG_STUDENT=$(echo $TAG_STUDENT)" >> $GITHUB_OUTPUT - - - name: "Installing missing package" - run: | - sudo apt-get update - sudo apt-get install -y libgomp1 graphviz - - - name: "Setup Python" - uses: actions/setup-python@v5 + - name: "Run Pytest for ${{ matrix.mapdl-version }} on local mode using minimal configuration" + uses: ./.github/actions/test-local with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: "Checking Python" - run: | - python --version - python -m pip install --upgrade pip - - - name: "Install ansys-mapdl-core" - run: | - python -m pip install . --no-deps - python -m pip install -r minimum_requirements.txt - python -c "from ansys.mapdl import core as pymapdl; print('Import successfull')" - - - name: "Unit testing requirements installation" - run: | - python -m pip install -r .ci/requirements_testing_minimal.txt - - - name: "Unit testing" - env: - ANSYSLMD_LICENSE_FILE: "1055@${{ secrets.LICENSE_SERVER }}" - ON_STUDENT: ${{ steps.student_check.outputs.ON_STUDENT }} - file_name: "${{ matrix.mapdl-version }}-minimal" - run: | - echo "ON_UBUNTU: $ON_UBUNTU" - echo "ON_STUDENT: $ON_STUDENT" - - # Because there is no 'ansys-tools-path' we need to input the - # executable path with the env var: PYMAPDL_MAPDL_EXEC. - - if [[ "${{ matrix.mapdl-version }}" == *"latest-ubuntu"* ]] ; then - version=${{ env.LATEST_VERSION }} - else - version=$(echo "${{ matrix.mapdl-version }}" | head -c 5 | tail -c 4 | tr -d '.') - fi; - - echo "Version: $version" - - export PYMAPDL_MAPDL_EXEC=/ansys_inc/v"$version"/ansys/bin/ansys"$version" - echo "$PYMAPDL_MAPDL_EXEC" - - unset PYMAPDL_START_INSTANCE - pytest -k "not test_dpf" \ - ${{ env.PYTEST_ARGUMENTS }} \ - --report-log=$file_name.jsonl \ - --cov-report=xml:$file_name.xml - - - name: "Collect logs on failure" - if: always() - env: - LOG_NAMES: logs-minimal-${{ matrix.mapdl-version }} - run: | - .ci/collect_mapdl_logs_locals.sh - - - name: "Upload logs to GitHub" - if: always() - uses: actions/upload-artifact@master - with: - name: logs-minimal-${{ matrix.mapdl-version }}.tgz - path: ./logs-minimal-${{ matrix.mapdl-version }}.tgz - - - name: "Display files structure" - if: always() - env: - LOG_NAMES: logs-minimal-${{ matrix.mapdl-version }} - run: | - .ci/display_logs_locals.sh - - - uses: codecov/codecov-action@v5 - name: "Upload coverage to Codecov" - with: - token: ${{ secrets.CODECOV_TOKEN }} # required - root_dir: ${{ github.workspace }} - name: ${{ matrix.mapdl-version }}-minimal.xml - flags: ubuntu,local,${{ matrix.mapdl-version }},minimal,${{ steps.student_check.outputs.TAG_STUDENT }},dmp - - - name: "Upload coverage artifacts" - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.mapdl-version }}-minimal.xml - path: ./${{ matrix.mapdl-version }}-minimal.xml - + mapdl-version: ${{ matrix.mapdl-version }} + minimal: true + license_server: ${{ secrets.LICENSE_SERVER }} + pytest-arguments: '-k "not test_dpf"' + file-name: "${{ matrix.mapdl-version }}-minimal" + tags: "local,minimal" + codecov_token: ${{ secrets.CODECOV_TOKEN }} build-test-ubuntu-console: name: "Local-min-console: ${{ matrix.mapdl-version }}" @@ -779,109 +569,17 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} - - name: "Get if running student version" - id: student_check - run: | - if [[ "${{ matrix.mapdl-version }}" == *"student"* ]]; - then export ON_STUDENT=true; export TAG_STUDENT="student"; - else export ON_STUDENT=false; export TAG_STUDENT="non-student"; - fi - - echo "ON_STUDENT: $ON_STUDENT" - echo "TAG_STUDENT: $TAG_STUDENT" - echo "ON_STUDENT=$(echo $ON_STUDENT)" >> $GITHUB_OUTPUT - echo "TAG_STUDENT=$(echo $TAG_STUDENT)" >> $GITHUB_OUTPUT - - - name: "Installing missing package" - run: | - sudo apt-get update - sudo apt-get install -y libgomp1 graphviz - - - name: "Setup Python" - uses: actions/setup-python@v5 + - name: "Run Pytest for ${{ matrix.mapdl-version }} on local mode using console configuration" + uses: ./.github/actions/test-local with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: "Checking Python" - run: | - python --version - python -m pip install --upgrade pip - - - name: "Install ansys-mapdl-core" - run: | - python -m pip install . --no-deps - python -m pip install -r minimum_requirements.txt - python -c "from ansys.mapdl import core as pymapdl; print('Import successfull')" - - - name: "Unit testing requirements installation" - run: | - python -m pip install -r .ci/requirements_testing_minimal.txt - - - name: "Unit testing" - env: - ANSYSLMD_LICENSE_FILE: "1055@${{ secrets.LICENSE_SERVER }}" - ON_STUDENT: ${{ steps.student_check.outputs.ON_STUDENT }} - file_name: "${{ matrix.mapdl-version }}-minimal-console" - run: | - echo "ON_UBUNTU: $ON_UBUNTU" - echo "ON_STUDENT: $ON_STUDENT" - - # Because there is no 'ansys-tools-path' we need to input the - # executable path with the env var: PYMAPDL_MAPDL_EXEC. - - if [[ "${{ matrix.mapdl-version }}" == *"latest-ubuntu"* ]] ; then - version=${{ env.LATEST_VERSION }} - else - version=$(echo "${{ matrix.mapdl-version }}" | head -c 5 | tail -c 4 | tr -d '.') - fi; - - echo "Version: $version" - - export PYMAPDL_MAPDL_EXEC=/ansys_inc/v"$version"/ansys/bin/ansys"$version" - echo "$PYMAPDL_MAPDL_EXEC" - - unset PYMAPDL_START_INSTANCE - pytest -k "console" \ - ${{ env.PYTEST_ARGUMENTS }} \ - --report-log=$file_name.jsonl \ - --cov-report=xml:$file_name.xml - - - name: "Collect logs on failure" - if: always() - env: - LOG_NAMES: logs-minimal-console-${{ matrix.mapdl-version }} - run: | - .ci/collect_mapdl_logs_locals.sh - - - name: "Upload logs to GitHub" - if: always() - uses: actions/upload-artifact@master - with: - name: logs-minimal-console-${{ matrix.mapdl-version }}.tgz - path: ./logs-minimal-console-${{ matrix.mapdl-version }}.tgz - - - name: "Display files structure" - if: always() - env: - LOG_NAMES: logs-minimal-console-${{ matrix.mapdl-version }} - run: | - .ci/display_logs_locals.sh - - - uses: codecov/codecov-action@v5 - name: "Upload coverage to Codecov" - with: - token: ${{ secrets.CODECOV_TOKEN }} # required - root_dir: ${{ github.workspace }} - name: ${{ matrix.mapdl-version }}-minimal-console.xml - flags: ubuntu,local,${{ matrix.mapdl-version }},minimal,console,${{ steps.student_check.outputs.TAG_STUDENT }},dmp - - - name: "Upload coverage artifacts" - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.mapdl-version }}-minimal-console.xml - path: ./${{ matrix.mapdl-version }}-minimal-console.xml - - + mapdl-version: ${{ matrix.mapdl-version }} + minimal: true + license_server: ${{ secrets.LICENSE_SERVER }} + pytest-arguments: '-k console' + file-name: "${{ matrix.mapdl-version }}-minimal-console" + tags: "local,minimal,console" + codecov_token: ${{ secrets.CODECOV_TOKEN }} + test-windows: # Skipped if: github.repository == '' @@ -894,67 +592,9 @@ jobs: steps: - uses: actions/checkout@v4.2.2 - # Skipping because it is installed locally. - # - name: Setup Python - # uses: actions/setup-python@v5 - # with: - # python-version: 3.9 - - - name: "Checking Python" - shell: powershell - run: | - python -m pip install --upgrade pip - - - name: "Creating python venv" - shell: powershell - run: | - python -m venv .\.venv - .\.venv\Scripts\activate - - - name: "Install ansys-mapdl-core" - shell: powershell - run: | - python -m pip install build - python -m build - $FILE_=Resolve-Path '.\dist\*.whl' - python -m pip install $FILE_.Path --upgrade - python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" - - - name: "Unit testing requirements installation" - shell: powershell - run: | - python -m pip install .[tests] - - # - name: DPF Server Activation - # run: | - # docker pull ghcr.io/ansys/dpf-core:22.2dev - # docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}." - - - name: "Unit testing" - shell: powershell - env: - file_name: windows-v22.2.0-local - run: | - set PYMAPDL_PORT= - set PYMAPDL_START_INSTANCE= - python -m pytest -k "not test_database and not test_dpf" \ - ${{ env.PYTEST_ARGUMENTS }} \ - --ignore_image_cache \ - --report-log=$file_name.jsonl \ - --cov-report=xml:$file_name.xml - - - uses: codecov/codecov-action@v5 - name: "Upload coverage to Codecov" - with: - token: ${{ secrets.CODECOV_TOKEN }} # required - name: windows-v22.2.0-local.xml - flags: windows,local,v22.2.0 - - - name: "Upload coverage artifacts" - uses: actions/upload-artifact@v4 + - uses: ./.github/actions/test_windows with: - name: windows-v22.2.0-local.xml - path: ./windows_local.xml + codecov_token: ${{ secrets.CODECOV_TOKEN }} package: @@ -991,6 +631,7 @@ jobs: with: library-name: ${{ env.PACKAGE_NAME }} additional-artifacts: "minimum_requirements.txt" + token: ${{ secrets.GITHUB_TOKEN }} - name: "Display structure of downloaded files" run: ls -Rla @@ -1075,52 +716,16 @@ jobs: run: | using Pkg; Pkg.add("PyCall");using PyCall;pymapdl = pyimport("ansys.mapdl.core");print(pymapdl.__version__) - pytest-summary: name: Pytest summary for all the test jobs - needs: [build-test-remote, build-test-ubuntu-local, build-test-ubuntu-minimal, build-test-ubuntu-console] + needs: [ + build-test-remote, build-test-ubuntu-local, build-test-ubuntu-minimal, build-test-ubuntu-console + ] if: always() runs-on: ubuntu-22.04 steps: - name: "Install Git and checkout project" uses: actions/checkout@v4.2.2 - - name: "Setup Python with cache" - uses: actions/setup-python@v5 - with: - cache: 'pip' - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: "Install numpy" - run: python -m pip install numpy click - - - name: "Download artifacts" - uses: actions/download-artifact@v4 - with: - path: "artifacts" - - - name: "List directories" - run: | - echo "::group:: List directories:" && ls -Rla artifacts && echo "::endgroup::" - - - name: "Uncompress files" - run: | - find . -mindepth 1 -maxdepth 4 -type f -name 'logs-*.tgz' -exec tar -xzvf {} -C $(dirname {}) \; - - - name: "List directories" - run: | - echo "::group:: List directories:" && ls -Rla . && echo "::endgroup::" - - - name: "Create summary" - run: | - echo "# Test summary 🚀" >> $GITHUB_STEP_SUMMARY - echo -e "The followin tables show a summary of tests duration and standard desviation for all the jobs.\n" >> $GITHUB_STEP_SUMMARY - python .ci/pytest_summary.py --num 10 --save-file tests_durations.json >> summary.md - echo "$(cat summary.md)" >> $GITHUB_STEP_SUMMARY - cat summary.md - - - name: "Upload tests summary" - uses: actions/upload-artifact@v4 - with: - name: tests_durations.json - path: tests_durations.json \ No newline at end of file + - name: "Run Pytest-summary action" + uses: ./.github/actions/pytest-summary \ No newline at end of file From 4db1090a80cb0171b978643fe2d5796e218153fa Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 17:15:39 +0100 Subject: [PATCH 10/40] fix: update conditionals for minimal input in local testing action --- .github/actions/test-local/action.yml | 8 ++++---- .github/workflows/ci.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/actions/test-local/action.yml b/.github/actions/test-local/action.yml index 778734629ac..232f4d29e6d 100644 --- a/.github/actions/test-local/action.yml +++ b/.github/actions/test-local/action.yml @@ -86,7 +86,7 @@ runs: python -m pip install --upgrade pip - name: "Install ansys-mapdl-core" - if: ${{ !inputs.minimal }} + if: inputs.minimal == 'false' shell: bash run: | python -m pip install build @@ -96,20 +96,20 @@ runs: - name: "Install ansys-mapdl-core with minimal requirements" shell: bash - if: ${{ inputs.minimal }} + if: inputs.minimal == 'true' run: | python -m pip install . --no-deps python -m pip install -r minimum_requirements.txt python -c "from ansys.mapdl import core as pymapdl; print('Import successfull')" - name: "Unit testing requirements installation" - if: ${{ !inputs.minimal }} + if: inputs.minimal == 'false' shell: bash run: | python -m pip install .[tests] - name: "Unit testing requirements installation" - if: ${{ inputs.minimal }} + if: inputs.minimal == 'true' shell: bash run: | python -m pip install -r .ci/requirements_testing_minimal.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b8bd9070cf..b8c7fa90332 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -422,7 +422,7 @@ jobs: uses: actions/checkout@v4.2.2 - name: Run Pytest for ${{ matrix.mapdl-version }} on remote mode - uses: ./.github/actions/test_remote + uses: ./.github/actions/test-remote with: mapdl-version: ${{ matrix.mapdl-version }} username: ${{ github.actor }} From c7bf5c00160bec06a6a987f79354646d68cc0e46 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 17:46:48 +0100 Subject: [PATCH 11/40] feat: add GitHub Actions for Julia testing, remote matrix build, and documentation build --- .github/actions/build-matrix/action.yml | 66 ++++++ .github/actions/doc-build/action.yml | 228 +++++++++++++++++++ .github/actions/test-julia/action.yml | 36 +++ .github/workflows/ci.yml | 282 ++---------------------- 4 files changed, 354 insertions(+), 258 deletions(-) create mode 100644 .github/actions/build-matrix/action.yml create mode 100644 .github/actions/doc-build/action.yml create mode 100644 .github/actions/test-julia/action.yml diff --git a/.github/actions/build-matrix/action.yml b/.github/actions/build-matrix/action.yml new file mode 100644 index 00000000000..7831a6d0ebc --- /dev/null +++ b/.github/actions/build-matrix/action.yml @@ -0,0 +1,66 @@ +name: "Build remote matrix for testing" + +description: | + This action builds the matrix for remote testing of PyMAPDL. + +inputs: + token_teams_user_read: + description: | + Token for reading user teams. + required: true + type: string + + local: + description: | + If true, the building matrix for local testing + required: false + type: boolean + default: true + + run_all_builds: + description: | + If true, run all extended MAPDL build tests. + required: false + type: boolean + default: false + +runs: + using: "composite" + steps: + - name: Get event type and user to check permissions. + id: get_user + env: + type_event: ${{ github.event.issue.pull_request }} + run: | + if [[ $type_event ]]; then + echo "Event type: $type_event" + echo "event_type=$( echo "$type_event" )" >> $GITHUB_OUTPUT + export user=${{ github.event.pull_request.user.login }} + else + export user=${{ github.actor }} + fi + echo "This PR has been opened by: $user" + echo "user=$( echo "$user" )" >> $GITHUB_OUTPUT + + - uses: tspascoal/get-user-teams-membership@v3 + id: is_organization_member + if: ${{ github.actor != 'dependabot[bot]' }} + with: + username: ${{ steps.get_user.outputs.user }} + organization: ansys + team: 'pymapdl-developers' + GITHUB_TOKEN: ${{ inputs.token_teams_user_read }} + + - id: set-matrix + if: inputs.local == 'false' + env: + auth_user: ${{ steps.is_organization_member.outputs.isTeamMember == 'true' || github.actor == 'dependabot[bot]' }} + ON_REMOTE: ${{ inputs.local == 'false' }} + ONLY_UBUNTU: ${{ input.local == 'true' }} + ON_SCHEDULE: ${{ github.event_name == 'schedule' }} + ON_WORKFLOW_DISPATCH: ${{ github.event_name == 'workflow_dispatch' }} + RUN_ALL_TEST: ${{ inputs.run_all_builds == 'true' }} + ON_PUSH: ${{ github.event_name == 'push' }} + HAS_TAG: ${{ contains(github.ref, 'refs/tags') }} + LIMIT_VERSIONS: 2 + run: .ci/build_matrix.sh diff --git a/.github/actions/doc-build/action.yml b/.github/actions/doc-build/action.yml new file mode 100644 index 00000000000..18b70292c24 --- /dev/null +++ b/.github/actions/doc-build/action.yml @@ -0,0 +1,228 @@ +name: "Documentation Build" + +description: | + This action builds the documentation for PyMAPDL. + +inputs: + + license_server: + description: | + License server for ANSYS MAPDL + required: true + type: string + + username: + description: | + Username for the GitHub container registry. + required: true + type: string + + password: + description: | + Password for the GitHub container registry. + required: true + type: string + +runs: + using: "composite" + steps: + + - name: "Login in Github container registry" + uses: docker/login-action@v3.3.0 + with: + registry: ghcr.io + username: ${{ inputs.username }} + password: ${{ inputs.password }} + + - name: "Pull, launch, and validate MAPDL service" + id: start_mapdl + env: + LICENSE_SERVER: ${{ inputs.license_server }} + MAPDL_VERSION: ${{ env.MAPDL_IMAGE_VERSION_DOCS_BUILD }} + DISTRIBUTED_MODE: "dmp" + shell: bash + run: | + export INSTANCE_NAME=MAPDL_0 + .ci/start_mapdl.sh &> mapdl_launch.log & export DOCKER_PID=$! + echo "Launching MAPDL service at PID: $DOCKER_PID" + echo "DOCKER_PID=$(echo $DOCKER_PID)" >> $GITHUB_OUTPUT + + - name: "DPF server activation" + shell: bash + run: | + $(docker pull ghcr.io/ansys/dpf-core:22.2dev && docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}.") & + + - name: "Getting files change filters" + uses: dorny/paths-filter@v3 + id: changes + with: + filters: | + workflows: + - '.github/workflows/**' + - 'pyproject.toml' + examples: + - 'examples/**' + - 'pyproject.toml' + documentation: + - 'examples/**' + - 'doc/**' + - 'pyproject.toml' + + - name: "Setup Python with cache" + uses: actions/setup-python@v5 + if: steps.changes.outputs.workflows != 'true' + with: + cache: 'pip' + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: "Setup Python without cache" + uses: actions/setup-python@v5 + if: steps.changes.outputs.workflows == 'true' + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: "Install OS packages" + shell: bash + run: | + sudo apt update + sudo apt install zip pandoc libgl1-mesa-glx xvfb texlive-latex-extra latexmk graphviz texlive-xetex texlive-fonts-extra qpdf xindy + + - name: "Test virtual framebuffer" + shell: bash + run: | + pip install -r .ci/requirements_test_xvfb.txt + xvfb-run python .ci/display_test.py + + - name: "Install ansys-mapdl-core" + shell: bash + run: | + pip install . + xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" + + - name: "Retrieve PyMAPDL version" + id: version + shell: bash + run: | + echo "PYMAPDL_VERSION=$(python -c 'from ansys.mapdl.core import __version__; print(__version__)')" >> $GITHUB_OUTPUT + echo "PyMAPDL version is: $(python -c "from ansys.mapdl.core import __version__; print(__version__)")" + + - name: "Cache examples" + uses: actions/cache@v4 + if: steps.changes.outputs.documentation == 'false' || (github.ref == 'refs/heads/main' && !contains(github.ref, 'refs/tags')) + with: + path: doc/source/examples + key: Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }} + restore-keys: | + Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }} + + - name: "Cache docs build directory" + uses: actions/cache@v4 + if: steps.changes.outputs.documentation == 'false' || (github.ref == 'refs/heads/main' && !contains(github.ref, 'refs/tags')) + with: + path: doc/_build + key: doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }} + restore-keys: | + doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }} + + - name: "Cache autosummary" + uses: actions/cache@v4 + if: steps.changes.outputs.documentation == 'false' || (github.ref == 'refs/heads/main' && !contains(github.ref, 'refs/tags')) + with: + path: doc/source/**/_autosummary/*.rst + key: autosummary-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }} + restore-keys: | + autosummary-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }} + + - name: "Install docs build requirements" + shell: bash + run: | + pip uninstall ansys-sphinx-theme + pip install .[doc] + + - name: "Waiting for the services to be up" + shell: bash + run: | + .ci/waiting_services.sh + + - name: Install Quarto + uses: quarto-dev/quarto-actions/setup@v2 + with: + tinytex: true + + - name: Check Quarto Version + shell: bash + run: | + quarto --version + + - name: "Install Poppler for PDF to PNG conversion" + shell: bash + run: | + sudo apt-get update + sudo apt-get install -y poppler-utils + + - name: "Build documentation" + shell: bash + run: | + xvfb-run make -C doc html SPHINXOPTS="-j auto -W --keep-going" + + - name: "Substitute defective GIF" + shell: bash + run: | + .ci/substitute_defective_gif.sh + + - name: "Upload HTML Documentation" + uses: actions/upload-artifact@v4 + with: + name: documentation-html + path: doc/_build/html + retention-days: 7 + + - name: "Build PDF Documentation" + working-directory: doc + shell: bash + run: make pdf + + - name: "Show latex dir" + working-directory: doc + shell: bash + run: ls _build/latex + + - name: "Upload PDF documentation" + uses: actions/upload-artifact@v4 + with: + name: documentation-pdf + path: doc/_build/latex/pymapdl*.pdf + retention-days: 7 + + - name: "Upload minimal requirements file" + # To include it in the release + uses: actions/upload-artifact@v4 + with: + name: minimum_requirements.txt + path: ./minimum_requirements.txt + + - name: "Collect logs on failure" + if: always() + env: + MAPDL_VERSION: ${{ env.MAPDL_IMAGE_VERSION_DOCS_BUILD }} + MAPDL_INSTANCE: MAPDL_0 + LOG_NAMES: logs-build-docs + shell: bash + run: | + .ci/collect_mapdl_logs_remote.sh + + - name: "Upload logs to GitHub" + if: always() + uses: actions/upload-artifact@master + with: + name: logs-build-docs.tgz + path: ./logs-build-docs.tgz + + - name: "Display files structure" + if: always() + env: + MAPDL_INSTANCE: MAPDL_0 + LOG_NAMES: logs-build-docs + shell: bash + run: | + .ci/display_logs_remote.sh \ No newline at end of file diff --git a/.github/actions/test-julia/action.yml b/.github/actions/test-julia/action.yml new file mode 100644 index 00000000000..86d4491a169 --- /dev/null +++ b/.github/actions/test-julia/action.yml @@ -0,0 +1,36 @@ +name: "Julia testing" + +description: | + This action tests that PyMAPDL can be imported on Julia environments. + +inputs: + julia-version: + description: | + Julia version to test. + required: true + type: string + +runs: + using: "composite" + steps: + - name: "Set up Julia" + uses: julia-actions/setup-julia@v2 + with: + version: ${{ matrix.julia-version }} + + - name: "Getting python interpreter" + id: get_python + run: | + pycallpython=$(julia -e 'using Pkg;Pkg.add("PyCall");using PyCall;println(PyCall.python)') + echo "pythonpath=$(echo $pycallpython)" >> $GITHUB_OUTPUT + + - name: "Installing PyMAPDL" + env: + PYTHON_PATH: ${{ steps.get_python.outputs.pythonpath }} + run: | + "$PYTHON_PATH" -m pip install -e . + + - name: "Starting Julia" + shell: julia {0} + run: | + using Pkg; Pkg.add("PyCall");using PyCall;pymapdl = pyimport("ansys.mapdl.core");print(pymapdl.__version__) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8c7fa90332..44a5928a877 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: pull_request: workflow_dispatch: inputs: - run_all_tests: + run_all_builds: description: 'Run all extended MAPDL build tests' required: true type: boolean @@ -131,12 +131,10 @@ jobs: whitelist-license-check: "attrs" # This has MIT license but fails the check - name: "Importing library" - run: | - python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" + run: python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" - name: "Checking plotting support" - run: - python -c "from pyvista.plotting import system_supports_plotting; print('System support plotting ' + str(system_supports_plotting()))" + run: python -c "from pyvista.plotting import system_supports_plotting; print('System support plotting ' + str(system_supports_plotting()))" check-vulnerabilities: @@ -170,192 +168,13 @@ jobs: - name: "Install Git and checkout project" uses: actions/checkout@v4.2.2 - - name: "Login in Github container registry" - uses: docker/login-action@v3.3.0 + - name: "Build documentation" + uses: ./.github/actions/doc-build with: - registry: ghcr.io + license_server: ${{ secrets.LICENSE_SERVER }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: "Pull, launch, and validate MAPDL service" - id: start_mapdl - env: - LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }} - MAPDL_VERSION: ${{ env.MAPDL_IMAGE_VERSION_DOCS_BUILD }} - DISTRIBUTED_MODE: "dmp" - run: | - export INSTANCE_NAME=MAPDL_0 - .ci/start_mapdl.sh &> mapdl_launch.log & export DOCKER_PID=$! - echo "Launching MAPDL service at PID: $DOCKER_PID" - echo "DOCKER_PID=$(echo $DOCKER_PID)" >> $GITHUB_OUTPUT - - - name: "DPF server activation" - run: | - $(docker pull ghcr.io/ansys/dpf-core:22.2dev && docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}.") & - - - name: "Getting files change filters" - uses: dorny/paths-filter@v3 - id: changes - with: - filters: | - workflows: - - '.github/workflows/**' - - 'pyproject.toml' - examples: - - 'examples/**' - - 'pyproject.toml' - documentation: - - 'examples/**' - - 'doc/**' - - 'pyproject.toml' - - - name: "Setup Python with cache" - uses: actions/setup-python@v5 - if: steps.changes.outputs.workflows != 'true' - with: - cache: 'pip' - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: "Setup Python without cache" - uses: actions/setup-python@v5 - if: steps.changes.outputs.workflows == 'true' - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: "Install OS packages" - run: | - sudo apt update - sudo apt install zip pandoc libgl1-mesa-glx xvfb texlive-latex-extra latexmk graphviz texlive-xetex texlive-fonts-extra qpdf xindy - - - name: "Test virtual framebuffer" - run: | - pip install -r .ci/requirements_test_xvfb.txt - xvfb-run python .ci/display_test.py - - - name: "Install ansys-mapdl-core" - run: | - pip install . - xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" - - - name: "Retrieve PyMAPDL version" - id: version - run: | - echo "PYMAPDL_VERSION=$(python -c 'from ansys.mapdl.core import __version__; print(__version__)')" >> $GITHUB_OUTPUT - echo "PyMAPDL version is: $(python -c "from ansys.mapdl.core import __version__; print(__version__)")" - - - name: "Cache examples" - uses: actions/cache@v4 - if: steps.changes.outputs.documentation == 'false' || (github.ref == 'refs/heads/main' && !contains(github.ref, 'refs/tags')) - with: - path: doc/source/examples - key: Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }} - restore-keys: | - Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }} - - - name: "Cache docs build directory" - uses: actions/cache@v4 - if: steps.changes.outputs.documentation == 'false' || (github.ref == 'refs/heads/main' && !contains(github.ref, 'refs/tags')) - with: - path: doc/_build - key: doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }} - restore-keys: | - doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }} - - - name: "Cache autosummary" - uses: actions/cache@v4 - if: steps.changes.outputs.documentation == 'false' || (github.ref == 'refs/heads/main' && !contains(github.ref, 'refs/tags')) - with: - path: doc/source/**/_autosummary/*.rst - key: autosummary-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }} - restore-keys: | - autosummary-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }} - - - name: "Install docs build requirements" - run: | - pip uninstall ansys-sphinx-theme - pip install .[doc] - - - name: "Waiting for the services to be up" - run: | - .ci/waiting_services.sh - - - name: Install Quarto - uses: quarto-dev/quarto-actions/setup@v2 - with: - tinytex: true - - - name: Check Quarto Version - shell: bash - run: | - quarto --version - - - name: "Install Poppler for PDF to PNG conversion" - shell: bash - run: | - sudo apt-get update - sudo apt-get install -y poppler-utils - - - name: "Build documentation" - run: | - xvfb-run make -C doc html SPHINXOPTS="-j auto -W --keep-going" - - - name: "Substitute defective GIF" - run: | - .ci/substitute_defective_gif.sh - - - name: "Upload HTML Documentation" - uses: actions/upload-artifact@v4 - with: - name: documentation-html - path: doc/_build/html - retention-days: 7 - - - name: "Build PDF Documentation" - working-directory: doc - run: make pdf - - - name: "Show latex dir" - working-directory: doc - run: ls _build/latex - - - name: "Upload PDF documentation" - uses: actions/upload-artifact@v4 - with: - name: documentation-pdf - path: doc/_build/latex/pymapdl*.pdf - retention-days: 7 - - - name: "Upload minimal requirements file" - # To include it in the release - uses: actions/upload-artifact@v4 - with: - name: minimum_requirements.txt - path: ./minimum_requirements.txt - - - name: "Collect logs on failure" - if: always() - env: - MAPDL_VERSION: ${{ env.MAPDL_IMAGE_VERSION_DOCS_BUILD }} - MAPDL_INSTANCE: MAPDL_0 - LOG_NAMES: logs-build-docs - run: | - .ci/collect_mapdl_logs_remote.sh - - - name: "Upload logs to GitHub" - if: always() - uses: actions/upload-artifact@master - with: - name: logs-build-docs.tgz - path: ./logs-build-docs.tgz - - - name: "Display files structure" - if: always() - env: - MAPDL_INSTANCE: MAPDL_0 - LOG_NAMES: logs-build-docs - run: | - .ci/display_logs_remote.sh - build-test-remote-matrix: name: "Build remote test matrix" runs-on: ubuntu-22.04 @@ -367,36 +186,13 @@ jobs: - name: "Install Git and checkout project" uses: actions/checkout@v4.2.2 - - name: Get event type and user to check permissions. - id: get_user - env: - type_event: ${{ github.event.issue.pull_request }} - run: | - if [[ $type_event ]]; then - echo "Event type: $type_event" - echo "event_type=$( echo "$type_event" )" >> $GITHUB_OUTPUT - export user=${{ github.event.pull_request.user.login }} - else - export user=${{ github.actor }} - fi - echo "This PR has been opened by: $user" - echo "user=$( echo "$user" )" >> $GITHUB_OUTPUT - - - uses: tspascoal/get-user-teams-membership@v3 - id: is_organization_member - if: ${{ github.actor != 'dependabot[bot]' }} + - name: Build matrix for remote testing + uses: ./.github/actions/build-matrix with: - username: ${{ steps.get_user.outputs.user }} - organization: ansys - team: 'pymapdl-developers' - GITHUB_TOKEN: ${{ secrets.TOKEN_TEAMS_USER_READ }} - - - id: set-matrix - env: - extended_testing: ${{ github.event_name == 'schedule' || ( github.event_name == 'workflow_dispatch' && inputs.run_all_tests ) || ( github.event_name == 'push' && contains(github.ref, 'refs/tags') ) }} - auth_user: ${{ steps.is_organization_member.outputs.isTeamMember == 'true' || github.actor == 'dependabot[bot]' }} - ON_REMOTE: true - run: .ci/build_matrix.sh + token_teams_user_read: ${{ secrets.TOKEN_TEAMS_USER_READ}} + local: false + run_all_builds: ${{ inputs.run_all_builds }} + build-test-remote: name: "Remote: ${{ matrix.mapdl-version }}" @@ -430,7 +226,7 @@ jobs: codecov_token: ${{ secrets.CODECOV_TOKEN }} license_server: ${{ secrets.LICENSE_SERVER }} - build-test-local-minimal-matrix: + build-test-local-matrix: name: "Build test matrix for minimal and local" runs-on: ubuntu-22.04 if: github.ref != 'refs/heads/main' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' @@ -440,36 +236,22 @@ jobs: - name: "Install Git and checkout project" uses: actions/checkout@v4.2.2 - - uses: tspascoal/get-user-teams-membership@v3 - id: is_organization_member - if: ${{ github.actor != 'dependabot[bot]' }} + - name: Build matrix for local, minimal and console testing + uses: ./.github/actions/build-matrix with: - username: ${{ github.actor }} - organization: ansys - team: 'pymapdl-developers' - GITHUB_TOKEN: ${{ secrets.TOKEN_TEAMS_USER_READ }} - - - id: set-matrix - env: - ONLY_UBUNTU: true - LIMIT_VERSIONS: 2 - ON_SCHEDULE: ${{ github.event_name == 'schedule' }} - ON_WORKFLOW_DISPATCH: ${{ github.event_name == 'workflow_dispatch' }} - RUN_ALL_TEST: ${{ inputs.run_all_tests }} - ON_PUSH: ${{ github.event_name == 'push' }} - HAS_TAG: ${{ contains(github.ref, 'refs/tags') }} - auth_user: ${{ steps.is_organization_member.outputs.isTeamMember == 'true' || github.actor == 'dependabot[bot]' }} - run: .ci/build_matrix.sh + token_teams_user_read: ${{ secrets.TOKEN_TEAMS_USER_READ}} + local: true + run_all_builds: ${{ inputs.run_all_builds }} build-test-ubuntu-local: name: "Local: ${{ matrix.mapdl-version }}" runs-on: ubuntu-22.04 if: github.ref != 'refs/heads/main' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - needs: [smoke-tests, build-test-local-minimal-matrix] + needs: [smoke-tests, build-test-local-matrix] timeout-minutes: 75 strategy: fail-fast: false - matrix: ${{fromJson(needs.build-test-local-minimal-matrix.outputs.matrix)}} + matrix: ${{fromJson(needs.build-test-local-matrix.outputs.matrix)}} container: image: ghcr.io/ansys/mapdl:${{ matrix.mapdl-version }} @@ -694,27 +476,11 @@ jobs: steps: - uses: actions/checkout@v4.2.2 - - name: "Set up Julia" - uses: julia-actions/setup-julia@v2 + + - name: "Run Julia testing" + uses: ./.github/actions/test-julia with: - version: ${{ matrix.julia-version }} - - - name: "Getting python interpreter" - id: get_python - run: | - pycallpython=$(julia -e 'using Pkg;Pkg.add("PyCall");using PyCall;println(PyCall.python)') - echo "pythonpath=$(echo $pycallpython)" >> $GITHUB_OUTPUT - - - name: "Installing PyMAPDL" - env: - PYTHON_PATH: ${{ steps.get_python.outputs.pythonpath }} - run: | - "$PYTHON_PATH" -m pip install -e . - - - name: "Starting Julia" - shell: julia {0} - run: | - using Pkg; Pkg.add("PyCall");using PyCall;pymapdl = pyimport("ansys.mapdl.core");print(pymapdl.__version__) + julia-version: ${{ matrix.julia-version }} pytest-summary: name: Pytest summary for all the test jobs From 99891774fd2d4748aac83970cf0eec5ad4ff8363 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 17:51:16 +0100 Subject: [PATCH 12/40] feat: add minimal OS package installation and adjust pytest command based on input --- .github/actions/test-local/action.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/actions/test-local/action.yml b/.github/actions/test-local/action.yml index 232f4d29e6d..2abc94bc8ea 100644 --- a/.github/actions/test-local/action.yml +++ b/.github/actions/test-local/action.yml @@ -69,10 +69,17 @@ runs: echo "ON_STUDENT=$(echo $ON_STUDENT)" >> $GITHUB_OUTPUT echo "TAG_STUDENT=$(echo $TAG_STUDENT)" >> $GITHUB_OUTPUT + - name: "Installing minimal OS packages" + shell: bash + if: inputs.minimal == 'true' + run: | + sudo apt-get update && apt install -y libgomp1 graphviz + - name: "Installing OS packages" shell: bash + if: inputs.minimal == 'false' run: | - sudo apt-get update && apt-get install -y libgomp1 graphviz + sudo apt-get update && apt install -y libgl1-mesa-glx xvfb libgomp1 graphviz - name: "Setup Python" uses: actions/setup-python@v5 @@ -140,12 +147,15 @@ runs: if [[ "${{ inputs.minimal }}" == "true" ]]; then echo "PYMAPDL_MAPDL_EXEC: $PYMAPDL_MAPDL_EXEC" export PYMAPDL_MAPDL_EXEC=/ansys_inc/v"$version"/ansys/bin/ansys"$version" + export cmd="pytest" + else + export cmd="xvfb-run pytest" fi; unset PYMAPDL_START_INSTANCE unset PYMAPDL_PORT - pytest ${{ inputs.pytest-arguments }} \ + $cmd ${{ inputs.pytest-arguments }} \ ${{ env.PYTEST_ARGUMENTS }} \ --report-log=$file_name.jsonl \ --cov-report=xml:$file_name.xml From 4ab1f95335555835d05431f69f9d9d86293734d1 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 17:57:49 +0100 Subject: [PATCH 13/40] fix: enforce bash shell for all steps in build and test actions --- .github/actions/build-matrix/action.yml | 4 +++- .github/actions/test-julia/action.yml | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/actions/build-matrix/action.yml b/.github/actions/build-matrix/action.yml index 7831a6d0ebc..1094bcd1df7 100644 --- a/.github/actions/build-matrix/action.yml +++ b/.github/actions/build-matrix/action.yml @@ -31,6 +31,7 @@ runs: id: get_user env: type_event: ${{ github.event.issue.pull_request }} + shell: bash run: | if [[ $type_event ]]; then echo "Event type: $type_event" @@ -56,11 +57,12 @@ runs: env: auth_user: ${{ steps.is_organization_member.outputs.isTeamMember == 'true' || github.actor == 'dependabot[bot]' }} ON_REMOTE: ${{ inputs.local == 'false' }} - ONLY_UBUNTU: ${{ input.local == 'true' }} + ONLY_UBUNTU: ${{ inputs.local == 'true' }} ON_SCHEDULE: ${{ github.event_name == 'schedule' }} ON_WORKFLOW_DISPATCH: ${{ github.event_name == 'workflow_dispatch' }} RUN_ALL_TEST: ${{ inputs.run_all_builds == 'true' }} ON_PUSH: ${{ github.event_name == 'push' }} HAS_TAG: ${{ contains(github.ref, 'refs/tags') }} LIMIT_VERSIONS: 2 + shell: bash run: .ci/build_matrix.sh diff --git a/.github/actions/test-julia/action.yml b/.github/actions/test-julia/action.yml index 86d4491a169..690384ed892 100644 --- a/.github/actions/test-julia/action.yml +++ b/.github/actions/test-julia/action.yml @@ -20,6 +20,7 @@ runs: - name: "Getting python interpreter" id: get_python + shell: bash run: | pycallpython=$(julia -e 'using Pkg;Pkg.add("PyCall");using PyCall;println(PyCall.python)') echo "pythonpath=$(echo $pycallpython)" >> $GITHUB_OUTPUT @@ -27,6 +28,7 @@ runs: - name: "Installing PyMAPDL" env: PYTHON_PATH: ${{ steps.get_python.outputs.pythonpath }} + shell: bash run: | "$PYTHON_PATH" -m pip install -e . From a0e2e7af7891f47e54b450a7aec110af22eea021 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 18:06:56 +0100 Subject: [PATCH 14/40] feat: add output matrix for MAPDL containers in build matrix action --- .github/actions/build-matrix/action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/actions/build-matrix/action.yml b/.github/actions/build-matrix/action.yml index 1094bcd1df7..0762ab5f188 100644 --- a/.github/actions/build-matrix/action.yml +++ b/.github/actions/build-matrix/action.yml @@ -24,6 +24,11 @@ inputs: type: boolean default: false +outputs: + matrix: + description: "Matrix of MAPDL containers to test." + value: ${{ steps.set-matrix.outputs.matrix }} + runs: using: "composite" steps: From ca7e7eb5fe2ba06269db551f90f107f6b8832644 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 20:32:25 +0100 Subject: [PATCH 15/40] fix: remove unnecessary blank lines in action YAML files and set matrix IDs in CI workflow --- .github/actions/build-matrix/action.yml | 2 +- .github/actions/doc-build/action.yml | 2 +- .github/workflows/ci.yml | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/actions/build-matrix/action.yml b/.github/actions/build-matrix/action.yml index 0762ab5f188..25749747613 100644 --- a/.github/actions/build-matrix/action.yml +++ b/.github/actions/build-matrix/action.yml @@ -16,7 +16,7 @@ inputs: required: false type: boolean default: true - + run_all_builds: description: | If true, run all extended MAPDL build tests. diff --git a/.github/actions/doc-build/action.yml b/.github/actions/doc-build/action.yml index 18b70292c24..8ca48a680b8 100644 --- a/.github/actions/doc-build/action.yml +++ b/.github/actions/doc-build/action.yml @@ -16,7 +16,7 @@ inputs: Username for the GitHub container registry. required: true type: string - + password: description: | Password for the GitHub container registry. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44a5928a877..be12e08ca72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -188,6 +188,7 @@ jobs: - name: Build matrix for remote testing uses: ./.github/actions/build-matrix + id: set-matrix with: token_teams_user_read: ${{ secrets.TOKEN_TEAMS_USER_READ}} local: false @@ -238,6 +239,7 @@ jobs: - name: Build matrix for local, minimal and console testing uses: ./.github/actions/build-matrix + id: set-matrix with: token_teams_user_read: ${{ secrets.TOKEN_TEAMS_USER_READ}} local: true From 166e63f581b0052a3c314396b45000e10d1edfda Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 22:31:35 +0100 Subject: [PATCH 16/40] feat: remove if condition, add type_event input to build-matrix action and improve package installation command --- .github/actions/build-matrix/action.yml | 10 ++++++++-- .github/actions/doc-build/action.yml | 3 +-- .github/workflows/ci.yml | 6 +++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/actions/build-matrix/action.yml b/.github/actions/build-matrix/action.yml index 25749747613..2ca93c24460 100644 --- a/.github/actions/build-matrix/action.yml +++ b/.github/actions/build-matrix/action.yml @@ -23,6 +23,13 @@ inputs: required: false type: boolean default: false + + type_event: + description: | + Type of event that triggered the workflow. + required: false + type: string + default: "" outputs: matrix: @@ -35,7 +42,7 @@ runs: - name: Get event type and user to check permissions. id: get_user env: - type_event: ${{ github.event.issue.pull_request }} + type_event: ${{ inputs.type_event }} shell: bash run: | if [[ $type_event ]]; then @@ -58,7 +65,6 @@ runs: GITHUB_TOKEN: ${{ inputs.token_teams_user_read }} - id: set-matrix - if: inputs.local == 'false' env: auth_user: ${{ steps.is_organization_member.outputs.isTeamMember == 'true' || github.actor == 'dependabot[bot]' }} ON_REMOTE: ${{ inputs.local == 'false' }} diff --git a/.github/actions/doc-build/action.yml b/.github/actions/doc-build/action.yml index 8ca48a680b8..41d15245f45 100644 --- a/.github/actions/doc-build/action.yml +++ b/.github/actions/doc-build/action.yml @@ -84,8 +84,7 @@ runs: - name: "Install OS packages" shell: bash run: | - sudo apt update - sudo apt install zip pandoc libgl1-mesa-glx xvfb texlive-latex-extra latexmk graphviz texlive-xetex texlive-fonts-extra qpdf xindy + sudo apt update && sudo apt install zip pandoc libgl1-mesa-glx xvfb texlive-latex-extra latexmk graphviz texlive-xetex texlive-fonts-extra qpdf xindy - name: "Test virtual framebuffer" shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be12e08ca72..2dfdee8482a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -190,7 +190,7 @@ jobs: uses: ./.github/actions/build-matrix id: set-matrix with: - token_teams_user_read: ${{ secrets.TOKEN_TEAMS_USER_READ}} + token_teams_user_read: ${{ secrets.TOKEN_TEAMS_USER_READ }} local: false run_all_builds: ${{ inputs.run_all_builds }} @@ -241,7 +241,7 @@ jobs: uses: ./.github/actions/build-matrix id: set-matrix with: - token_teams_user_read: ${{ secrets.TOKEN_TEAMS_USER_READ}} + token_teams_user_read: ${{ secrets.TOKEN_TEAMS_USER_READ }} local: true run_all_builds: ${{ inputs.run_all_builds }} @@ -253,7 +253,7 @@ jobs: timeout-minutes: 75 strategy: fail-fast: false - matrix: ${{fromJson(needs.build-test-local-matrix.outputs.matrix)}} + matrix: ${{ fromJson(needs.build-test-local-matrix.outputs.matrix) }} container: image: ghcr.io/ansys/mapdl:${{ matrix.mapdl-version }} From e2cb7306da8c428b0ef4d76685f74b73e1508870 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 23:37:20 +0100 Subject: [PATCH 17/40] feat: using reusable workflows instead --- .github/actions/build-matrix/action.yml | 4 +- .github/workflows/ci.yml | 115 +++-------- .github/workflows/doc-build.yml | 235 ++++++++++++++++++++++ .github/workflows/test-local.yml | 245 +++++++++++++++++++++++ .github/workflows/test-remote.yml | 248 ++++++++++++++++++++++++ 5 files changed, 757 insertions(+), 90 deletions(-) create mode 100644 .github/workflows/doc-build.yml create mode 100644 .github/workflows/test-local.yml create mode 100644 .github/workflows/test-remote.yml diff --git a/.github/actions/build-matrix/action.yml b/.github/actions/build-matrix/action.yml index 2ca93c24460..3ac23ad4ae5 100644 --- a/.github/actions/build-matrix/action.yml +++ b/.github/actions/build-matrix/action.yml @@ -10,7 +10,7 @@ inputs: required: true type: string - local: + local: description: | If true, the building matrix for local testing required: false @@ -23,7 +23,7 @@ inputs: required: false type: boolean default: false - + type_event: description: | Type of event that triggered the workflow. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2dfdee8482a..12bfd19e423 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,6 @@ env: PACKAGE_NAMESPACE: 'ansys.mapdl.core' DOCUMENTATION_CNAME: 'mapdl.docs.pyansys.com' LATEST_VERSION: "252" - MAPDL_IMAGE_VERSION_DOCS_BUILD: v24.2-ubuntu-student MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY }} MEILISEARCH_PUBLIC_API_KEY: ${{ secrets.MEILISEARCH_PUBLIC_API_KEY }} PYANSYS_OFF_SCREEN: True @@ -38,14 +37,6 @@ env: BUILD_CHEATSHEET: True PYMAPDL_DEBUG_TESTING: True - # Following env vars when changed will "reset" the mentioned cache, - # by changing the cache file name. It is rendered as ...-v%RESET_XXX%-... - # You should go up in number, if you go down (or repeat a previous value) - # you might end up reusing a previous cache if it haven't been deleted already. - # It applies 7 days retention policy by default. - RESET_EXAMPLES_CACHE: 0 - RESET_DOC_BUILD_CACHE: 0 - RESET_AUTOSUMMARY_CACHE: 0 concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -150,30 +141,14 @@ jobs: upload-reports: True hide-log: false - docs-build: name: "Build documentation" - runs-on: ubuntu-22.04 needs: doc-style - timeout-minutes: 60 - outputs: - PYMAPDL_VERSION: ${{ steps.version.outputs.PYMAPDL_VERSION }} - env: - PYMAPDL_PORT: 21000 # default won't work on GitHub runners - PYMAPDL_DB_PORT: 21001 # default won't work on GitHub runners - PYMAPDL_START_INSTANCE: FALSE - ON_DOCUMENTATION: TRUE - GRPC_ENABLE_FORK_SUPPORT: false # See #3434 - steps: - - name: "Install Git and checkout project" - uses: actions/checkout@v4.2.2 - - - name: "Build documentation" - uses: ./.github/actions/doc-build - with: - license_server: ${{ secrets.LICENSE_SERVER }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + uses: ./.github/workflows/doc-build.yml + secrets: + license_server: ${{ secrets.LICENSE_SERVER }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} build-test-remote-matrix: name: "Build remote test matrix" @@ -194,38 +169,21 @@ jobs: local: false run_all_builds: ${{ inputs.run_all_builds }} - build-test-remote: name: "Remote: ${{ matrix.mapdl-version }}" - runs-on: ubuntu-22.04 needs: [smoke-tests, build-test-remote-matrix] - timeout-minutes: 35 strategy: fail-fast: false matrix: ${{ fromJson(needs.build-test-remote-matrix.outputs.matrix) }} - - env: - PYMAPDL_PORT: 21000 # default won't work on GitHub runners - PYMAPDL_PORT2: 21001 # for the pool testing and default won't work on GitHub runners - PYMAPDL_DB_PORT: 21002 # default won't work on GitHub runners - PYMAPDL_DB_PORT2: 21003 # default won't work on GitHub runners - PYMAPDL_START_INSTANCE: FALSE - ON_LOCAL: FALSE - ON_UBUNTU: FALSE - # BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - - steps: - - name: "Install Git and checkout project" - uses: actions/checkout@v4.2.2 - - - name: Run Pytest for ${{ matrix.mapdl-version }} on remote mode - uses: ./.github/actions/test-remote - with: - mapdl-version: ${{ matrix.mapdl-version }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - codecov_token: ${{ secrets.CODECOV_TOKEN }} - license_server: ${{ secrets.LICENSE_SERVER }} + uses: ./.github/workflows/test-remote.yml + secrets: + license-server: ${{ secrets.LICENSE_SERVER }} + codecov-token: ${{ secrets.CODECOV_TOKEN }} + password: ${{ secrets.GITHUB_TOKEN }} + actor: ${{ github.actor }} + with: + mapdl-version: ${{ matrix.mapdl-version }} + file-name: "${{ matrix.mapdl-version }}-remote" build-test-local-matrix: name: "Build test matrix for minimal and local" @@ -247,43 +205,24 @@ jobs: build-test-ubuntu-local: name: "Local: ${{ matrix.mapdl-version }}" - runs-on: ubuntu-22.04 if: github.ref != 'refs/heads/main' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' needs: [smoke-tests, build-test-local-matrix] - timeout-minutes: 75 + uses: ./.github/workflows/test-local.yml strategy: fail-fast: false matrix: ${{ fromJson(needs.build-test-local-matrix.outputs.matrix) }} - - container: - image: ghcr.io/ansys/mapdl:${{ matrix.mapdl-version }} - options: -u=0:0 --oom-kill-disable --memory=6656MB --memory-swap=16896MB --shm-size=1gb --entrypoint /bin/bash - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - env: - ON_LOCAL: true - ON_UBUNTU: true - P_SCHEMA: "/ansys_inc/v241/ansys/ac4/schema" - PYTEST_TIMEOUT: 120 # seconds. Limit the duration for each unit test - - steps: - - name: "Install Git and checkout project" - uses: actions/checkout@v4.2.2 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - - name: "Run pytest on local" - uses: ./.github/actions/test-local - with: - mapdl-version: ${{ matrix.mapdl-version }} - minimal: false - license_server: ${{ secrets.LICENSE_SERVER }} - pytest-arguments: '-k "not test_dpf" --reset_only_failed --add_missing_images' - file-name: "${{ matrix.mapdl-version }}-local" - tags: "local" - codecov_token: ${{ secrets.CODECOV_TOKEN }} + secrets: + license-server: ${{ secrets.LICENSE_SERVER }} + codecov-token: ${{ secrets.CODECOV_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} + actor: ${{ github.actor }} + with: + testing-minimal: false + pytest-arguments: '-k "not test_dpf" --reset_only_failed --add_missing_images' + mapdl-version: ${{ matrix.mapdl-version }} + file-name: "${{ matrix.mapdl-version }}-local" + tags: "local" + latest-version: ${{ env.LATEST_VERSION }} build-test-ubuntu-minimal: name: "Local-min: ${{ matrix.mapdl-version }}" diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml new file mode 100644 index 00000000000..a8096037c39 --- /dev/null +++ b/.github/workflows/doc-build.yml @@ -0,0 +1,235 @@ +# This action builds the documentation for PyMAPDL. +name: "Documentation Build" + +on: + workflow_call: + # inputs: + + # Secrets + secrets: + license_server: + description: | + License server for ANSYS MAPDL + required: true + + username: + description: | + Username for the GitHub container registry. + required: true + + password: + description: | + Password for the GitHub container registry. + required: true + +jobs: + doc-build: + runs-on: ubuntu-22.04 + env: + ON_CI: True + MAPDL_IMAGE_VERSION_DOCS_BUILD: v24.2-ubuntu-student + PYMAPDL_PORT: 21000 # default won't work on GitHub runners + PYMAPDL_DB_PORT: 21001 # default won't work on GitHub runners + PYMAPDL_START_INSTANCE: FALSE + ON_DOCUMENTATION: TRUE + GRPC_ENABLE_FORK_SUPPORT: false # See #3434 + DPF_PORT: 21004 + steps: + - name: "Login in Github container registry" + uses: docker/login-action@v3.3.0 + with: + registry: ghcr.io + username: ${{ secrets.username }} + password: ${{ secrets.password }} + + - name: "Pull, launch, and validate MAPDL service" + id: start_mapdl + env: + LICENSE_SERVER: ${{ secrets.license_server }} + MAPDL_VERSION: ${{ env.MAPDL_IMAGE_VERSION_DOCS_BUILD }} + DISTRIBUTED_MODE: "dmp" + shell: bash + run: | + export INSTANCE_NAME=MAPDL_0 + .ci/start_mapdl.sh &> mapdl_launch.log & export DOCKER_PID=$! + echo "Launching MAPDL service at PID: $DOCKER_PID" + echo "DOCKER_PID=$(echo $DOCKER_PID)" >> $GITHUB_OUTPUT + + - name: "DPF server activation" + shell: bash + run: | + $(docker pull ghcr.io/ansys/dpf-core:22.2dev && docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}.") & + + - name: "Getting files change filters" + uses: dorny/paths-filter@v3 + id: changes + with: + filters: | + workflows: + - '.github/workflows/**' + - 'pyproject.toml' + examples: + - 'examples/**' + - 'pyproject.toml' + documentation: + - 'examples/**' + - 'doc/**' + - 'pyproject.toml' + + - name: "Setup Python with cache" + uses: actions/setup-python@v5 + if: steps.changes.outputs.workflows != 'true' + with: + cache: 'pip' + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: "Setup Python without cache" + uses: actions/setup-python@v5 + if: steps.changes.outputs.workflows == 'true' + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: "Install OS packages" + shell: bash + run: | + sudo apt update && sudo apt install zip pandoc libgl1-mesa-glx xvfb texlive-latex-extra latexmk graphviz texlive-xetex texlive-fonts-extra qpdf xindy + + - name: "Test virtual framebuffer" + shell: bash + run: | + pip install -r .ci/requirements_test_xvfb.txt + xvfb-run python .ci/display_test.py + + - name: "Install ansys-mapdl-core" + shell: bash + run: | + pip install . + xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" + + - name: "Retrieve PyMAPDL version" + id: version + shell: bash + run: | + echo "PYMAPDL_VERSION=$(python -c 'from ansys.mapdl.core import __version__; print(__version__)')" >> $GITHUB_OUTPUT + echo "PyMAPDL version is: $(python -c "from ansys.mapdl.core import __version__; print(__version__)")" + + - name: "Cache examples" + uses: actions/cache@v4 + if: steps.changes.outputs.documentation == 'false' || (github.ref == 'refs/heads/main' && !contains(github.ref, 'refs/tags')) + with: + path: doc/source/examples + key: Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }} + restore-keys: | + Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }} + + - name: "Cache docs build directory" + uses: actions/cache@v4 + if: steps.changes.outputs.documentation == 'false' || (github.ref == 'refs/heads/main' && !contains(github.ref, 'refs/tags')) + with: + path: doc/_build + key: doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }} + restore-keys: | + doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }} + + - name: "Cache autosummary" + uses: actions/cache@v4 + if: steps.changes.outputs.documentation == 'false' || (github.ref == 'refs/heads/main' && !contains(github.ref, 'refs/tags')) + with: + path: doc/source/**/_autosummary/*.rst + key: autosummary-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }} + restore-keys: | + autosummary-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }} + + - name: "Install docs build requirements" + shell: bash + run: | + pip uninstall ansys-sphinx-theme + pip install .[doc] + + - name: "Waiting for the services to be up" + shell: bash + run: | + .ci/waiting_services.sh + + - name: Install Quarto + uses: quarto-dev/quarto-actions/setup@v2 + with: + tinytex: true + + - name: Check Quarto Version + shell: bash + run: | + quarto --version + + - name: "Install Poppler for PDF to PNG conversion" + shell: bash + run: | + sudo apt-get update + sudo apt-get install -y poppler-utils + + - name: "Build documentation" + shell: bash + run: | + xvfb-run make -C doc html SPHINXOPTS="-j auto -W --keep-going" + + - name: "Substitute defective GIF" + shell: bash + run: | + .ci/substitute_defective_gif.sh + + - name: "Upload HTML Documentation" + uses: actions/upload-artifact@v4 + with: + name: documentation-html + path: doc/_build/html + retention-days: 7 + + - name: "Build PDF Documentation" + working-directory: doc + shell: bash + run: make pdf + + - name: "Show latex dir" + working-directory: doc + shell: bash + run: ls _build/latex + + - name: "Upload PDF documentation" + uses: actions/upload-artifact@v4 + with: + name: documentation-pdf + path: doc/_build/latex/pymapdl*.pdf + retention-days: 7 + + - name: "Upload minimal requirements file" + # To include it in the release + uses: actions/upload-artifact@v4 + with: + name: minimum_requirements.txt + path: ./minimum_requirements.txt + + - name: "Collect logs on failure" + if: always() + env: + MAPDL_VERSION: ${{ env.MAPDL_IMAGE_VERSION_DOCS_BUILD }} + MAPDL_INSTANCE: MAPDL_0 + LOG_NAMES: logs-build-docs + shell: bash + run: | + .ci/collect_mapdl_logs_remote.sh + + - name: "Upload logs to GitHub" + if: always() + uses: actions/upload-artifact@master + with: + name: logs-build-docs.tgz + path: ./logs-build-docs.tgz + + - name: "Display files structure" + if: always() + env: + MAPDL_INSTANCE: MAPDL_0 + LOG_NAMES: logs-build-docs + shell: bash + run: | + .ci/display_logs_remote.sh \ No newline at end of file diff --git a/.github/workflows/test-local.yml b/.github/workflows/test-local.yml new file mode 100644 index 00000000000..477ad116573 --- /dev/null +++ b/.github/workflows/test-local.yml @@ -0,0 +1,245 @@ +# This action tests PyMAPDL with MAPDL running locally. +# It does support running with minimal requirements and with console interface. + +name: "Local testing" + +on: + workflow_call: + inputs: + mapdl-version: + description: | + MAPDL version to test. + required: true + type: string + + minimal: + description: | + If true, the minimal requirements will be installed. + required: false + type: boolean + default: false + + pytest-arguments: + description: | + Arguments to pass to pytest, additionally to the ones in the environment variable PYTEST_ARGUMENTS. + required: false + type: string + default: "" + + file-name: + description: | + Name of the file to save the logs. + required: true + type: string + + tags: + description: | + Tags to add to the coverage report. + required: true + type: string + + testing-minimal: + description: | + If true, the minimal requirements will be installed. + required: false + type: boolean + default: false + + latest-version: + description: | + Latest version of MAPDL. + required: true + type: string + + main-python-version: + description: | + Python version to test. + required: true + type: string + + secrets: + license-server: + description: | + License server for ANSYS MAPDL + required: true + + codecov-token: + description: | + Token for Codecov. + required: true + + github-token: + description: | + Token for GitHub. + required: true + + actor: + description: | + GitHub actor. + required: true + +jobs: + test-local: + runs-on: ubuntu-22.04 + env: + ON_CI: True + ON_LOCAL: true + ON_UBUNTU: true + TESTING_MINIMAL: ${{ inputs.testing-minimal }} + MAIN_PYTHON_VERSION: "3.12" + P_SCHEMA: "/ansys_inc/v241/ansys/ac4/schema" + PYTEST_TIMEOUT: 120 # seconds. Limit the duration for each unit test + + container: + image: ghcr.io/ansys/mapdl:${{ inputs.mapdl-version }} + options: -u=0:0 --oom-kill-disable --memory=6656MB --memory-swap=16896MB --shm-size=1gb --entrypoint /bin/bash + credentials: + username: ${{ secrets.actor }} + password: ${{ secrets.github-token }} + + steps: + - name: "Install Git and checkout project" + uses: actions/checkout@v4.2.2 + + - name: "Get if running student version" + id: student_check + shell: bash + run: | + if [[ "${{ inputs.mapdl-version }}" == *"student"* ]]; + then export ON_STUDENT=true; export TAG_STUDENT="student"; + else export ON_STUDENT=false; export TAG_STUDENT="non-student"; + fi + + echo "ON_STUDENT: $ON_STUDENT" + echo "TAG_STUDENT: $TAG_STUDENT" + echo "ON_STUDENT=$(echo $ON_STUDENT)" >> $GITHUB_OUTPUT + echo "TAG_STUDENT=$(echo $TAG_STUDENT)" >> $GITHUB_OUTPUT + + - name: "Installing minimal OS packages" + shell: bash + if: inputs.testing-minimal == 'true' + run: | + sudo apt-get update && apt install -y libgomp1 graphviz + + - name: "Installing OS packages" + shell: bash + if: inputs.testing-minimal == 'false' + run: | + sudo apt-get update && apt install -y libgl1-mesa-glx xvfb libgomp1 graphviz + + - name: "Setup Python" + uses: actions/setup-python@v5 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: "Checking Python" + shell: bash + run: | + python --version + python -m pip install --upgrade pip + + - name: "Install ansys-mapdl-core" + if: inputs.testing-minimal == 'false' + shell: bash + run: | + python -m pip install build + python -m build + python -m pip install dist/*.whl + xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" + + - name: "Install ansys-mapdl-core with minimal requirements" + shell: bash + if: inputs.testing-minimal == 'true' + run: | + python -m pip install . --no-deps + python -m pip install -r minimum_requirements.txt + python -c "from ansys.mapdl import core as pymapdl; print('Import successfull')" + + - name: "Unit testing requirements installation" + if: inputs.testing-minimal == 'false' + shell: bash + run: | + python -m pip install .[tests] + + - name: "Unit testing requirements installation" + if: inputs.testing-minimal == 'true' + shell: bash + run: | + python -m pip install -r .ci/requirements_testing_minimal.txt + + - name: "Unit testing" + env: + ANSYSLMD_LICENSE_FILE: "1055@${{ secrets.license_server }}" + ON_STUDENT: ${{ steps.student_check.outputs.ON_STUDENT }} + file_name: ${{ inputs.file-name }} + ON_MINIMAL: ${{ inputs.testing-minimal }} + shell: bash + run: | + echo "ON_UBUNTU: $ON_UBUNTU" + echo "ON_STUDENT: $ON_STUDENT" + + # Because there is no 'ansys-tools-path' we need to input the + # executable path with the env var: PYMAPDL_MAPDL_EXEC. + + if [[ "${{ inputs.mapdl-version }}" == *"latest-ubuntu"* ]] ; then + version=${{ input.latest-version }} + else + version=$(echo "${{ inputs.mapdl-version }}" | head -c 5 | tail -c 4 | tr -d '.') + fi; + + echo "Version: $version" + + # If minimal is true, we need to set the executable path. + if [[ "${{ inputs.testing-minimal }}" == "true" ]]; then + echo "PYMAPDL_MAPDL_EXEC: $PYMAPDL_MAPDL_EXEC" + export PYMAPDL_MAPDL_EXEC=/ansys_inc/v"$version"/ansys/bin/ansys"$version" + export cmd="pytest" + else + export cmd="xvfb-run pytest" + fi; + + unset PYMAPDL_START_INSTANCE + unset PYMAPDL_PORT + + $cmd ${{ inputs.pytest-arguments }} \ + ${{ env.PYTEST_ARGUMENTS }} \ + --report-log=$file_name.jsonl \ + --cov-report=xml:$file_name.xml + + - name: "Collect logs on failure" + if: always() + env: + LOG_NAMES: logs-${{ inputs.file-name }} + shell: bash + run: | + .ci/collect_mapdl_logs_locals.sh + + - name: "Upload logs to GitHub" + if: always() + uses: actions/upload-artifact@master + with: + name: logs-${{ inputs.file-name }}.tgz + path: ./logs-${{ inputs.file-name }}.tgz + + - name: "Display files structure" + if: always() + env: + LOG_NAMES: logs-${{ inputs.file-name }} + shell: bash + run: | + .ci/display_logs_locals.sh + + - uses: codecov/codecov-action@v5 + name: "Upload coverage to Codecov" + with: + token: ${{ secrets.codecov_token }} # required + root_dir: ${{ github.workspace }} + name: ${{ inputs.file-name }}.xml + flags: ubuntu,local,${{ inputs.mapdl-version }},${{ inputs.tags }},${{ steps.student_check.outputs.TAG_STUDENT }},dmp + + - name: "Upload coverage artifacts" + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.file-name }}.xml + path: ./${{ inputs.file-name }}.xml + diff --git a/.github/workflows/test-remote.yml b/.github/workflows/test-remote.yml new file mode 100644 index 00000000000..507494add9f --- /dev/null +++ b/.github/workflows/test-remote.yml @@ -0,0 +1,248 @@ +# This action starts a MAPDL instance in a Docker container and runs the PyMAPDL test suite against it +name: | + Test PyMAPDL with remote MAPDL instances + +on: + workflow_call: + + inputs: + mapdl-version: + description: | + MAPDL version to test. + required: true + type: string + + file-name: + description: | + Name of the file to save the logs. + required: true + type: string + + secrets: + username: + description: | + Username for the GitHub container registry. + required: true + + password: + description: | + Password for the GitHub container registry. + required: true + + license-server: + description: | + License server for ANSYS MAPDL + required: true + + codecov-token: + description: | + Token for Codecov. + required: true + + +jobs: + test-remote: + runs-on: ubuntu-22.04 + env: + ON_CI: True + ON_LOCAL: FALSE + ON_UBUNTU: FALSE + PYMAPDL_START_INSTANCE: FALSE + PYMAPDL_PORT: 21000 # default won't work on GitHub runners + PYMAPDL_PORT2: 21001 # for the pool testing and default won't work on GitHub runners + PYMAPDL_DB_PORT: 21002 # default won't work on GitHub runners + PYMAPDL_DB_PORT2: 21003 # default won't work on GitHub runners + DPF_PORT: 21004 + 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' + MAIN_PYTHON_VERSION: '3.12' + + steps: + - name: "Login in Github container registry" + uses: docker/login-action@v3.3.0 + with: + registry: ghcr.io + username: ${{ secrets.username }} + password: ${{ secrets.password }} + + - name: "Getting SMP/DMP mode" + id: distributed_mode + shell: bash + run: | + image=${{ inputs.mapdl-version }} + export distributed_mode="smp" + if [[ $image == *".1."* ]]; then + export distributed_mode="dmp"; + fi + echo "Distributed mode: $distributed_mode" + echo "distributed_mode=$(echo $distributed_mode)" >> $GITHUB_OUTPUT + + - name: "Get if running on Ubuntu" + id: ubuntu_check + shell: bash + run: | + if [[ "${{ inputs.mapdl-version }}" == *"ubuntu"* ]]; + then export ON_UBUNTU=true; export TAG_UBUNTU="ubuntu"; + else export ON_UBUNTU=false; export TAG_UBUNTU="centos"; + fi + echo "ON_UBUNTU: $ON_UBUNTU" + echo "TAG_UBUNTU: $TAG_UBUNTU" + echo "ON_UBUNTU=$(echo $ON_UBUNTU)" >> $GITHUB_OUTPUT + echo "TAG_UBUNTU=$(echo $TAG_UBUNTU)" >> $GITHUB_OUTPUT + + - name: "Get if running student version" + id: student_check + shell: bash + run: | + if [[ "${{ inputs.mapdl-version }}" == *"student"* ]]; + then export ON_STUDENT=true; export TAG_STUDENT="student"; + else export ON_STUDENT=false; export TAG_STUDENT="non-student"; + fi + echo "ON_STUDENT: $ON_STUDENT" + echo "TAG_STUDENT: $TAG_STUDENT" + echo "ON_STUDENT=$(echo $ON_STUDENT)" >> $GITHUB_OUTPUT + echo "TAG_STUDENT=$(echo $TAG_STUDENT)" >> $GITHUB_OUTPUT + + - name: "Pull, launch, and validate MAPDL service" + id: start_mapdl + env: + LICENSE_SERVER: ${{ secrets.license_server }} + MAPDL_VERSION: ${{ inputs.mapdl-version }} + DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} + shell: bash + run: | + echo "Launching first MAPDL instance..." + export INSTANCE_NAME=MAPDL_0 + .ci/start_mapdl.sh &> mapdl_launch_0.log & export DOCKER_PID_0=$! + echo "Launching a second instance for MAPDL pool testing..." + export PYMAPDL_PORT=${{ env.PYMAPDL_PORT2 }} + export PYMAPDL_DB_PORT=${{ env.PYMAPDL_DB_PORT2 }} + export INSTANCE_NAME=MAPDL_1 + .ci/start_mapdl.sh &> mapdl_launch_1.log & export DOCKER_PID_1=$! + echo "Launching MAPDL service 0 at PID: $DOCKER_PID_0" + echo "Launching MAPDL service 1 at PID: $DOCKER_PID_2" + echo "DOCKER_PID_0=$(echo $DOCKER_PID_0)" >> $GITHUB_OUTPUT + echo "DOCKER_PID_1=$(echo $DOCKER_PID_1)" >> $GITHUB_OUTPUT + + - name: "DPF server activation" + shell: bash + run: | + $(docker pull ghcr.io/ansys/dpf-core:22.2dev && docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}.") & + + - name: "Getting files change filters" + uses: dorny/paths-filter@v3 + id: changes + with: + filters: | + workflows: + - '.github/workflows/**' + + - name: "Setup Python with cache" + uses: actions/setup-python@v5 + if: steps.changes.outputs.workflows != 'true' + with: + cache: 'pip' + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: "Setup Python without cache" + uses: actions/setup-python@v5 + if: steps.changes.outputs.workflows == 'true' + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: "Install os packages" + shell: bash + run: | + sudo apt update + sudo apt install libgl1-mesa-glx xvfb graphviz + + - name: "Test virtual framebuffer" + shell: bash + run: | + pip install -r .ci/requirements_test_xvfb.txt + xvfb-run python .ci/display_test.py + + - name: Install ansys-mapdl-core + shell: bash + run: | + python -m pip install build + python -m build + python -m pip install dist/*.whl + xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" + + - name: "Unit testing requirements installation" + shell: bash + run: | + python -m pip install .[tests] + + - name: "Waiting for the services to be up" + shell: bash + run: | + .ci/waiting_services.sh + + - name: "Unit testing" + env: + DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} + ON_UBUNTU: ${{ steps.ubuntu_check.outputs.ON_UBUNTU }} + ON_STUDENT: ${{ steps.student_check.outputs.ON_STUDENT }} + file_name: "${{ inputs.file-name }}" + shell: bash + run: | + echo "ON_UBUNTU: $ON_UBUNTU" + echo "ON_STUDENT: $ON_STUDENT" + xvfb-run pytest \ + ${{ env.PYTEST_ARGUMENTS }} \ + --ignore_image_cache \ + --report-log=$file_name.jsonl \ + --cov-report=xml:$file_name.xml + + - uses: codecov/codecov-action@v5 + name: "Upload coverage to Codecov" + with: + token: ${{ secrets.codecov-token }} # required + name: "${{ inputs.file-name }}.xml" + flags: remote,${{ steps.ubuntu_check.outputs.TAG_UBUNTU }},${{ inputs.mapdl-version }},${{ steps.distributed_mode.outputs.distributed_mode }},${{ steps.student_check.outputs.TAG_STUDENT }} + + - name: Upload coverage artifacts + uses: actions/upload-artifact@v4 + with: + name: "${{ inputs.file-name }}.xml" + path: "./${{ inputs.file-name }}.xml" + + - name: "Check package" + shell: bash + run: | + pip install twine + twine check dist/* + + - name: "Upload wheel and binaries" + uses: actions/upload-artifact@v4 + with: + name: PyMAPDL-packages-${{ inputs.mapdl-version }} + path: dist/ + retention-days: 7 + + - name: "Collect logs on failure" + if: always() + env: + MAPDL_VERSION: ${{ inputs.mapdl-version }} + MAPDL_INSTANCE: MAPDL_0 + LOG_NAMES: logs-${{ inputs.file-name }} + shell: bash + run: | + .ci/collect_mapdl_logs_remote.sh + + - name: "Upload logs to GitHub" + if: always() + uses: actions/upload-artifact@v4 + with: + name: logs-${{ inputs.file-name }}.tgz + path: ./logs-${{ inputs.file-name }}.tgz + + - name: "Display files structure" + if: always() + env: + MAPDL_INSTANCE: MAPDL_0 + LOG_NAMES: logs-${{ inputs.file-name }} + shell: bash + run: | + .ci/display_logs_remote.sh \ No newline at end of file From ed73d6dde58f16588c5cc9953b2336c9e18530cc Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Thu, 6 Mar 2025 22:39:29 +0000 Subject: [PATCH 18/40] chore: adding changelog file 3787.maintenance.md [dependabot-skip] --- doc/changelog.d/3787.maintenance.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/3787.maintenance.md diff --git a/doc/changelog.d/3787.maintenance.md b/doc/changelog.d/3787.maintenance.md new file mode 100644 index 00000000000..556e925954b --- /dev/null +++ b/doc/changelog.d/3787.maintenance.md @@ -0,0 +1 @@ +ci: using-reusable-workflows \ No newline at end of file From 0df4eb0e19d7d2582ffac9405ea8982ae6e7a5c6 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 23:44:04 +0100 Subject: [PATCH 19/40] fix: update latest-version to 252 in CI workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12bfd19e423..14ab6ed3b36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -222,7 +222,7 @@ jobs: mapdl-version: ${{ matrix.mapdl-version }} file-name: "${{ matrix.mapdl-version }}-local" tags: "local" - latest-version: ${{ env.LATEST_VERSION }} + latest-version: "252" build-test-ubuntu-minimal: name: "Local-min: ${{ matrix.mapdl-version }}" From 6659ce6557df8711c6139984c67c482ab4cde7d5 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 23:46:07 +0100 Subject: [PATCH 20/40] fix: update CI workflow to use 'username' instead of 'actor' and adjust mapdl-version syntax --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14ab6ed3b36..6674d623c26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -180,9 +180,9 @@ jobs: license-server: ${{ secrets.LICENSE_SERVER }} codecov-token: ${{ secrets.CODECOV_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }} - actor: ${{ github.actor }} + username: ${{ github.actor }} with: - mapdl-version: ${{ matrix.mapdl-version }} + mapdl-version: "${{ matrix.mapdl-version }}" file-name: "${{ matrix.mapdl-version }}-remote" build-test-local-matrix: From 54a8c19f5da6410627be940e938bed8b054ca103 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 23:48:56 +0100 Subject: [PATCH 21/40] fix: correct variable reference for latest-version in test-local workflow --- .github/workflows/test-local.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-local.yml b/.github/workflows/test-local.yml index 477ad116573..1941532e958 100644 --- a/.github/workflows/test-local.yml +++ b/.github/workflows/test-local.yml @@ -182,7 +182,7 @@ jobs: # executable path with the env var: PYMAPDL_MAPDL_EXEC. if [[ "${{ inputs.mapdl-version }}" == *"latest-ubuntu"* ]] ; then - version=${{ input.latest-version }} + version=${{ inputs.latest-version }} else version=$(echo "${{ inputs.mapdl-version }}" | head -c 5 | tail -c 4 | tr -d '.') fi; From 98ca1e6b1a910093ccdf81a1b5335fd246bfc65f Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 6 Mar 2025 23:50:13 +0100 Subject: [PATCH 22/40] fix: remove unused main-python-version input from test-local workflow --- .github/workflows/test-local.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/test-local.yml b/.github/workflows/test-local.yml index 1941532e958..2e8815ed420 100644 --- a/.github/workflows/test-local.yml +++ b/.github/workflows/test-local.yml @@ -50,12 +50,6 @@ on: Latest version of MAPDL. required: true type: string - - main-python-version: - description: | - Python version to test. - required: true - type: string secrets: license-server: From aff9e35d9a94b0c0b44f887c8e68dfbe472fbc11 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 00:02:37 +0100 Subject: [PATCH 23/40] fix: update test-local workflow to streamline input parameters and improve boolean checks --- .github/workflows/test-local.yml | 43 +++++++++++++------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/.github/workflows/test-local.yml b/.github/workflows/test-local.yml index 2e8815ed420..f75a07cee5b 100644 --- a/.github/workflows/test-local.yml +++ b/.github/workflows/test-local.yml @@ -11,13 +11,12 @@ on: MAPDL version to test. required: true type: string - - minimal: + + latest-version: description: | - If true, the minimal requirements will be installed. - required: false - type: boolean - default: false + Latest version of MAPDL. + required: true + type: string pytest-arguments: description: | @@ -26,6 +25,13 @@ on: type: string default: "" + testing-minimal: + description: | + If true, the minimal requirements will be installed. + required: false + type: boolean + default: false + file-name: description: | Name of the file to save the logs. @@ -38,19 +44,6 @@ on: required: true type: string - testing-minimal: - description: | - If true, the minimal requirements will be installed. - required: false - type: boolean - default: false - - latest-version: - description: | - Latest version of MAPDL. - required: true - type: string - secrets: license-server: description: | @@ -111,13 +104,13 @@ jobs: - name: "Installing minimal OS packages" shell: bash - if: inputs.testing-minimal == 'true' + if: inputs.testing-minimal == true run: | sudo apt-get update && apt install -y libgomp1 graphviz - name: "Installing OS packages" shell: bash - if: inputs.testing-minimal == 'false' + if: inputs.testing-minimal == false run: | sudo apt-get update && apt install -y libgl1-mesa-glx xvfb libgomp1 graphviz @@ -133,7 +126,7 @@ jobs: python -m pip install --upgrade pip - name: "Install ansys-mapdl-core" - if: inputs.testing-minimal == 'false' + if: inputs.testing-minimal == false shell: bash run: | python -m pip install build @@ -143,20 +136,20 @@ jobs: - name: "Install ansys-mapdl-core with minimal requirements" shell: bash - if: inputs.testing-minimal == 'true' + if: inputs.testing-minimal == true run: | python -m pip install . --no-deps python -m pip install -r minimum_requirements.txt python -c "from ansys.mapdl import core as pymapdl; print('Import successfull')" - name: "Unit testing requirements installation" - if: inputs.testing-minimal == 'false' + if: inputs.testing-minimal == false shell: bash run: | python -m pip install .[tests] - name: "Unit testing requirements installation" - if: inputs.testing-minimal == 'true' + if: inputs.testing-minimal == true shell: bash run: | python -m pip install -r .ci/requirements_testing_minimal.txt From dbcb806ed01a19f14f1a63c55fa9388651408947 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 00:03:17 +0100 Subject: [PATCH 24/40] fix: add directory listing to test-remote workflow for better debugging --- .github/workflows/test-remote.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-remote.yml b/.github/workflows/test-remote.yml index 507494add9f..78a8aac2a11 100644 --- a/.github/workflows/test-remote.yml +++ b/.github/workflows/test-remote.yml @@ -158,6 +158,7 @@ jobs: - name: "Test virtual framebuffer" shell: bash run: | + ls -laR . pip install -r .ci/requirements_test_xvfb.txt xvfb-run python .ci/display_test.py From 0a16b01887fda04eabc27e19db7215cbd1721a82 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 00:29:12 +0100 Subject: [PATCH 25/40] fix: tests --- .github/workflows/ci.yml | 2 +- .github/workflows/test-local.yml | 6 +++--- .github/workflows/test-remote.yml | 3 +++ tests/test_mapdl.py | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6674d623c26..589d39e6ec2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -214,7 +214,7 @@ jobs: secrets: license-server: ${{ secrets.LICENSE_SERVER }} codecov-token: ${{ secrets.CODECOV_TOKEN }} - github-token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} actor: ${{ github.actor }} with: testing-minimal: false diff --git a/.github/workflows/test-local.yml b/.github/workflows/test-local.yml index f75a07cee5b..8490e3b0191 100644 --- a/.github/workflows/test-local.yml +++ b/.github/workflows/test-local.yml @@ -55,7 +55,7 @@ on: Token for Codecov. required: true - github-token: + token: description: | Token for GitHub. required: true @@ -156,7 +156,7 @@ jobs: - name: "Unit testing" env: - ANSYSLMD_LICENSE_FILE: "1055@${{ secrets.license_server }}" + ANSYSLMD_LICENSE_FILE: "1055@${{ secrets.license-server }}" ON_STUDENT: ${{ steps.student_check.outputs.ON_STUDENT }} file_name: ${{ inputs.file-name }} ON_MINIMAL: ${{ inputs.testing-minimal }} @@ -219,7 +219,7 @@ jobs: - uses: codecov/codecov-action@v5 name: "Upload coverage to Codecov" with: - token: ${{ secrets.codecov_token }} # required + token: ${{ secrets.codecov-token }} # required root_dir: ${{ github.workspace }} name: ${{ inputs.file-name }}.xml flags: ubuntu,local,${{ inputs.mapdl-version }},${{ inputs.tags }},${{ steps.student_check.outputs.TAG_STUDENT }},dmp diff --git a/.github/workflows/test-remote.yml b/.github/workflows/test-remote.yml index 78a8aac2a11..bd8f31c22be 100644 --- a/.github/workflows/test-remote.yml +++ b/.github/workflows/test-remote.yml @@ -57,6 +57,9 @@ jobs: MAIN_PYTHON_VERSION: '3.12' steps: + - name: "Install Git and checkout project" + uses: actions/checkout@v4.2.2 + - name: "Login in Github container registry" uses: docker/login-action@v3.3.0 with: diff --git a/tests/test_mapdl.py b/tests/test_mapdl.py index 38d1f378223..b7078cd2bde 100644 --- a/tests/test_mapdl.py +++ b/tests/test_mapdl.py @@ -1225,6 +1225,9 @@ def test_cwd(mapdl, cleared, tmpdir): finally: mapdl.cwd(old_path) + # we need to flush the error output + mapdl.slashdelete("anstmp") + @requires("nocicd") @requires("local") From ce3ec83617d451d4323c4139086bce258a5c4e6b Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 00:33:21 +0100 Subject: [PATCH 26/40] fix: add pytest arguments to enhance test execution and reporting --- .github/workflows/test-local.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-local.yml b/.github/workflows/test-local.yml index 8490e3b0191..ffaa6a9c80e 100644 --- a/.github/workflows/test-local.yml +++ b/.github/workflows/test-local.yml @@ -76,6 +76,7 @@ jobs: MAIN_PYTHON_VERSION: "3.12" P_SCHEMA: "/ansys_inc/v241/ansys/ac4/schema" PYTEST_TIMEOUT: 120 # seconds. Limit the duration for each unit test + 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' container: image: ghcr.io/ansys/mapdl:${{ inputs.mapdl-version }} From dfbeba630ac9d353a4bc493709a761c2be9672c9 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 00:33:49 +0100 Subject: [PATCH 27/40] fix: remove some composite actions --- .github/actions/doc-build/action.yml | 227 ------------------------ .github/actions/test-local/action.yml | 199 --------------------- .github/actions/test-remote/action.yml | 235 ------------------------- 3 files changed, 661 deletions(-) delete mode 100644 .github/actions/doc-build/action.yml delete mode 100644 .github/actions/test-local/action.yml delete mode 100644 .github/actions/test-remote/action.yml diff --git a/.github/actions/doc-build/action.yml b/.github/actions/doc-build/action.yml deleted file mode 100644 index 41d15245f45..00000000000 --- a/.github/actions/doc-build/action.yml +++ /dev/null @@ -1,227 +0,0 @@ -name: "Documentation Build" - -description: | - This action builds the documentation for PyMAPDL. - -inputs: - - license_server: - description: | - License server for ANSYS MAPDL - required: true - type: string - - username: - description: | - Username for the GitHub container registry. - required: true - type: string - - password: - description: | - Password for the GitHub container registry. - required: true - type: string - -runs: - using: "composite" - steps: - - - name: "Login in Github container registry" - uses: docker/login-action@v3.3.0 - with: - registry: ghcr.io - username: ${{ inputs.username }} - password: ${{ inputs.password }} - - - name: "Pull, launch, and validate MAPDL service" - id: start_mapdl - env: - LICENSE_SERVER: ${{ inputs.license_server }} - MAPDL_VERSION: ${{ env.MAPDL_IMAGE_VERSION_DOCS_BUILD }} - DISTRIBUTED_MODE: "dmp" - shell: bash - run: | - export INSTANCE_NAME=MAPDL_0 - .ci/start_mapdl.sh &> mapdl_launch.log & export DOCKER_PID=$! - echo "Launching MAPDL service at PID: $DOCKER_PID" - echo "DOCKER_PID=$(echo $DOCKER_PID)" >> $GITHUB_OUTPUT - - - name: "DPF server activation" - shell: bash - run: | - $(docker pull ghcr.io/ansys/dpf-core:22.2dev && docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}.") & - - - name: "Getting files change filters" - uses: dorny/paths-filter@v3 - id: changes - with: - filters: | - workflows: - - '.github/workflows/**' - - 'pyproject.toml' - examples: - - 'examples/**' - - 'pyproject.toml' - documentation: - - 'examples/**' - - 'doc/**' - - 'pyproject.toml' - - - name: "Setup Python with cache" - uses: actions/setup-python@v5 - if: steps.changes.outputs.workflows != 'true' - with: - cache: 'pip' - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: "Setup Python without cache" - uses: actions/setup-python@v5 - if: steps.changes.outputs.workflows == 'true' - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: "Install OS packages" - shell: bash - run: | - sudo apt update && sudo apt install zip pandoc libgl1-mesa-glx xvfb texlive-latex-extra latexmk graphviz texlive-xetex texlive-fonts-extra qpdf xindy - - - name: "Test virtual framebuffer" - shell: bash - run: | - pip install -r .ci/requirements_test_xvfb.txt - xvfb-run python .ci/display_test.py - - - name: "Install ansys-mapdl-core" - shell: bash - run: | - pip install . - xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" - - - name: "Retrieve PyMAPDL version" - id: version - shell: bash - run: | - echo "PYMAPDL_VERSION=$(python -c 'from ansys.mapdl.core import __version__; print(__version__)')" >> $GITHUB_OUTPUT - echo "PyMAPDL version is: $(python -c "from ansys.mapdl.core import __version__; print(__version__)")" - - - name: "Cache examples" - uses: actions/cache@v4 - if: steps.changes.outputs.documentation == 'false' || (github.ref == 'refs/heads/main' && !contains(github.ref, 'refs/tags')) - with: - path: doc/source/examples - key: Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }} - restore-keys: | - Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }} - - - name: "Cache docs build directory" - uses: actions/cache@v4 - if: steps.changes.outputs.documentation == 'false' || (github.ref == 'refs/heads/main' && !contains(github.ref, 'refs/tags')) - with: - path: doc/_build - key: doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }} - restore-keys: | - doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }} - - - name: "Cache autosummary" - uses: actions/cache@v4 - if: steps.changes.outputs.documentation == 'false' || (github.ref == 'refs/heads/main' && !contains(github.ref, 'refs/tags')) - with: - path: doc/source/**/_autosummary/*.rst - key: autosummary-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }} - restore-keys: | - autosummary-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ steps.version.outputs.PYMAPDL_VERSION }} - - - name: "Install docs build requirements" - shell: bash - run: | - pip uninstall ansys-sphinx-theme - pip install .[doc] - - - name: "Waiting for the services to be up" - shell: bash - run: | - .ci/waiting_services.sh - - - name: Install Quarto - uses: quarto-dev/quarto-actions/setup@v2 - with: - tinytex: true - - - name: Check Quarto Version - shell: bash - run: | - quarto --version - - - name: "Install Poppler for PDF to PNG conversion" - shell: bash - run: | - sudo apt-get update - sudo apt-get install -y poppler-utils - - - name: "Build documentation" - shell: bash - run: | - xvfb-run make -C doc html SPHINXOPTS="-j auto -W --keep-going" - - - name: "Substitute defective GIF" - shell: bash - run: | - .ci/substitute_defective_gif.sh - - - name: "Upload HTML Documentation" - uses: actions/upload-artifact@v4 - with: - name: documentation-html - path: doc/_build/html - retention-days: 7 - - - name: "Build PDF Documentation" - working-directory: doc - shell: bash - run: make pdf - - - name: "Show latex dir" - working-directory: doc - shell: bash - run: ls _build/latex - - - name: "Upload PDF documentation" - uses: actions/upload-artifact@v4 - with: - name: documentation-pdf - path: doc/_build/latex/pymapdl*.pdf - retention-days: 7 - - - name: "Upload minimal requirements file" - # To include it in the release - uses: actions/upload-artifact@v4 - with: - name: minimum_requirements.txt - path: ./minimum_requirements.txt - - - name: "Collect logs on failure" - if: always() - env: - MAPDL_VERSION: ${{ env.MAPDL_IMAGE_VERSION_DOCS_BUILD }} - MAPDL_INSTANCE: MAPDL_0 - LOG_NAMES: logs-build-docs - shell: bash - run: | - .ci/collect_mapdl_logs_remote.sh - - - name: "Upload logs to GitHub" - if: always() - uses: actions/upload-artifact@master - with: - name: logs-build-docs.tgz - path: ./logs-build-docs.tgz - - - name: "Display files structure" - if: always() - env: - MAPDL_INSTANCE: MAPDL_0 - LOG_NAMES: logs-build-docs - shell: bash - run: | - .ci/display_logs_remote.sh \ No newline at end of file diff --git a/.github/actions/test-local/action.yml b/.github/actions/test-local/action.yml deleted file mode 100644 index 2abc94bc8ea..00000000000 --- a/.github/actions/test-local/action.yml +++ /dev/null @@ -1,199 +0,0 @@ -name: "Local testing" - -description: | - This action tests PyMAPDL with MAPDL running locally. - It does support running with minimal requirements and with console interface. - -inputs: - - mapdl-version: - description: | - MAPDL version to test. - required: true - type: string - - license_server: - description: | - License server for ANSYS MAPDL - required: true - type: string - - minimal: - description: | - If true, the minimal requirements will be installed. - required: false - type: boolean - default: false - - pytest-arguments: - description: | - Arguments to pass to pytest, additionally to the ones in the environment variable PYTEST_ARGUMENTS. - required: false - type: string - default: "" - - file-name: - description: | - Name of the file to save the logs. - required: true - type: string - - codecov_token: - description: | - Token for Codecov. - required: true - type: string - - tags: - description: | - Tags to add to the coverage report. - required: true - type: string - - -runs: - using: "composite" - steps: - - - name: "Get if running student version" - id: student_check - shell: bash - run: | - if [[ "${{ inputs.mapdl-version }}" == *"student"* ]]; - then export ON_STUDENT=true; export TAG_STUDENT="student"; - else export ON_STUDENT=false; export TAG_STUDENT="non-student"; - fi - - echo "ON_STUDENT: $ON_STUDENT" - echo "TAG_STUDENT: $TAG_STUDENT" - echo "ON_STUDENT=$(echo $ON_STUDENT)" >> $GITHUB_OUTPUT - echo "TAG_STUDENT=$(echo $TAG_STUDENT)" >> $GITHUB_OUTPUT - - - name: "Installing minimal OS packages" - shell: bash - if: inputs.minimal == 'true' - run: | - sudo apt-get update && apt install -y libgomp1 graphviz - - - name: "Installing OS packages" - shell: bash - if: inputs.minimal == 'false' - run: | - sudo apt-get update && apt install -y libgl1-mesa-glx xvfb libgomp1 graphviz - - - name: "Setup Python" - uses: actions/setup-python@v5 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: "Checking Python" - shell: bash - run: | - python --version - python -m pip install --upgrade pip - - - name: "Install ansys-mapdl-core" - if: inputs.minimal == 'false' - shell: bash - run: | - python -m pip install build - python -m build - python -m pip install dist/*.whl - xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" - - - name: "Install ansys-mapdl-core with minimal requirements" - shell: bash - if: inputs.minimal == 'true' - run: | - python -m pip install . --no-deps - python -m pip install -r minimum_requirements.txt - python -c "from ansys.mapdl import core as pymapdl; print('Import successfull')" - - - name: "Unit testing requirements installation" - if: inputs.minimal == 'false' - shell: bash - run: | - python -m pip install .[tests] - - - name: "Unit testing requirements installation" - if: inputs.minimal == 'true' - shell: bash - run: | - python -m pip install -r .ci/requirements_testing_minimal.txt - - - name: "Unit testing" - env: - ANSYSLMD_LICENSE_FILE: "1055@${{ inputs.license_server }}" - ON_STUDENT: ${{ steps.student_check.outputs.ON_STUDENT }} - file_name: ${{ inputs.file-name }} - ON_MINIMAL: ${{ inputs.minimal }} - shell: bash - run: | - echo "ON_UBUNTU: $ON_UBUNTU" - echo "ON_STUDENT: $ON_STUDENT" - - # Because there is no 'ansys-tools-path' we need to input the - # executable path with the env var: PYMAPDL_MAPDL_EXEC. - - if [[ "${{ inputs.mapdl-version }}" == *"latest-ubuntu"* ]] ; then - version=${{ env.LATEST_VERSION }} - else - version=$(echo "${{ inputs.mapdl-version }}" | head -c 5 | tail -c 4 | tr -d '.') - fi; - - echo "Version: $version" - - # If minimal is true, we need to set the executable path. - if [[ "${{ inputs.minimal }}" == "true" ]]; then - echo "PYMAPDL_MAPDL_EXEC: $PYMAPDL_MAPDL_EXEC" - export PYMAPDL_MAPDL_EXEC=/ansys_inc/v"$version"/ansys/bin/ansys"$version" - export cmd="pytest" - else - export cmd="xvfb-run pytest" - fi; - - unset PYMAPDL_START_INSTANCE - unset PYMAPDL_PORT - - $cmd ${{ inputs.pytest-arguments }} \ - ${{ env.PYTEST_ARGUMENTS }} \ - --report-log=$file_name.jsonl \ - --cov-report=xml:$file_name.xml - - - name: "Collect logs on failure" - if: always() - env: - LOG_NAMES: logs-${{ inputs.file-name }} - shell: bash - run: | - .ci/collect_mapdl_logs_locals.sh - - - name: "Upload logs to GitHub" - if: always() - uses: actions/upload-artifact@master - with: - name: logs-${{ inputs.file-name }}.tgz - path: ./logs-${{ inputs.file-name }}.tgz - - - name: "Display files structure" - if: always() - env: - LOG_NAMES: logs-${{ inputs.file-name }} - shell: bash - run: | - .ci/display_logs_locals.sh - - - uses: codecov/codecov-action@v5 - name: "Upload coverage to Codecov" - with: - token: ${{ inputs.codecov_token }} # required - root_dir: ${{ github.workspace }} - name: ${{ inputs.file-name }}.xml - flags: ubuntu,local,${{ inputs.mapdl-version }},${{ inputs.tags }},${{ steps.student_check.outputs.TAG_STUDENT }},dmp - - - name: "Upload coverage artifacts" - uses: actions/upload-artifact@v4 - with: - name: ${{ inputs.file-name }}.xml - path: ./${{ inputs.file-name }}.xml - diff --git a/.github/actions/test-remote/action.yml b/.github/actions/test-remote/action.yml deleted file mode 100644 index 748459ef654..00000000000 --- a/.github/actions/test-remote/action.yml +++ /dev/null @@ -1,235 +0,0 @@ - -name: | - Test PyMAPDL with remote MAPDL instances - -description: | - This action starts a MAPDL instance in a Docker container and runs the PyMAPDL test suite against it - -inputs: - - # Required inputs - - mapdl-version: - description: | - MAPDL version to test. - required: true - type: string - - username: - description: | - Username for the GitHub container registry. - required: true - type: string - - password: - description: | - Password for the GitHub container registry. - required: true - type: string - - license_server: - description: | - License server for ANSYS MAPDL - required: true - type: string - - codecov_token: - description: | - Token for Codecov. - required: true - type: string - - -runs: - using: "composite" - - steps: - - name: "Login in Github container registry" - uses: docker/login-action@v3.3.0 - with: - registry: ghcr.io - username: ${{ inputs.username }} - password: ${{ inputs.password }} - - - name: "Getting SMP/DMP mode" - id: distributed_mode - shell: bash - run: | - image=${{ inputs.mapdl-version }} - export distributed_mode="smp" - if [[ $image == *".1."* ]]; then - export distributed_mode="dmp"; - fi - echo "Distributed mode: $distributed_mode" - echo "distributed_mode=$(echo $distributed_mode)" >> $GITHUB_OUTPUT - - - name: "Get if running on Ubuntu" - id: ubuntu_check - shell: bash - run: | - if [[ "${{ inputs.mapdl-version }}" == *"ubuntu"* ]]; - then export ON_UBUNTU=true; export TAG_UBUNTU="ubuntu"; - else export ON_UBUNTU=false; export TAG_UBUNTU="centos"; - fi - echo "ON_UBUNTU: $ON_UBUNTU" - echo "TAG_UBUNTU: $TAG_UBUNTU" - echo "ON_UBUNTU=$(echo $ON_UBUNTU)" >> $GITHUB_OUTPUT - echo "TAG_UBUNTU=$(echo $TAG_UBUNTU)" >> $GITHUB_OUTPUT - - - name: "Get if running student version" - id: student_check - shell: bash - run: | - if [[ "${{ inputs.mapdl-version }}" == *"student"* ]]; - then export ON_STUDENT=true; export TAG_STUDENT="student"; - else export ON_STUDENT=false; export TAG_STUDENT="non-student"; - fi - echo "ON_STUDENT: $ON_STUDENT" - echo "TAG_STUDENT: $TAG_STUDENT" - echo "ON_STUDENT=$(echo $ON_STUDENT)" >> $GITHUB_OUTPUT - echo "TAG_STUDENT=$(echo $TAG_STUDENT)" >> $GITHUB_OUTPUT - - - name: "Pull, launch, and validate MAPDL service" - id: start_mapdl - env: - LICENSE_SERVER: ${{ inputs.license_server }} - MAPDL_VERSION: ${{ inputs.mapdl-version }} - DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} - shell: bash - run: | - echo "Launching first MAPDL instance..." - export INSTANCE_NAME=MAPDL_0 - .ci/start_mapdl.sh &> mapdl_launch_0.log & export DOCKER_PID_0=$! - echo "Launching a second instance for MAPDL pool testing..." - export PYMAPDL_PORT=${{ env.PYMAPDL_PORT2 }} - export PYMAPDL_DB_PORT=${{ env.PYMAPDL_DB_PORT2 }} - export INSTANCE_NAME=MAPDL_1 - .ci/start_mapdl.sh &> mapdl_launch_1.log & export DOCKER_PID_1=$! - echo "Launching MAPDL service 0 at PID: $DOCKER_PID_0" - echo "Launching MAPDL service 1 at PID: $DOCKER_PID_2" - echo "DOCKER_PID_0=$(echo $DOCKER_PID_0)" >> $GITHUB_OUTPUT - echo "DOCKER_PID_1=$(echo $DOCKER_PID_1)" >> $GITHUB_OUTPUT - - - name: "DPF server activation" - shell: bash - run: | - $(docker pull ghcr.io/ansys/dpf-core:22.2dev && docker run -d --name dpfserver -p ${{ env.DPF_PORT }}:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port ${{ env.DPF_PORT }}.") & - - - name: "Getting files change filters" - uses: dorny/paths-filter@v3 - id: changes - with: - filters: | - workflows: - - '.github/workflows/**' - - - name: "Setup Python with cache" - uses: actions/setup-python@v5 - if: steps.changes.outputs.workflows != 'true' - with: - cache: 'pip' - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: "Setup Python without cache" - uses: actions/setup-python@v5 - if: steps.changes.outputs.workflows == 'true' - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - - - name: "Install os packages" - shell: bash - run: | - sudo apt update - sudo apt install libgl1-mesa-glx xvfb graphviz - - - name: "Test virtual framebuffer" - shell: bash - run: | - pip install -r .ci/requirements_test_xvfb.txt - xvfb-run python .ci/display_test.py - - - name: Install ansys-mapdl-core - shell: bash - run: | - python -m pip install build - python -m build - python -m pip install dist/*.whl - xvfb-run python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())" - - - name: "Unit testing requirements installation" - shell: bash - run: | - python -m pip install .[tests] - - - name: "Waiting for the services to be up" - shell: bash - run: | - .ci/waiting_services.sh - - - name: "Unit testing" - env: - DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} - ON_UBUNTU: ${{ steps.ubuntu_check.outputs.ON_UBUNTU }} - ON_STUDENT: ${{ steps.student_check.outputs.ON_STUDENT }} - file_name: "${{ inputs.mapdl-version }}-remote" - shell: bash - run: | - echo "ON_UBUNTU: $ON_UBUNTU" - echo "ON_STUDENT: $ON_STUDENT" - xvfb-run pytest \ - ${{ env.PYTEST_ARGUMENTS }} \ - --ignore_image_cache \ - --report-log=$file_name.jsonl \ - --cov-report=xml:$file_name.xml - - - uses: codecov/codecov-action@v5 - name: "Upload coverage to Codecov" - with: - token: ${{ inputs.codecov_token }} # required - name: ${{ inputs.mapdl-version }}-remote.xml - flags: remote,${{ steps.ubuntu_check.outputs.TAG_UBUNTU }},${{ inputs.mapdl-version }},${{ steps.distributed_mode.outputs.distributed_mode }},${{ steps.student_check.outputs.TAG_STUDENT }} - - - name: Upload coverage artifacts - uses: actions/upload-artifact@v4 - with: - name: ${{ inputs.mapdl-version }}-remote.xml - path: ./${{ inputs.mapdl-version }}-remote.xml - - - name: "Check package" - shell: bash - run: | - pip install twine - twine check dist/* - - - name: "Upload wheel and binaries" - uses: actions/upload-artifact@v4 - with: - name: PyMAPDL-packages-${{ inputs.mapdl-version }} - path: dist/ - retention-days: 7 - - - name: "Collect logs on failure" - if: always() - env: - MAPDL_VERSION: ${{ inputs.mapdl-version }} - MAPDL_INSTANCE: MAPDL_0 - LOG_NAMES: logs-remote-${{ inputs.mapdl-version }} - shell: bash - run: | - .ci/collect_mapdl_logs_remote.sh - - - name: "Upload logs to GitHub" - if: always() - uses: actions/upload-artifact@v4 - with: - name: logs-remote-${{ inputs.mapdl-version }}.tgz - path: ./logs-remote-${{ inputs.mapdl-version }}.tgz - - - name: "Display files structure" - if: always() - env: - MAPDL_INSTANCE: MAPDL_0 - LOG_NAMES: logs-remote-${{ inputs.mapdl-version }} - shell: bash - run: | - .ci/display_logs_remote.sh \ No newline at end of file From 6ee5f5c365ed033073de1fa0dd1e000acd998d8d Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 00:35:43 +0100 Subject: [PATCH 28/40] fix: update password secret reference in test-local workflow --- .github/workflows/test-local.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-local.yml b/.github/workflows/test-local.yml index ffaa6a9c80e..8c5775df064 100644 --- a/.github/workflows/test-local.yml +++ b/.github/workflows/test-local.yml @@ -83,7 +83,7 @@ jobs: options: -u=0:0 --oom-kill-disable --memory=6656MB --memory-swap=16896MB --shm-size=1gb --entrypoint /bin/bash credentials: username: ${{ secrets.actor }} - password: ${{ secrets.github-token }} + password: ${{ secrets.token }} steps: - name: "Install Git and checkout project" From f0915b97f4f5e6d96308755764540e8a7f130de0 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 00:37:17 +0100 Subject: [PATCH 29/40] fix: rename password secret to token in CI workflows for clarity --- .github/workflows/ci.yml | 2 +- .github/workflows/test-remote.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 589d39e6ec2..00222fbf75a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -179,7 +179,7 @@ jobs: secrets: license-server: ${{ secrets.LICENSE_SERVER }} codecov-token: ${{ secrets.CODECOV_TOKEN }} - password: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} username: ${{ github.actor }} with: mapdl-version: "${{ matrix.mapdl-version }}" diff --git a/.github/workflows/test-remote.yml b/.github/workflows/test-remote.yml index bd8f31c22be..7314ff81cee 100644 --- a/.github/workflows/test-remote.yml +++ b/.github/workflows/test-remote.yml @@ -24,9 +24,9 @@ on: Username for the GitHub container registry. required: true - password: + token: description: | - Password for the GitHub container registry. + Token for GitHub. required: true license-server: @@ -65,7 +65,7 @@ jobs: with: registry: ghcr.io username: ${{ secrets.username }} - password: ${{ secrets.password }} + password: ${{ secrets.token }} - name: "Getting SMP/DMP mode" id: distributed_mode From d23282f73d3575689ac510442a0d3ce8a7c7e5b1 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 00:41:35 +0100 Subject: [PATCH 30/40] fix: add step to install Git and checkout project in doc-build workflow --- .github/workflows/doc-build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index a8096037c39..4536151d0ac 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -34,7 +34,11 @@ jobs: ON_DOCUMENTATION: TRUE GRPC_ENABLE_FORK_SUPPORT: false # See #3434 DPF_PORT: 21004 + steps: + - name: "Install Git and checkout project" + uses: actions/checkout@v4.2.2 + - name: "Login in Github container registry" uses: docker/login-action@v3.3.0 with: From 3f59acaf56e196f36c74bfc064df37315cb73f6c Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 00:56:07 +0100 Subject: [PATCH 31/40] fix: standardize license server secret naming in workflows --- .github/workflows/doc-build.yml | 5 +++-- .github/workflows/test-remote.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 4536151d0ac..ce28bc1baa0 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -7,7 +7,7 @@ on: # Secrets secrets: - license_server: + license-server: description: | License server for ANSYS MAPDL required: true @@ -34,6 +34,7 @@ jobs: ON_DOCUMENTATION: TRUE GRPC_ENABLE_FORK_SUPPORT: false # See #3434 DPF_PORT: 21004 + MAIN_PYTHON_VERSION: "3.12" steps: - name: "Install Git and checkout project" @@ -49,7 +50,7 @@ jobs: - name: "Pull, launch, and validate MAPDL service" id: start_mapdl env: - LICENSE_SERVER: ${{ secrets.license_server }} + LICENSE_SERVER: ${{ secrets.license-server }} MAPDL_VERSION: ${{ env.MAPDL_IMAGE_VERSION_DOCS_BUILD }} DISTRIBUTED_MODE: "dmp" shell: bash diff --git a/.github/workflows/test-remote.yml b/.github/workflows/test-remote.yml index 7314ff81cee..8209bb03d1a 100644 --- a/.github/workflows/test-remote.yml +++ b/.github/workflows/test-remote.yml @@ -108,7 +108,7 @@ jobs: - name: "Pull, launch, and validate MAPDL service" id: start_mapdl env: - LICENSE_SERVER: ${{ secrets.license_server }} + LICENSE_SERVER: ${{ secrets.license-server }} MAPDL_VERSION: ${{ inputs.mapdl-version }} DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} shell: bash From eccbfbb8914ba040253e6cfd024c8534e1e2303e Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 01:00:11 +0100 Subject: [PATCH 32/40] fix: standardize license server secret naming in CI workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00222fbf75a..d2fc0154937 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -146,7 +146,7 @@ jobs: needs: doc-style uses: ./.github/workflows/doc-build.yml secrets: - license_server: ${{ secrets.LICENSE_SERVER }} + license-server: ${{ secrets.LICENSE_SERVER }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} From d2bb91149a60376d958e95df2bf5fb6c34c201c1 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 01:16:21 +0100 Subject: [PATCH 33/40] fix: add MAPDL package and environment variables in test-remote workflow --- .github/workflows/test-remote.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test-remote.yml b/.github/workflows/test-remote.yml index 8209bb03d1a..b9618ac36cf 100644 --- a/.github/workflows/test-remote.yml +++ b/.github/workflows/test-remote.yml @@ -55,6 +55,7 @@ jobs: DPF_PORT: 21004 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' MAIN_PYTHON_VERSION: '3.12' + MAPDL_PACKAGE: ghcr.io/ansys/mapdl steps: - name: "Install Git and checkout project" @@ -180,6 +181,9 @@ jobs: - name: "Waiting for the services to be up" shell: bash + env: + PYMAPDL_PORT: ${{ env.PYMAPDL_PORT }} + PYMAPDL_PORT2: ${{ env.PYMAPDL_PORT2 }} run: | .ci/waiting_services.sh From d288db468101823e73ccc8704f4ca4bd1bc6ae08 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 10:50:38 +0100 Subject: [PATCH 34/40] fix: update CI workflows to use reusable workflows for minimal and console --- .github/workflows/ci.yml | 94 ++++++++++---------------------- .github/workflows/test-local.yml | 20 +++++-- 2 files changed, 44 insertions(+), 70 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2fc0154937..9f1a43cdf71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -215,7 +215,7 @@ jobs: license-server: ${{ secrets.LICENSE_SERVER }} codecov-token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }} - actor: ${{ github.actor }} + username: ${{ github.actor }} with: testing-minimal: false pytest-arguments: '-k "not test_dpf" --reset_only_failed --add_missing_images' @@ -226,83 +226,49 @@ jobs: build-test-ubuntu-minimal: name: "Local-min: ${{ matrix.mapdl-version }}" - runs-on: ubuntu-22.04 if: github.ref != 'refs/heads/main' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - needs: [build-test-ubuntu-local, build-test-remote] - timeout-minutes: 75 + # needs: [build-test-ubuntu-local, build-test-remote] + uses: ./.github/workflows/test-local.yml strategy: fail-fast: false matrix: mapdl-version: ['latest-ubuntu', 'v25.1-ubuntu'] - container: - image: ghcr.io/ansys/mapdl:${{ matrix.mapdl-version }} - options: -u=0:0 --oom-kill-disable --memory=6656MB --memory-swap=16896MB --shm-size=1gb --entrypoint /bin/bash - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - env: - ON_LOCAL: true - ON_UBUNTU: true - TESTING_MINIMAL: true - - steps: - - name: "Install Git and checkout project" - uses: actions/checkout@v4.2.2 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - - name: "Run Pytest for ${{ matrix.mapdl-version }} on local mode using minimal configuration" - uses: ./.github/actions/test-local - with: - mapdl-version: ${{ matrix.mapdl-version }} - minimal: true - license_server: ${{ secrets.LICENSE_SERVER }} - pytest-arguments: '-k "not test_dpf"' - file-name: "${{ matrix.mapdl-version }}-minimal" - tags: "local,minimal" - codecov_token: ${{ secrets.CODECOV_TOKEN }} + secrets: + license-server: ${{ secrets.LICENSE_SERVER }} + codecov-token: ${{ secrets.CODECOV_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} + username: ${{ github.actor }} + with: + testing-minimal: true + pytest-arguments: '-k "not test_dpf" --reset_only_failed --add_missing_images' + mapdl-version: ${{ matrix.mapdl-version }} + file-name: "${{ matrix.mapdl-version }}-minimal" + tags: "local,minimal" + latest-version: "252" build-test-ubuntu-console: name: "Local-min-console: ${{ matrix.mapdl-version }}" - runs-on: ubuntu-22.04 if: github.ref != 'refs/heads/main' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - needs: [build-test-ubuntu-local, build-test-remote] - timeout-minutes: 75 + # needs: [build-test-ubuntu-local, build-test-remote] + uses: ./.github/workflows/test-local.yml strategy: fail-fast: false matrix: mapdl-version: ['latest-ubuntu', 'v25.1-ubuntu'] - container: - image: ghcr.io/ansys/mapdl:${{ matrix.mapdl-version }} - options: -u=0:0 --oom-kill-disable --memory=6656MB --memory-swap=16896MB --shm-size=1gb --entrypoint /bin/bash - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - env: - ON_LOCAL: true - ON_UBUNTU: true - TESTING_MINIMAL: true - ON_CONSOLE: true - - steps: - - name: "Install Git and checkout project" - uses: actions/checkout@v4.2.2 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} + secrets: + license-server: ${{ secrets.LICENSE_SERVER }} + codecov-token: ${{ secrets.CODECOV_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} + username: ${{ github.actor }} + with: + latest-version: "252" + mapdl-version: ${{ matrix.mapdl-version }} + testing-minimal: true + on-console: true + pytest-arguments: '-k console' + file-name: "${{ matrix.mapdl-version }}-minimal-console" + tags: "local,minimal,console" - - name: "Run Pytest for ${{ matrix.mapdl-version }} on local mode using console configuration" - uses: ./.github/actions/test-local - with: - mapdl-version: ${{ matrix.mapdl-version }} - minimal: true - license_server: ${{ secrets.LICENSE_SERVER }} - pytest-arguments: '-k console' - file-name: "${{ matrix.mapdl-version }}-minimal-console" - tags: "local,minimal,console" - codecov_token: ${{ secrets.CODECOV_TOKEN }} - test-windows: # Skipped if: github.repository == '' diff --git a/.github/workflows/test-local.yml b/.github/workflows/test-local.yml index 8c5775df064..80721bd08a2 100644 --- a/.github/workflows/test-local.yml +++ b/.github/workflows/test-local.yml @@ -31,6 +31,13 @@ on: required: false type: boolean default: false + + on-console: + description: | + If true, the tests will be run on console. + required: false + type: boolean + default: false file-name: description: | @@ -57,12 +64,12 @@ on: token: description: | - Token for GitHub. + Token for GitHub. Used also for login into ghcr.io. required: true - actor: + username: description: | - GitHub actor. + GitHub username for login into ghcr.io. required: true jobs: @@ -82,7 +89,7 @@ jobs: image: ghcr.io/ansys/mapdl:${{ inputs.mapdl-version }} options: -u=0:0 --oom-kill-disable --memory=6656MB --memory-swap=16896MB --shm-size=1gb --entrypoint /bin/bash credentials: - username: ${{ secrets.actor }} + username: ${{ secrets.username }} password: ${{ secrets.token }} steps: @@ -157,10 +164,11 @@ jobs: - name: "Unit testing" env: - ANSYSLMD_LICENSE_FILE: "1055@${{ secrets.license-server }}" ON_STUDENT: ${{ steps.student_check.outputs.ON_STUDENT }} - file_name: ${{ inputs.file-name }} ON_MINIMAL: ${{ inputs.testing-minimal }} + ON_CONSOLE: ${{ inputs.on-console }} + ANSYSLMD_LICENSE_FILE: "1055@${{ secrets.license-server }}" + file_name: ${{ inputs.file-name }} shell: bash run: | echo "ON_UBUNTU: $ON_UBUNTU" From d386907fbc8cee7101db3e46ed2c77bb73e7cd61 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 10:56:13 +0100 Subject: [PATCH 35/40] fix: add MAPDL package environment variable to doc-build and test-remote workflows --- .github/workflows/doc-build.yml | 8 +++++--- .github/workflows/test-remote.yml | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index ce28bc1baa0..1eb289e78a3 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -27,13 +27,14 @@ jobs: runs-on: ubuntu-22.04 env: ON_CI: True + ON_DOCUMENTATION: TRUE MAPDL_IMAGE_VERSION_DOCS_BUILD: v24.2-ubuntu-student + MAPDL_PACKAGE: ghcr.io/ansys/mapdl + PYMAPDL_START_INSTANCE: FALSE PYMAPDL_PORT: 21000 # default won't work on GitHub runners PYMAPDL_DB_PORT: 21001 # default won't work on GitHub runners - PYMAPDL_START_INSTANCE: FALSE - ON_DOCUMENTATION: TRUE - GRPC_ENABLE_FORK_SUPPORT: false # See #3434 DPF_PORT: 21004 + GRPC_ENABLE_FORK_SUPPORT: false # See #3434 MAIN_PYTHON_VERSION: "3.12" steps: @@ -52,6 +53,7 @@ jobs: env: LICENSE_SERVER: ${{ secrets.license-server }} MAPDL_VERSION: ${{ env.MAPDL_IMAGE_VERSION_DOCS_BUILD }} + MAPDL_PACKAGE: ${{ env.MAPDL_PACKAGE }} DISTRIBUTED_MODE: "dmp" shell: bash run: | diff --git a/.github/workflows/test-remote.yml b/.github/workflows/test-remote.yml index b9618ac36cf..04e78789264 100644 --- a/.github/workflows/test-remote.yml +++ b/.github/workflows/test-remote.yml @@ -112,6 +112,7 @@ jobs: LICENSE_SERVER: ${{ secrets.license-server }} MAPDL_VERSION: ${{ inputs.mapdl-version }} DISTRIBUTED_MODE: ${{ steps.distributed_mode.outputs.distributed_mode }} + MAPDL_PACKAGE: ${{ env.MAPDL_PACKAGE }} shell: bash run: | echo "Launching first MAPDL instance..." From 3352e7e696f26284e15d27dcc6763efa6f94d2d6 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 11:03:18 +0100 Subject: [PATCH 36/40] fix: update CI workflows to standardize environment variables and improve testing configurations --- .github/workflows/ci.yml | 13 ++----------- .github/workflows/doc-build.yml | 3 +++ .github/workflows/test-local.yml | 1 + .github/workflows/test-remote.yml | 3 +++ 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f1a43cdf71..042b34d404e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,23 +19,14 @@ on: - cron: '30 4 * * *' env: + ON_CI: True PROJECT_NAME: 'PyMAPDL' MAIN_PYTHON_VERSION: '3.12' PACKAGE_NAME: 'ansys-mapdl-core' PACKAGE_NAMESPACE: 'ansys.mapdl.core' DOCUMENTATION_CNAME: 'mapdl.docs.pyansys.com' - LATEST_VERSION: "252" MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY }} MEILISEARCH_PUBLIC_API_KEY: ${{ secrets.MEILISEARCH_PUBLIC_API_KEY }} - PYANSYS_OFF_SCREEN: True - DPF_START_SERVER: False - DPF_PORT: 21004 - MAPDL_PACKAGE: ghcr.io/ansys/mapdl - ON_CI: True - 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 concurrency: @@ -240,7 +231,7 @@ jobs: username: ${{ github.actor }} with: testing-minimal: true - pytest-arguments: '-k "not test_dpf" --reset_only_failed --add_missing_images' + pytest-arguments: '-k "not test_dpf"' mapdl-version: ${{ matrix.mapdl-version }} file-name: "${{ matrix.mapdl-version }}-minimal" tags: "local,minimal" diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 1eb289e78a3..bfac80fa18c 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -28,12 +28,15 @@ jobs: env: ON_CI: True ON_DOCUMENTATION: TRUE + PYANSYS_OFF_SCREEN: True + BUILD_CHEATSHEET: True MAPDL_IMAGE_VERSION_DOCS_BUILD: v24.2-ubuntu-student MAPDL_PACKAGE: ghcr.io/ansys/mapdl PYMAPDL_START_INSTANCE: FALSE PYMAPDL_PORT: 21000 # default won't work on GitHub runners PYMAPDL_DB_PORT: 21001 # default won't work on GitHub runners DPF_PORT: 21004 + DPF_START_SERVER: False GRPC_ENABLE_FORK_SUPPORT: false # See #3434 MAIN_PYTHON_VERSION: "3.12" diff --git a/.github/workflows/test-local.yml b/.github/workflows/test-local.yml index 80721bd08a2..657eeb8a795 100644 --- a/.github/workflows/test-local.yml +++ b/.github/workflows/test-local.yml @@ -79,6 +79,7 @@ jobs: ON_CI: True ON_LOCAL: true ON_UBUNTU: true + PYMAPDL_DEBUG_TESTING: True TESTING_MINIMAL: ${{ inputs.testing-minimal }} MAIN_PYTHON_VERSION: "3.12" P_SCHEMA: "/ansys_inc/v241/ansys/ac4/schema" diff --git a/.github/workflows/test-remote.yml b/.github/workflows/test-remote.yml index 04e78789264..3db544b1a1c 100644 --- a/.github/workflows/test-remote.yml +++ b/.github/workflows/test-remote.yml @@ -47,12 +47,15 @@ jobs: ON_CI: True ON_LOCAL: FALSE ON_UBUNTU: FALSE + PYANSYS_OFF_SCREEN: True + PYMAPDL_DEBUG_TESTING: True PYMAPDL_START_INSTANCE: FALSE PYMAPDL_PORT: 21000 # default won't work on GitHub runners PYMAPDL_PORT2: 21001 # for the pool testing and default won't work on GitHub runners PYMAPDL_DB_PORT: 21002 # default won't work on GitHub runners PYMAPDL_DB_PORT2: 21003 # default won't work on GitHub runners DPF_PORT: 21004 + DPF_START_SERVER: False 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' MAIN_PYTHON_VERSION: '3.12' MAPDL_PACKAGE: ghcr.io/ansys/mapdl From 296c716569d4d3dc8e6ab7025c9fbdd571704c3f Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 11:27:05 +0100 Subject: [PATCH 37/40] fix: update CI workflow dependencies for minimal and console jobs --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 042b34d404e..4aa7d7819d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -218,7 +218,7 @@ jobs: build-test-ubuntu-minimal: name: "Local-min: ${{ matrix.mapdl-version }}" if: github.ref != 'refs/heads/main' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - # needs: [build-test-ubuntu-local, build-test-remote] + needs: [build-test-ubuntu-local, build-test-remote] uses: ./.github/workflows/test-local.yml strategy: fail-fast: false @@ -240,7 +240,7 @@ jobs: build-test-ubuntu-console: name: "Local-min-console: ${{ matrix.mapdl-version }}" if: github.ref != 'refs/heads/main' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - # needs: [build-test-ubuntu-local, build-test-remote] + needs: [build-test-ubuntu-local, build-test-remote] uses: ./.github/workflows/test-local.yml strategy: fail-fast: false From f1fd9bb01752974b4e7e526073eee270663961e2 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 11:30:48 +0100 Subject: [PATCH 38/40] fix: remove obsolete changelog entry for PyMAPDL GitHub Action --- doc/changelog.d/3785.maintenance.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 doc/changelog.d/3785.maintenance.md diff --git a/doc/changelog.d/3785.maintenance.md b/doc/changelog.d/3785.maintenance.md deleted file mode 100644 index aeaf2f52002..00000000000 --- a/doc/changelog.d/3785.maintenance.md +++ /dev/null @@ -1 +0,0 @@ -feat: add GitHub Action for testing PyMAPDL with remote MAPDL instances \ No newline at end of file From 76d632379a6f44ea4062e5a73c03dd99263fcb64 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Fri, 7 Mar 2025 10:32:59 +0000 Subject: [PATCH 39/40] chore: adding changelog file 3787.maintenance.md [dependabot-skip] --- doc/changelog.d/3787.maintenance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog.d/3787.maintenance.md b/doc/changelog.d/3787.maintenance.md index 556e925954b..8d2284a51b0 100644 --- a/doc/changelog.d/3787.maintenance.md +++ b/doc/changelog.d/3787.maintenance.md @@ -1 +1 @@ -ci: using-reusable-workflows \ No newline at end of file +ci: using reusable workflows \ No newline at end of file From 85f164e2a42c6818389e047b6559f3cb23888a2a Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Fri, 7 Mar 2025 11:33:50 +0100 Subject: [PATCH 40/40] fix: specify Python version for Pytest-summary action in CI workflow --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4aa7d7819d6..f0b1d8f7419 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -392,4 +392,6 @@ jobs: uses: actions/checkout@v4.2.2 - name: "Run Pytest-summary action" - uses: ./.github/actions/pytest-summary \ No newline at end of file + uses: ./.github/actions/pytest-summary + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} \ No newline at end of file