From 69d2727636707c95c5cc787ea7e9df5fe546b959 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 13 Apr 2023 12:28:22 +0800 Subject: [PATCH 1/8] Adding coverage --- codecov.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..9dbf54b4 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,21 @@ +comment: + layout: "diff" + behavior: default + require_changes: true # Avoid coverage comment if no files are changed. + +coverage: + range: 70..100 + round: down + precision: 2 + status: + project: + default: + target: 90% + patch: + default: + # basic + target: 90% + if_not_found: success + if_ci_failed: error + if_no_uploads: error + threshold: 4% # Because some tests are flaky. From c57fd94009afdd9fcfd279e91763fcd4a5fe04ae Mon Sep 17 00:00:00 2001 From: German Date: Thu, 13 Apr 2023 12:34:06 +0800 Subject: [PATCH 2/8] Adding some env var --- .github/workflows/ci_cd.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index c96c0dc9..7bdd5307 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -10,6 +10,12 @@ on: branches: - main +env: + MAIN_PYTHON_VERSION: '3.10' + PACKAGE_NAME: 'ansys-tools-path' + PACKAGE_NAMESPACE: 'ansys.tools.path' + DOCUMENTATION_CNAME: 'path.tools.docs.pyansys.com' + jobs: style: name: Pre-commit Check @@ -170,3 +176,15 @@ jobs: ./**/*.whl ./**/*.zip ./**/*.pdf + + upload-dev-docs: + name: Upload dev documentation + if: github.ref == 'refs/heads/main' && !contains(github.ref, 'refs/tags') + runs-on: ubuntu-latest + needs: [docs] + steps: + - name: Deploy the latest documentation + uses: pyansys/actions/doc-deploy-dev@v4 + with: + cname: ${{ env.DOCUMENTATION_CNAME }} + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 535a24968d23daba1c740f2337475c6c83336270 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 13 Apr 2023 13:09:17 +0800 Subject: [PATCH 3/8] Getting CICD in place. --- .github/workflows/ci_cd.yml | 173 +++++++++++++++++------------------- CHANGELOG.md | 2 +- 2 files changed, 83 insertions(+), 92 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 7bdd5307..2c07c2f7 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -36,9 +36,35 @@ jobs: run: | pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) - main: + smoke-tests: + name: "Build and smoke tests" + runs-on: ${{ matrix.os }} + if: github.ref != 'refs/heads/main' + timeout-minutes: 20 + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + # Only perform wheelhouse builds for macOS when releasing + should-release: + - ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags') }} + exclude: + - should-release: false + os: macos-latest + steps: + - name: "Build wheelhouse and perform smoke test" + uses: pyansys/actions/build-wheelhouse@v4 + with: + library-name: ${{ env.PACKAGE_NAME }} + library-namespace: ${{ env.PACKAGE_NAMESPACE }} + operating-system: ${{ matrix.os }} + python-version: ${{ matrix.python-version }} + + build-tests: name: Build and Testing runs-on: ubuntu-latest + needs: [smoke-tests] timeout-minutes: 20 container: image: ghcr.io/pyansys/mapdl:v22.2-ubuntu @@ -55,7 +81,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: ${{ env.MAIN_PYTHON_VERSION }} - name: Create wheel run: | @@ -73,118 +99,83 @@ jobs: - name: Unit testing run: | cd tests # so we're testing the install, not local - python -m pytest -vx --cov=ansys.tools.path --cov-report=html + python -m pytest -vx --cov=${{ env.PACKAGE_NAMESPACE }} --cov-report=term --cov-report=xml:.cov/coverage.xml --cov-report=html:.cov/html - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 - - - name: Upload wheel - uses: actions/upload-artifact@v3 with: - name: ansys-product-library-wheel - path: dist/ - retention-days: 7 + files: .cov/coverage.xml - docs: - name: Build Documentation + docs-style: + name: PyAnsys documentation style check using Vale runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup Python - uses: actions/setup-python@v4 + - name: PyAnsys documentation style checks + uses: pyansys/actions/doc-style@v4 with: - python-version: 3.8 + token: ${{ secrets.GITHUB_TOKEN }} - - name: Install library, with docs extra - run: | - pip install .[doc] - - - name: Build HTML - run: | - make -C doc html SPHINXOPTS="-W" - - # - name: Build PDF Documentation - # run: | - # sudo apt update - # sudo apt-get install -y texlive-latex-extra latexmk - # make -C doc latexpdf - - - name: Upload HTML Documentation - uses: actions/upload-artifact@v3 - with: - name: Documentation-html - path: doc/_build/html - retention-days: 7 - - # - name: Upload PDF Documentation - # uses: actions/upload-artifact@v3 - # with: - # name: Documentation-pdf - # path: doc/build/latex/*.pdf - # retention-days: 7 - - Release: - if: contains(github.ref, 'refs/tags') - needs: [main, style, docs] + docs: + name: Documentation runs-on: ubuntu-latest + needs: [docs-style] steps: - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - - uses: actions/checkout@v3 - - - uses: actions/download-artifact@v3 + - name: "Run Ansys documentation building action" + uses: pyansys/actions/doc-build@v4 with: - name: ansys-product-library-wheel + python-version: ${{ env.MAIN_PYTHON_VERSION }} + dependencies: "build-essential zip pandoc texlive-latex-extra latexmk texlive-pstricks" - - uses: actions/download-artifact@v3 - with: - name: Documentation-pdf - - - uses: actions/download-artifact@v3 + package: + name: Package library + needs: [build-tests, docs] + runs-on: ubuntu-latest + steps: + - name: Build library source and wheel artifacts + uses: pyansys/actions/build-library@v4 with: - name: Documentation-html - path: ~/html + library-name: ${{ env.PACKAGE_NAME }} + python-version: ${{ env.MAIN_PYTHON_VERSION }} - # list current directory - - name: List directory structure - run: ls -R - - - name: Deploy - uses: JamesIves/github-pages-deploy-action@4.4 + release: + name: Release project + if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags') }} + needs: [package] + runs-on: ubuntu-latest + steps: + - name: Release to the public PyPI repository + uses: pyansys/actions/release-pypi-public@v4 with: - BRANCH: gh-pages - FOLDER: ~/html - CLEAN: true + library-name: ${{ env.PACKAGE_NAME }} + twine-username: "__token__" + twine-token: ${{ secrets.PYPI_TOKEN }} - # note how we use the PyPI tokens - - name: Upload to Azure PyPi (disabled) - run: | - pip install twine - # twine upload --skip-existing ./**/*.whl - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - - - name: Release - uses: softprops/action-gh-release@v1 + - name: Release to GitHub + uses: pyansys/actions/release-github@v4 with: - files: | - ./**/*.whl - ./**/*.zip - ./**/*.pdf + library-name: ${{ env.PACKAGE_NAME }} - upload-dev-docs: + upload_docs_dev: name: Upload dev documentation - if: github.ref == 'refs/heads/main' && !contains(github.ref, 'refs/tags') + if: ${{ github.ref == 'refs/heads/main' }} runs-on: ubuntu-latest - needs: [docs] + needs: [package] steps: - name: Deploy the latest documentation uses: pyansys/actions/doc-deploy-dev@v4 with: cname: ${{ env.DOCUMENTATION_CNAME }} - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + token: ${{ secrets.GITHUB_TOKEN }} + + 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: pyansys/actions/doc-deploy-stable@v4 + with: + cname: ${{ env.DOCUMENTATION_CNAME }} + token: ${{ secrets.GITHUB_TOKEN }} + python-version: ${{ env.MAIN_PYTHON_VERSION }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index dc25d743..7c6abb26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,6 @@ questions or submissions to this repository. For contributing to this project, please refer to the [PyAnsys Developer's Guide]. Further information about contributing to ansys-tools-path can be found in -[ansys-tools-path github page](hhttps://github.com/pyansys/ansys-tools-path). +[ansys-tools-path github page](https://github.com/pyansys/ansys-tools-path). [PyAnsys Developer's Guide]: https://dev.docs.pyansys.com/ \ No newline at end of file From 25e095e236832dcf736d1aa2b266ff29fb9369ac Mon Sep 17 00:00:00 2001 From: German Date: Thu, 13 Apr 2023 13:20:50 +0800 Subject: [PATCH 4/8] Adding PDF building --- doc/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/Makefile b/doc/Makefile index d5066f42..8d78ac95 100755 --- a/doc/Makefile +++ b/doc/Makefile @@ -13,12 +13,18 @@ help: .PHONY: help Makefile + +# customized pdf due to svg issue +pdf: + @$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + cd $(BUILDDIR)/latex && latexmk -r latexmkrc -pdf *.tex -interaction=nonstopmode || true + (test -f $(BUILDDIR)/latex/ansys-tools*.pdf && echo pdf exists) || exit 1 + # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - # Customized clean due to examples gallery clean: rm -rf $(BUILDDIR)/* From eb35c13d4b9472b451ac41cc9326192a7084a574 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 13 Apr 2023 13:22:00 +0800 Subject: [PATCH 5/8] Updating coverage --- codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 9dbf54b4..9a179576 100644 --- a/codecov.yml +++ b/codecov.yml @@ -10,7 +10,7 @@ coverage: status: project: default: - target: 90% + target: 85% patch: default: # basic From 2ed849eb2a32d09e7565cc638c813ea6295f37d6 Mon Sep 17 00:00:00 2001 From: German Date: Thu, 13 Apr 2023 13:23:30 +0800 Subject: [PATCH 6/8] Fixing Vale --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index b2c85a80..16c8c492 100644 --- a/README.rst +++ b/README.rst @@ -67,8 +67,8 @@ For developers Installing ``ansys-tools-path`` in developer mode allows you to modify the source and enhance it. -Before contributing to the project, please refer to the `PyAnsys Developer's guide`_. You will -need to follow these steps: +Before contributing to the project, please refer to the `PyAnsys Developer's guide`_. +You need to follow these steps: #. Start by cloning this repository: From 1e81df71a26cefc3654fa587f139f177da5a674b Mon Sep 17 00:00:00 2001 From: German Date: Thu, 13 Apr 2023 13:26:47 +0800 Subject: [PATCH 7/8] Fixing vale again --- doc/source/_static/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/_static/README.md b/doc/source/_static/README.md index ff7796e4..d2c955cc 100644 --- a/doc/source/_static/README.md +++ b/doc/source/_static/README.md @@ -1 +1 @@ -Static files will be found here (like images and other assets). +Static files are found here (like images and other assets). From 0694d938c7c2b47476375315f8991086a357e68f Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Thu, 13 Apr 2023 08:12:07 +0200 Subject: [PATCH 8/8] FEAT: minor edits to CI/CD --- .github/workflows/ci_cd.yml | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 2c07c2f7..b18caeff 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -1,8 +1,7 @@ -# check spelling, codestyle name: GitHub CI -# run only on main branch. This avoids duplicated actions on PRs on: + workflow_dispatch: pull_request: push: tags: @@ -18,27 +17,18 @@ env: jobs: style: - name: Pre-commit Check + name: Code style runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup Python - uses: actions/setup-python@v4 + - name: PyAnsys code style checks + uses: pyansys/actions/code-style@v4 with: - python-version: 3.8 - - - name: Install pre-commit requirements - run: | - pip install pre-commit - - - name: Run pre-commit - run: | - pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) + python-version: ${{ env.MAIN_PYTHON_VERSION }} smoke-tests: name: "Build and smoke tests" runs-on: ${{ matrix.os }} + needs: [style] if: github.ref != 'refs/heads/main' timeout-minutes: 20 strategy: @@ -83,18 +73,8 @@ jobs: with: python-version: ${{ env.MAIN_PYTHON_VERSION }} - - name: Create wheel - run: | - python -m pip install build - python -m build --wheel - - - name: Validate wheel - run: | - python -m pip install twine - python -m twine check dist/* - - name: Install library, with test extra - run: python -m pip install $(echo dist/*)[test] + run: python -m pip install .[test] - name: Unit testing run: | @@ -178,4 +158,4 @@ jobs: with: cname: ${{ env.DOCUMENTATION_CNAME }} token: ${{ secrets.GITHUB_TOKEN }} - python-version: ${{ env.MAIN_PYTHON_VERSION }} \ No newline at end of file + python-version: ${{ env.MAIN_PYTHON_VERSION }}