Skip to content

Commit

Permalink
Merge branch 'main' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuelopez-ansys authored Oct 30, 2024
2 parents 33ead89 + 74f97af commit e58a58c
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 165 deletions.
143 changes: 18 additions & 125 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ env:
LIBRARY_NAME: 'ansys-aedt-toolkits-antenna'
LIBRARY_NAMESPACE: 'ansys.aedt.toolkits.antenna'
ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }}
MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY }}
MEILISEARCH_HOST_URL: ${{ vars.MEILISEARCH_HOST_URL }}
MEILISEARCH_PUBLIC_API_KEY: ${{ secrets.MEILISEARCH_PUBLIC_API_KEY }}
ON_CI: True

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -33,7 +31,7 @@ jobs:
name: "Code style"
runs-on: ubuntu-latest
steps:
- uses: ansys/actions/code-style@v6
- uses: ansys/actions/code-style@v8
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
use-python-cache: false
Expand All @@ -42,7 +40,7 @@ jobs:
name: "Documentation style"
runs-on: ubuntu-latest
steps:
- uses: ansys/actions/doc-style@v6
- uses: ansys/actions/doc-style@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
vale-version: "3.4.1"
Expand All @@ -53,79 +51,14 @@ jobs:
needs: [ doc-style ]
timeout-minutes: 15
steps:
- uses: actions/checkout@v4

- name: "Set up Python"
uses: ansys/actions/_setup-python@main
- name: Build documentation
uses: ansys/actions/doc-build@v8
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
use-cache: false

- name: 'Create virtual env'
run: |
python -m venv .venv
- name: "Update pip"
run: |
. .venv\Scripts\Activate.ps1
python -m pip install pip -U
python -m pip install wheel setuptools -U
python -c "import sys; print(sys.executable)"
- name: Install antenna toolkit with doc dependencies
run: |
. .venv\Scripts\Activate.ps1
pip install .
pip install .[doc]
- name: Uninstall conflicting CI packages
run: |
.venv\Scripts\Activate.ps1
pip uninstall vtk pypandoc -y
- name: Install CI dependencies (e.g. vtk-osmesa)
run: |
.venv\Scripts\Activate.ps1
pip uninstall --yes pypandoc vtk
pip install --extra-index-url https://wheels.vtk.org vtk-osmesa==9.2.20230527.dev0
pip install pypandoc-binary
- name: Retrieve antenna toolkit version
run: |
. .venv\Scripts\Activate.ps1
echo "Antenna Toolkit version is: $(python -c "from ansys.aedt.toolkits.antenna import __version__; print(); print(__version__)")"
- name: Build the documentation (HTML)
run: |
.\.venv\Scripts\Activate.ps1
cd doc
.\make.bat html
- name: Build the documentation (PDF)
run: |
.\.venv\Scripts\Activate.ps1
cd doc
.\make.bat pdf
- name: Add assets to HTML docs
run: |
zip -r documentation-html.zip .\doc\_build\html
mv documentation-html.zip .\doc\_build\html\_static\assets\download\
cp doc/_build/latex/ansys-aedt-toolkits-antenna.pdf .\doc\_build\html\_static\assets\download\
use-python-cache: false
add-pdf-html-docs-as-assets: true
check-links: true

- name: Upload HTML Documentation artifact
uses: actions/upload-artifact@v4
with:
name: documentation-html
path: doc/_build/html
retention-days: 1

