Skip to content

Commit

Permalink
Merge pull request #14 from ansys-internal/fb-ROCKY-20651-build-doc-o…
Browse files Browse the repository at this point in the history
…n-ci

Implement jobs to build and deploy docs
  • Loading branch information
Gustavo Corrêa Martins authored Dec 5, 2023
2 parents 0a58811 + 71b3e5b commit def9bd8
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 6 deletions.
54 changes: 51 additions & 3 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -26,7 +27,7 @@ jobs:
ANSYSLMD_LICENSE_FILE: 1055@${{ secrets.LICENSE_SERVER }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: "Install"
run: |
Expand All @@ -47,12 +48,59 @@ 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
if: success() || failure() # run this step even if previous step failed
with:
name: Pytest Report
path: build/tests.xml # Path to test results
reporter: java-junit
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 }}
16 changes: 16 additions & 0 deletions doc/compress_doc.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 2 additions & 3 deletions examples/test_examples.py → test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())])

0 comments on commit def9bd8

Please sign in to comment.