From 221d9cfd3f986418788c247caa7ee4dcc4464f22 Mon Sep 17 00:00:00 2001 From: Gustavo Martins Date: Fri, 1 Dec 2023 15:28:02 -0300 Subject: [PATCH 1/2] Implement jobs to build and deploy docs ROCKY-20651 --- .github/workflows/ci_cd.yml | 52 +++++++++++++++++++++++++++++++++++-- doc/compress_doc.py | 16 ++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 doc/compress_doc.py diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 13cfa204..0300a959 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -11,6 +11,7 @@ env: MAIN_PYTHON_VERSION : '3.10' LIBRARY_NAME: 'ansys-rocky-core' DOCUMENTATION_CNAME: 'rocky.docs.pyansys.com' + DOC_DEPLOYMENT_IMAGE_TAG: v24.1.0 concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -26,7 +27,7 @@ jobs: ANSYSLMD_LICENSE_FILE: 1055@${{ secrets.LICENSE_SERVER }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Install" run: | @@ -55,4 +56,51 @@ jobs: with: name: Pytest Report path: build/tests.xml # Path to test results - reporter: java-junit \ No newline at end of file + reporter: java-junit + + + docs_build: + name: Build Documentation + runs-on: [self-hosted, Windows, pyrocky] + env: + ANSYSLMD_LICENSE_FILE: 1055@${{ secrets.LICENSE_SERVER }} + + steps: + - uses: actions/checkout@v4 + + - name: "Install" + run: | + python -m venv .venv + .venv/Scripts/activate.bat + pip install -e .[dev] + pip install msvc-runtime + + - name: Build Source Documentation + run: | + .venv/Scripts/activate.bat + doc\make.bat html + + - name: Zip HTML Documentation before upload + run: python doc\compress_doc.py HTML-Documentation-tag-${{ env.DOC_DEPLOYMENT_IMAGE_TAG }} + + - name: Upload HTML Documentation + uses: actions/upload-artifact@v3 + with: + name: HTML-Documentation-tag-${{ env.DOC_DEPLOYMENT_IMAGE_TAG }} + path: HTML-Documentation-tag-${{ env.DOC_DEPLOYMENT_IMAGE_TAG }}.zip + retention-days: 7 + + + doc-deploy-dev: + name: "Deploy development documentation" + # Deploy development only when merging or pushing to the 'main' branch + if: github.event_name == 'push' && !contains(github.ref, 'refs/tags') + runs-on: ubuntu-latest + needs: docs_build + steps: + - uses: ansys/actions/doc-deploy-dev@v4 + with: + doc-artifact-name: 'HTML-Documentation-tag-${{ env.DOC_DEPLOYMENT_IMAGE_TAG }}' + decompress-artifact: true + cname: ${{ env.DOCUMENTATION_CNAME }} + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/doc/compress_doc.py b/doc/compress_doc.py new file mode 100644 index 00000000..e0982469 --- /dev/null +++ b/doc/compress_doc.py @@ -0,0 +1,16 @@ +import os.path +from pathlib import Path +import shutil +import sys + + +def compress_doc(name: str) -> None: + path = Path(os.path.realpath(__file__)) + doc_build_path = path.parent / "_build/html" + + shutil.make_archive(name, "zip", doc_build_path) + + +if __name__ == "__main__": + name = sys.argv[1] + compress_doc(name) From 71b3e5b657a70048f4383161a6c036d45e07f695 Mon Sep 17 00:00:00 2001 From: Gustavo Martins Date: Mon, 4 Dec 2023 16:41:54 -0300 Subject: [PATCH 2/2] Fix to avoid problems on Sphinx doc generation ROCKY-20651 --- .github/workflows/ci_cd.yml | 2 +- examples/test_examples.py => test_examples.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) rename examples/test_examples.py => test_examples.py (54%) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 0300a959..0334121c 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -48,7 +48,7 @@ jobs: run: | .venv/Scripts/activate.bat - pytest examples\test_examples.py --junitxml=build/tests-examples.xml + pytest test_examples.py --junitxml=build/tests-examples.xml - name: Test Report uses: dorny/test-reporter@v1 diff --git a/examples/test_examples.py b/test_examples.py similarity index 54% rename from examples/test_examples.py rename to test_examples.py index da42f426..d4c0eada 100644 --- a/examples/test_examples.py +++ b/test_examples.py @@ -4,10 +4,9 @@ import pytest -EXAMPLES_DIR = Path(__file__).parent / "basic_examples" -EXAMPLE_FILES = EXAMPLES_DIR +EXAMPLES_DIR = Path(__file__).parent / "examples" -@pytest.mark.parametrize("example_path", list(EXAMPLE_FILES.glob("*.py"))) +@pytest.mark.parametrize("example_path", list(EXAMPLES_DIR.glob("*.py"))) def test_examples(example_path: Path) -> None: subprocess.check_call([sys.executable, str(example_path.absolute())])