- name: Upload PDF Documentation artifact
uses: actions/upload-artifact@v4
with:
name: documentation-pdf
path: doc/_build/latex/*.pdf
retention-days: 7

smoke-tests:
name: "Build and Smoke tests"
Expand All @@ -137,7 +70,7 @@ jobs:
runs-on: ${{ matrix.os }}
needs: [ code-style ]
steps:
- uses: ansys/actions/build-wheelhouse@v6
- uses: ansys/actions/build-wheelhouse@v8
with:
library-name: ${{ env.LIBRARY_NAME }}
operating-system: ${{ matrix.os }}
Expand Down Expand Up @@ -272,7 +205,7 @@ jobs:
runs-on: ubuntu-latest
needs: [ doc-build, tests_windows, tests_linux ]
steps:
- uses: ansys/actions/build-library@v6
- uses: ansys/actions/build-library@v8
with:
library-name: ${{ env.LIBRARY_NAME }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
Expand All @@ -289,13 +222,13 @@ jobs:
contents: write
steps:
- name: "Release to the public PyPI repository"
uses: ansys/actions/release-pypi-public@v6
uses: ansys/actions/release-pypi-public@v8
with:
library-name: ${{ env.LIBRARY_NAME }}
use-trusted-publisher: true

- name: "Release to GitHub"
uses: ansys/actions/release-github@v6
uses: ansys/actions/release-github@v8
with:
library-name: ${{ env.LIBRARY_NAME }}

Expand All @@ -305,62 +238,22 @@ jobs:
needs: build-library
if: github.event_name == 'push'
steps:
- uses: ansys/actions/doc-deploy-dev@v6
- uses: ansys/actions/doc-deploy-dev@v8
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}

doc-index-dev:
name: "Deploy development index documentation"
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: doc-deploy-dev
steps:
- name: "Deploy the latest documentation index"
uses: ansys/actions/doc-deploy-index@v6
with:
cname: ${{ env.DOCUMENTATION_CNAME }}/version/dev
index-name: pyaedt-toolkits-antenna-vdev
host-url: ${{ env.MEILISEARCH_HOST_URL }}
api-key: ${{ env.MEILISEARCH_API_KEY }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}

doc-deploy-stable:
name: "Deploy stable documentation"
runs-on: ubuntu-latest
needs: release
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
steps:
- uses: ansys/actions/doc-deploy-stable@v6
- uses: ansys/actions/doc-deploy-stable@v8
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}

doc-index-stable:
name: "Deploy stable documentation index"
runs-on: ubuntu-latest
needs: doc-deploy-stable
steps:
- name: "Install Git and clone project"
uses: actions/checkout@v4

- name: "Install the package requirements"
run: pip install -e .

- name: "Get the version to PyMeilisearch"
run: |
VERSION=$(python -c "from ansys.aedt.toolkits.antenna import __version__; print('.'.join(__version__.split('.')[:2]))")
VERSION_MEILI=$(python -c "from ansys.aedt.toolkits.antenna import __version__; print('-'.join(__version__.split('.')[:2]))")
echo "Calculated VERSION: $VERSION"
echo "Calculated VERSION_MEILI: $VERSION_MEILI"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION_MEILI=$VERSION_MEILI" >> $GITHUB_ENV
- name: "Deploy the latest documentation index"
uses: ansys/actions/doc-deploy-index@v6
with:
cname: ${{ env.DOCUMENTATION_CNAME }}/version/${{ env.VERSION }}
index-name: pyaedt-toolkits-antenna-v${{ env.VERSION_MEILI }}
host-url: ${{ env.MEILISEARCH_HOST_URL }}
api-key: ${{ env.MEILISEARCH_API_KEY }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}
23 changes: 16 additions & 7 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,32 @@ help:

.PHONY: help Makefile

clean:
rm -rf $(BUILDDIR)/*
rm -rf examples/
find . -type d -name "_autosummary" -exec rm -rf {} +
.install-deps:
@pip freeze | grep -q "vtk-osmesa" && is_vtk_osmesa_installed="yes" || is_vtk_osmesa_installed="no"
@if [ "${ON_CI}" = "True" ] && [ "$$is_vtk_osmesa_installed" != "yes" ]; then \
@echo "Removing vtk to avoid conflicts with vtk-osmesa needed for CI/CD"; \
pip uninstall --yes vtk; \
@echo "Installing vtk-osmesa"; \
pip install --extra-index-url https://wheels.vtk.org vtk-osmesa; \
fi

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
%: .install-deps Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

clean: .install-deps
rm -rf $(BUILDDIR)/*
rm -rf examples/
find . -type d -name "_autosummary" -exec rm -rf {} +

# build html docs in parallel using all available CPUs
# WARNING: this is a resource hog
html:
html: .install-deps
$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -j auto

# Build pdf docs.
pdf:
pdf: .install-deps
@$(SPHINXBUILD) -M latex "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
cd $(BUILDDIR)/latex && latexmk -r latexmkrc -pdf *.tex -interaction=nonstopmode || true
(test -f $(BUILDDIR)/latex/ansys-aedt-toolkits-antenna.pdf && echo pdf exists) || exit 1
Expand Down
12 changes: 12 additions & 0 deletions doc/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ if "%SPHINXBUILD%" == "" (
set SOURCEDIR=source
set BUILDDIR=_build

REM This LOCs are used to uninstall and install specific package(s) during CI/CD
for /f %%i in ('pip freeze ^| findstr /c:"vtk-osmesa"') do set is_vtk_osmesa_installed=%%i
if NOT "%is_vtk_osmesa_installed%" == "vtk-osmesa" if "%ON_CI%" == "true" (
@ECHO ON
echo "Removing vtk to avoid conflicts with vtk-osmesa"
@ECHO OFF
pip uninstall --yes vtk
@ECHO ON
echo "Installing vtk-osmesa"
@ECHO OFF
pip install --extra-index-url https://wheels.vtk.org vtk-osmesa)

if "%1" == "" goto help
if "%1" == "clean" goto clean
if "%1" == "pdf" goto pdf
Expand Down
37 changes: 5 additions & 32 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,6 @@
# Sphinx event hooks


def check_example_error(app, pagename, templatename, context, doctree):
"""Log an error if the execution of an example as a notebook triggered an error.
Since the documentation build might not stop if the execution of a notebook triggered
an error, we use a flag to log that an error is spotted in the html page context.
"""
# Check if the HTML contains an error message
if pagename.startswith("examples") and not pagename.endswith("/index"):
if any(
map(
lambda msg: msg in context["body"],
["UsageError", "NameError", "DeadKernelError", "NotebookError"],
)
):
logger.error(f"An error was detected in file {pagename}")
app.builder.config.html_context["build_error"] = True


def check_build_finished_without_error(app, exception):
"""Check that no error is detected along the documentation build process."""
if app.builder.config.html_context.get("build_error", False):
raise Exception("Build failed due to an error in html-page-context")


def check_pandoc_installed(app):
"""Ensure that pandoc is installed"""
import pypandoc
Expand All @@ -93,8 +69,6 @@ def check_pandoc_installed(app):

def setup(app):
app.connect("builder-inited", check_pandoc_installed)
app.connect("html-page-context", check_example_error)
app.connect("build-finished", check_build_finished_without_error)


print(__version__)
Expand Down Expand Up @@ -146,12 +120,6 @@ def setup(app):
"icon": "fa fa-file-pdf fa-fw",
},
],
"use_meilisearch": {
"api_key": os.getenv("MEILISEARCH_PUBLIC_API_KEY", ""),
"index_uids": {
f"pyaedt-toolkits-antenna-v{get_version_match(__version__).replace('.', '-')}": "AEDT TOOLKITS ANTENNA API",
},
},
}

# Sphinx extensions
Expand Down Expand Up @@ -197,6 +165,11 @@ def setup(app):
# type, unless multiple values are being returned"
}

# Removing check on repo lines of code as using line numbers as anchor is not working
linkcheck_ignore = [
"https://github.com/ansys/pyaedt-toolkits-antenna/blob/main/src/ansys/aedt/toolkits/antenna/ui/" "actions.py#L165",
"https://github.com/ansys/pyaedt-toolkits-antenna/blob/main/src/ansys/aedt/toolkits/antenna/ui/" "actions.py#L143",
]

# static path
html_static_path = ["_static"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def theta_cut_combobox_clicked(self):
self.__plot_2d_cut(self.farfield_2d_theta_graph, data, theta, "Theta", "Phi")

def __plot_2d_cut(self, graph_obj, data, cut, cut_name, sweep):
lines = data.gca().get_lines()
lines = data.ax.get_lines()
x_data = lines[-1].get_xdata()
y_data = lines[-1].get_ydata()
graph_obj.plot(
Expand Down

0 comments on commit e58a58c

Please sign in to comment.