From 948fc3a99bec6e06eea3bf2070388bba3a0e6ae8 Mon Sep 17 00:00:00 2001 From: afernand Date: Wed, 23 Jul 2025 12:42:54 +0200 Subject: [PATCH 01/19] maint: Complete CICD --- .github/workflows/cicd.yml | 81 ++++++++++++++++++++++++++++++++++---- CHANGELOG.md | 0 2 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index cc5acac0..4002775c 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -12,9 +12,44 @@ on: env: PACKAGE_NAME: ansys-tools-common MAIN_PYTHON_VERSION: 3.13 - DOCUMENTATION_CNAME: bookish-adventure-16g5prl.pages.github.io + DOCUMENTATION_CNAME: tools.docs.pyansys.com jobs: + + update-changelog: + name: "Update CHANGELOG (on release)" + if: github.event_name == 'push' && contains(github.ref, 'refs/tags') + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: ansys/actions/doc-deploy-changelog@v10 + with: + token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} + bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} + + vulnerabilities: + name: Vulnerabilities + runs-on: ubuntu-latest + steps: + - name: PyAnsys Vulnerability check (on main) + if: github.ref == 'refs/heads/main' + uses: ansys/actions/check-vulnerabilities@v10 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + python-package-name: ${{ env.PACKAGE_NAME }} + token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + + - name: PyAnsys Vulnerability check (on dev mode) + if: github.ref != 'refs/heads/main' + uses: ansys/actions/check-vulnerabilities@v10 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + python-package-name: ${{ env.PACKAGE_NAME }} + token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + dev-mode: true style: name: Code style runs-on: ubuntu-latest @@ -96,16 +131,46 @@ jobs: library-name: ${{ env.PACKAGE_NAME }} python-version: ${{ env.MAIN_PYTHON_VERSION }} - upload_dev_docs: - name: Upload dev documentation - if: github.ref == 'refs/heads/main' + release: + name: Release project + if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags') }} + needs: [package] runs-on: ubuntu-latest - needs: [doc-build] + environment: release + permissions: + id-token: write + contents: write steps: - - name: Deploy the latest documentation - uses: ansys/actions/doc-deploy-dev@v10 + - name: "Download the library artifacts from build-library step" + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 + with: + name: ${{ env.PACKAGE_NAME }}-artifacts + path: ${{ env.PACKAGE_NAME }}-artifacts + + - name: "Upload artifacts to PyPI using trusted publisher" + uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 + with: + repository-url: "https://upload.pypi.org/legacy/" + print-hash: true + packages-dir: ${{ env.PACKAGE_NAME }}-artifacts + skip-existing: false + + - name: Release to GitHub + uses: ansys/actions/release-github@v10 + with: + token: ${{ secrets.GITHUB_TOKEN }} + library-name: ${{ env.PACKAGE_NAME }} + + upload_docs_release: + name: Upload release documentation + if: github.event_name == 'push' && contains(github.ref, 'refs/tags') + runs-on: ubuntu-latest + needs: [release] + steps: + - name: Deploy the stable documentation + uses: ansys/actions/doc-deploy-stable@v10 with: cname: ${{ env.DOCUMENTATION_CNAME }} token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} - bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} + bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..e69de29b From 883b4fca2f330bc4aef52c6d9b2f0c1db2a429b5 Mon Sep 17 00:00:00 2001 From: afernand Date: Wed, 23 Jul 2025 12:45:04 +0200 Subject: [PATCH 02/19] maint: Add doc style action --- .github/workflows/cicd.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 4002775c..57adf42f 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -75,8 +75,8 @@ jobs: python-version: ${{ matrix.python-version }} whitelist-license-check: "termcolor" # Has MIT license, but it's not recognized - build-tests: - name: Build and Testing + tests: + name: Testing runs-on: ubuntu-latest needs: [smoke-tests] env: @@ -110,8 +110,18 @@ jobs: # with: # token: ${{ secrets.CODECOV_TOKEN }} + docs-style: + name: Documentation Style Check + runs-on: ubuntu-latest + steps: + - name: PyAnsys documentation style checks + uses: ansys/actions/doc-style@v10 + with: + token: ${{ secrets.GITHUB_TOKEN }} + doc-build: name: Build documentation + needs: [docs-style] runs-on: ubuntu-latest steps: - name: Build documentation @@ -123,7 +133,7 @@ jobs: package: name: Package library runs-on: ubuntu-latest - needs: [smoke-tests] + needs: [tests, doc-build] steps: - name: Build library source and wheel artifacts uses: ansys/actions/build-library@v10 From 93adccecb457215ca2dcc27c272d6e00ad8b9227 Mon Sep 17 00:00:00 2001 From: afernand Date: Wed, 23 Jul 2025 12:55:03 +0200 Subject: [PATCH 03/19] fix: Doc style fixes --- doc/.vale.ini | 10 +++++++++- doc/source/contributing.rst | 2 +- doc/styles/config/vocabularies/ANSYS/accept.txt | 8 ++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/doc/.vale.ini b/doc/.vale.ini index c148a37a..564b4cbb 100644 --- a/doc/.vale.ini +++ b/doc/.vale.ini @@ -28,4 +28,12 @@ Vocab = ANSYS [*.{rst}] BasedOnStyles = Vale, Google Vale.Terms = NO -Google.Headings = NO \ No newline at end of file +Google.Headings = NO +BlockIgnores = ```[a-z]*[\s\S]*?\n``` + +TokenIgnores = \(\/.*?\), \ + {%.*?%}, \ + {{.*?}}, \ + (.|\/|-)?github(\/|-)?, \ + (+?), \ + (```[a-z]*[\s\S]*?\n```) \ No newline at end of file diff --git a/doc/source/contributing.rst b/doc/source/contributing.rst index 98c75511..ede604b7 100644 --- a/doc/source/contributing.rst +++ b/doc/source/contributing.rst @@ -6,7 +6,7 @@ Contribute Overall guidance on contributing to a PyAnsys library appears in the `Contributing `_ topic in the *PyAnsys developer's guide*. Ensure that you are thoroughly familiar -with this guide before attempting to contribute to the Ansys tools common repo. +with this guide before attempting to contribute to the Ansys tools common repository. The following contribution information is specific to the Ansys tools common. diff --git a/doc/styles/config/vocabularies/ANSYS/accept.txt b/doc/styles/config/vocabularies/ANSYS/accept.txt index 359302da..ad23686d 100644 --- a/doc/styles/config/vocabularies/ANSYS/accept.txt +++ b/doc/styles/config/vocabularies/ANSYS/accept.txt @@ -1,4 +1,8 @@ (?i)Ansys -pytest ANS -astroid \ No newline at end of file +astroid +downloader +mypy +pytest +pathing +subprocess \ No newline at end of file From fe70d64c96435ce336e10d99bf6619fcf40d3c40 Mon Sep 17 00:00:00 2001 From: afernand Date: Wed, 23 Jul 2025 13:15:42 +0200 Subject: [PATCH 04/19] fix: PyMAPDL container name --- .github/workflows/run_mapdl_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_mapdl_tests.yml b/.github/workflows/run_mapdl_tests.yml index 7908fe30..6bcd891e 100644 --- a/.github/workflows/run_mapdl_tests.yml +++ b/.github/workflows/run_mapdl_tests.yml @@ -17,7 +17,7 @@ jobs: build-tests: runs-on: ubuntu-22.04 container: - image: ghcr.io/ansys/pymapdl/mapdl:v22.2-ubuntu + image: ghcr.io/ansys/mapdl:v22.2-ubuntu options: "-u=0:0 --entrypoint /bin/bash" credentials: username: ${{ secrets.GH_USERNAME }} From f851095302063e5909965c3525985e457a119fcf Mon Sep 17 00:00:00 2001 From: afernand Date: Wed, 23 Jul 2025 13:18:32 +0200 Subject: [PATCH 05/19] fix: Ignore rst code blocks --- doc/.vale.ini | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/.vale.ini b/doc/.vale.ini index 564b4cbb..2b99633a 100644 --- a/doc/.vale.ini +++ b/doc/.vale.ini @@ -29,8 +29,9 @@ Vocab = ANSYS BasedOnStyles = Vale, Google Vale.Terms = NO Google.Headings = NO -BlockIgnores = ```[a-z]*[\s\S]*?\n``` - +BlockIgnores = ```[a-z]*[\s\S]*?\n```, \ + ::\s*\n\s*(.*\n)*?\n(?=\S), \ + \.\. code-block::.*?\n(.*\n)*?\n(?=\S) TokenIgnores = \(\/.*?\), \ {%.*?%}, \ {{.*?}}, \ From 5e5587b5b8c9f2574a915a89a4f83e9128746979 Mon Sep 17 00:00:00 2001 From: afernand Date: Wed, 23 Jul 2025 13:23:44 +0200 Subject: [PATCH 06/19] fix: Vale ini --- doc/.vale.ini | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/doc/.vale.ini b/doc/.vale.ini index 2b99633a..1cc4ad98 100644 --- a/doc/.vale.ini +++ b/doc/.vale.ini @@ -29,12 +29,5 @@ Vocab = ANSYS BasedOnStyles = Vale, Google Vale.Terms = NO Google.Headings = NO -BlockIgnores = ```[a-z]*[\s\S]*?\n```, \ - ::\s*\n\s*(.*\n)*?\n(?=\S), \ - \.\. code-block::.*?\n(.*\n)*?\n(?=\S) -TokenIgnores = \(\/.*?\), \ - {%.*?%}, \ - {{.*?}}, \ - (.|\/|-)?github(\/|-)?, \ - (+?), \ - (```[a-z]*[\s\S]*?\n```) \ No newline at end of file +SkippedScopes = script, style, pre, figure, code-block, literal-block + From 4abcd776b434cc94c7474f68ba54dbffd627c627 Mon Sep 17 00:00:00 2001 From: afernand Date: Wed, 23 Jul 2025 13:25:46 +0200 Subject: [PATCH 07/19] fix: Accept words --- doc/styles/config/vocabularies/ANSYS/accept.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/styles/config/vocabularies/ANSYS/accept.txt b/doc/styles/config/vocabularies/ANSYS/accept.txt index ad23686d..64937a12 100644 --- a/doc/styles/config/vocabularies/ANSYS/accept.txt +++ b/doc/styles/config/vocabularies/ANSYS/accept.txt @@ -5,4 +5,10 @@ downloader mypy pytest pathing -subprocess \ No newline at end of file +subprocess + + +s.P +e.M +terminate +kill \ No newline at end of file From 45bcf871510f69d7004a5a6ee5da661f43d21a02 Mon Sep 17 00:00:00 2001 From: afernand Date: Thu, 24 Jul 2025 09:42:19 +0200 Subject: [PATCH 08/19] fix: Add changelog missing line, add private PyPI --- .github/workflows/cicd.yml | 38 ++++++++++++++++++-------------------- CHANGELOG.md | 1 + 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 57adf42f..4454158b 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -30,26 +30,17 @@ jobs: bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} - vulnerabilities: - name: Vulnerabilities + check-vulnerabilities: + name: "Check library vulnerabilities" runs-on: ubuntu-latest steps: - - name: PyAnsys Vulnerability check (on main) - if: github.ref == 'refs/heads/main' - uses: ansys/actions/check-vulnerabilities@v10 + - uses: ansys/actions/check-vulnerabilities@v10.0 with: python-version: ${{ env.MAIN_PYTHON_VERSION }} - python-package-name: ${{ env.PACKAGE_NAME }} token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} - - - name: PyAnsys Vulnerability check (on dev mode) - if: github.ref != 'refs/heads/main' - uses: ansys/actions/check-vulnerabilities@v10 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} python-package-name: ${{ env.PACKAGE_NAME }} - token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} - dev-mode: true + dev-mode: ${{ github.ref != "refs/heads/main" }} + style: name: Code style runs-on: ubuntu-latest @@ -157,13 +148,20 @@ jobs: name: ${{ env.PACKAGE_NAME }}-artifacts path: ${{ env.PACKAGE_NAME }}-artifacts - - name: "Upload artifacts to PyPI using trusted publisher" - uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 + # - name: "Upload artifacts to PyPI using trusted publisher" + # uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 + # with: + # repository-url: "https://upload.pypi.org/legacy/" + # print-hash: true + # packages-dir: ${{ env.PACKAGE_NAME }}-artifacts + # skip-existing: false + + - name: "Release to the private PyPI repository" + uses: ansys/actions/release-pypi-private@v9 with: - repository-url: "https://upload.pypi.org/legacy/" - print-hash: true - packages-dir: ${{ env.PACKAGE_NAME }}-artifacts - skip-existing: false + library-name: "ansys-api-meshing-maestro" + twine-username: "__token__" + twine-token: ${{ secrets.PYANSYS_PYPI_PRIVATE_PAT }} - name: Release to GitHub uses: ansys/actions/release-github@v10 diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29b..3cf7b732 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1 @@ + \ No newline at end of file From ecccef022bda1a80d678c744a4035015dd66846f Mon Sep 17 00:00:00 2001 From: afernand Date: Thu, 24 Jul 2025 09:52:41 +0200 Subject: [PATCH 09/19] fix: CICD file --- .github/workflows/cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 4454158b..e0d31eca 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -39,7 +39,7 @@ jobs: python-version: ${{ env.MAIN_PYTHON_VERSION }} token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} python-package-name: ${{ env.PACKAGE_NAME }} - dev-mode: ${{ github.ref != "refs/heads/main" }} + dev-mode: ${{ github.ref != 'refs/heads/main' }} style: name: Code style From 4ccfef801480f6b216f65723b553c3f5bf8ec1f3 Mon Sep 17 00:00:00 2001 From: afernand Date: Thu, 24 Jul 2025 10:06:37 +0200 Subject: [PATCH 10/19] fix: Missing changelog config --- .github/workflows/cicd.yml | 1 + .github/workflows/label.yml | 115 ++++++++++++++++++++++++++++++++++++ CHANGELOG.md | 2 + doc/source/conf.py | 5 ++ doc/source/index.rst | 3 +- 5 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/label.yml diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index e0d31eca..0306f06a 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -30,6 +30,7 @@ jobs: bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} + check-vulnerabilities: name: "Check library vulnerabilities" runs-on: ubuntu-latest diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml new file mode 100644 index 00000000..65bf3a36 --- /dev/null +++ b/.github/workflows/label.yml @@ -0,0 +1,115 @@ +name: Labeler +on: + pull_request: + # opened, reopened, and synchronize are default for pull_request + # edited - when PR title or body is changed + # labeled - when labels are added to PR + types: [opened, reopened, synchronize, edited, labeled] + push: + branches: [ main ] + paths: + - '../labels.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + label-syncer: + name: Syncer + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: micnncim/action-label-syncer@3abd5ab72fda571e69fffd97bd4e0033dd5f495c # v1.3.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + labeler: + name: Set labels + needs: [label-syncer] + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + + # Label based on modified files + - name: Label based on changed files + uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + sync-labels: true + + # Label based on branch name + - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # v1.1.3 + if: | + startsWith(github.event.pull_request.head.ref, 'doc') || + startsWith(github.event.pull_request.head.ref, 'docs') + with: + labels: documentation + github_token: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # v1.1.3 + if: | + startsWith(github.event.pull_request.head.ref, 'maint') || + startsWith(github.event.pull_request.head.ref, 'no-ci') || + startsWith(github.event.pull_request.head.ref, 'ci') + with: + labels: maintenance + github_token: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # v1.1.3 + if: startsWith(github.event.pull_request.head.ref, 'feat') + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: | + enhancement + + - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # v1.1.3 + if: | + startsWith(github.event.pull_request.head.ref, 'fix') || + startsWith(github.event.pull_request.head.ref, 'patch') + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: bug + + commenter: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: + - name: Suggest to add labels + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 + # Execute only when no labels have been applied to the pull request + if: toJSON(github.event.pull_request.labels.*.name) == '{}' + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + Please add one of the following labels to add this contribution to the Release Notes :point_down: + - [bug](https://github.com/ansys-internal/ansys-tools-common/pulls?q=label%3Abug+) + - [documentation](https://github.com/ansys-internal/ansys-tools-common/pulls?q=label%3Adocumentation+) + - [enhancement](https://github.com/ansys-internal/ansys-tools-common/pulls?q=label%3Aenhancement+) + - [good first issue](https://github.com/ansys-internal/ansys-tools-common/pulls?q=label%3Agood+first+issue) + - [maintenance](https://github.com/ansys-internal/ansys-tools-common/pulls?q=label%3Amaintenance+) + - [release](https://github.com/ansys-internal/ansys-tools-common/pulls?q=label%3Arelease+) + + changelog-fragment: + name: "Create changelog fragment" + needs: [labeler] + permissions: + contents: write + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: ansys/actions/doc-changelog@v10 + with: + token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + use-conventional-commits: true + use-default-towncrier-config: true + bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} + bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cf7b732..8f8a3f96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,3 @@ +This document contains the release notes for the project. See release notes for v{latest-version} and earlier +in `CHANGELOG.md `_. \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py index 789b23d5..a637d56e 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -70,6 +70,11 @@ }, } +linkcheck_ignore = [] + +if switcher_version != "dev": + linkcheck_ignore.append(f"https://github.com/ansys-internal/ansys-tools-common/releases/tag/v{__version__}") + # Sphinx extensions extensions = [ "sphinx.ext.intersphinx", diff --git a/doc/source/index.rst b/doc/source/index.rst index 28c28e8d..6cccf7c4 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -47,4 +47,5 @@ The Ansys tools project is a collection of tools for the PyAnsys ecosystem. getting_started/index user_guide/index api/index - contributing \ No newline at end of file + contributing + changelog \ No newline at end of file From 142806b18a886ea9348563ce5230b84788774cfe Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Thu, 24 Jul 2025 08:10:06 +0000 Subject: [PATCH 11/19] chore: adding changelog file 34.maintenance.md [dependabot-skip] --- doc/changelog.d/34.maintenance.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/34.maintenance.md diff --git a/doc/changelog.d/34.maintenance.md b/doc/changelog.d/34.maintenance.md new file mode 100644 index 00000000..e53e26a8 --- /dev/null +++ b/doc/changelog.d/34.maintenance.md @@ -0,0 +1 @@ +Finish cicd \ No newline at end of file From b8c376c2d34e7d516d02b0ca3ea22ddae2f83fe8 Mon Sep 17 00:00:00 2001 From: afernand Date: Thu, 24 Jul 2025 10:13:09 +0200 Subject: [PATCH 12/19] fix: Temporary allow vulnerability logs --- .github/workflows/cicd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 0306f06a..0e5bd859 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -41,6 +41,7 @@ jobs: token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} python-package-name: ${{ env.PACKAGE_NAME }} dev-mode: ${{ github.ref != 'refs/heads/main' }} + hide-log: false style: name: Code style From 90857306075848df2074a20311b913fc56646894 Mon Sep 17 00:00:00 2001 From: afernand Date: Thu, 24 Jul 2025 11:04:08 +0200 Subject: [PATCH 13/19] fix: Remove changelog --- doc/source/index.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/index.rst b/doc/source/index.rst index 6cccf7c4..a3f48d48 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -48,4 +48,3 @@ The Ansys tools project is a collection of tools for the PyAnsys ecosystem. user_guide/index api/index contributing - changelog \ No newline at end of file From e6da613f3c12890282a33fdca369fce14342ca15 Mon Sep 17 00:00:00 2001 From: afernand Date: Thu, 24 Jul 2025 11:10:49 +0200 Subject: [PATCH 14/19] fix: Upload reports --- .github/workflows/cicd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 0e5bd859..38e8665d 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -42,6 +42,7 @@ jobs: python-package-name: ${{ env.PACKAGE_NAME }} dev-mode: ${{ github.ref != 'refs/heads/main' }} hide-log: false + upload-reports: true style: name: Code style From 6ddf9745958bf9a2da2bd7c6620df0cc080d284f Mon Sep 17 00:00:00 2001 From: afernand Date: Thu, 24 Jul 2025 11:19:48 +0200 Subject: [PATCH 15/19] fix: remove vulnerabilites publication --- .github/workflows/cicd.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 38e8665d..0306f06a 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -41,8 +41,6 @@ jobs: token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} python-package-name: ${{ env.PACKAGE_NAME }} dev-mode: ${{ github.ref != 'refs/heads/main' }} - hide-log: false - upload-reports: true style: name: Code style From 9c098bde5906244d39cf864f868ff99a99445d8a Mon Sep 17 00:00:00 2001 From: afernand Date: Thu, 24 Jul 2025 16:27:51 +0200 Subject: [PATCH 16/19] fix: Vulnerability --- src/ansys/tools/common/example_download.py | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/ansys/tools/common/example_download.py b/src/ansys/tools/common/example_download.py index 14bbdaf1..f62f38c1 100644 --- a/src/ansys/tools/common/example_download.py +++ b/src/ansys/tools/common/example_download.py @@ -25,8 +25,9 @@ import tempfile from threading import Lock from typing import Optional -from urllib.parse import urljoin -import urllib.request +from urllib.parse import urljoin, urlparse + +import requests __all__ = ["DownloadManager"] @@ -186,17 +187,23 @@ def _retrieve_data(self, url: str, filename: str, dest: str = None, force: bool str The local path where the file was saved. """ - local_path = "" if dest is None: - dest = tempfile.gettempdir() # Use system temp directory if no destination is provided - local_path = Path(dest) / Path(filename).name - if not force and Path(local_path).is_file(): - return local_path - try: - local_path, _ = urllib.request.urlretrieve(url, filename=local_path) - except urllib.error.HTTPError: - raise FileNotFoundError(f"Failed to download {filename} from {url}, file does not exist.") - return local_path + dest = tempfile.gettempdir() + local_path = Path(dest) / Path(filename).name + + if not force and local_path.is_file(): + return str(local_path) + + parsed_url = urlparse(url) + if parsed_url.scheme not in ("http", "https"): + raise ValueError(f"Unsafe URL scheme: {parsed_url.scheme}") + + response = requests.get(url, timeout=60) + response.raise_for_status() + + Path(local_path).write_bytes(response.content) + + return str(local_path) # Create a singleton instance of DownloadManager From f20eeca84f388a175b486ad2a7e0a05bfe42f93f Mon Sep 17 00:00:00 2001 From: afernand Date: Mon, 28 Jul 2025 09:38:27 +0200 Subject: [PATCH 17/19] fix: Tests --- pyproject.toml | 1 + tests/test_example_download.py | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b5bec27d..5e6d76eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,6 +28,7 @@ dependencies = [ "scooby>=0.5.12", "appdirs>=1.4.4", "typing-extensions>=4.5.0", + "requests>=2.32.4", ] [project.optional-dependencies] diff --git a/tests/test_example_download.py b/tests/test_example_download.py index 422ef452..964cb584 100644 --- a/tests/test_example_download.py +++ b/tests/test_example_download.py @@ -24,6 +24,7 @@ from pathlib import Path import pytest +import requests from ansys.tools.common.example_download import download_manager @@ -34,14 +35,14 @@ def test_download(): directory = "pymapdl/cfx_mapping" # Download the file - local_path = download_manager.download_file(filename, directory) - - assert Path.is_file(local_path) + local_path_str = download_manager.download_file(filename, directory) + local_path = Path(local_path_str) + assert local_path.is_file() # Check that file is cached local_path2 = download_manager.download_file(filename, directory) - assert local_path2 == local_path + assert local_path2 == local_path_str download_manager.clear_download_cache() @@ -54,7 +55,7 @@ def test_non_existent_file(): directory = "pymapdl/cfx_mapping" # Attempt to download the non-existent file - with pytest.raises(FileNotFoundError): + with pytest.raises(requests.exceptions.HTTPError): download_manager.download_file(filename, directory) From 043424aef507f7d0c5484c8daf8c87596f200363 Mon Sep 17 00:00:00 2001 From: afernand Date: Mon, 28 Jul 2025 10:06:56 +0200 Subject: [PATCH 18/19] fix: Comment out vuln action until release --- .github/workflows/cicd.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 0306f06a..c3e172b1 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -30,17 +30,17 @@ jobs: bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} - - check-vulnerabilities: - name: "Check library vulnerabilities" - runs-on: ubuntu-latest - steps: - - uses: ansys/actions/check-vulnerabilities@v10.0 - with: - python-version: ${{ env.MAIN_PYTHON_VERSION }} - token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} - python-package-name: ${{ env.PACKAGE_NAME }} - dev-mode: ${{ github.ref != 'refs/heads/main' }} + # TODO uncomment after the first release + # check-vulnerabilities: + # name: "Check library vulnerabilities" + # runs-on: ubuntu-latest + # steps: + # - uses: ansys/actions/check-vulnerabilities@v10.0 + # with: + # python-version: ${{ env.MAIN_PYTHON_VERSION }} + # token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + # python-package-name: ${{ env.PACKAGE_NAME }} + # dev-mode: ${{ github.ref != 'refs/heads/main' }} style: name: Code style From 427881a44abdf8985583a342b2898f1202bd8d67 Mon Sep 17 00:00:00 2001 From: afernand Date: Mon, 28 Jul 2025 10:17:26 +0200 Subject: [PATCH 19/19] fix: Add TODOs for release --- .github/workflows/cicd.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index c3e172b1..868df96b 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -30,7 +30,7 @@ jobs: bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} - # TODO uncomment after the first release + # TODO uncomment after the first public release # check-vulnerabilities: # name: "Check library vulnerabilities" # runs-on: ubuntu-latest @@ -149,6 +149,7 @@ jobs: name: ${{ env.PACKAGE_NAME }}-artifacts path: ${{ env.PACKAGE_NAME }}-artifacts + # TODO uncomment after the first public release # - name: "Upload artifacts to PyPI using trusted publisher" # uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 # with: