docs #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: docs | |
on: | |
# Can be called by the CI | |
workflow_call: | |
inputs: | |
python_version: | |
required: false | |
type: string | |
default: "3.8" | |
ANSYS_VERSION: | |
required: false | |
type: string | |
default: "241" | |
standalone_suffix: | |
description: "Suffix of the branch on standalone" | |
required: false | |
type: string | |
default: '' | |
custom-requirements: | |
description: "Path to requirements.txt file to install" | |
required: false | |
type: string | |
default: '' | |
custom-wheels: | |
description: "extra pip '--find-links XXX' argument to find custom dpf wheels" | |
required: false | |
type: string | |
default: '' | |
event_name: | |
description: "Name of event calling" | |
required: true | |
type: string | |
default: '' | |
generate_pdf: | |
description: "Whether to build the PDF doc" | |
type: string | |
default: 'True' | |
debug: | |
description: "Debug verbose mode" | |
type: string | |
default: 'True' | |
# Can be called manually | |
workflow_dispatch: | |
inputs: | |
python_version: | |
description: "Python interpreter" | |
required: true | |
type: string | |
default: "3.8" | |
ANSYS_VERSION: | |
description: "ANSYS version" | |
required: true | |
type: string | |
default: "241" | |
standalone_suffix: | |
description: "Suffix of the branch on standalone" | |
required: false | |
type: string | |
default: '' | |
custom-requirements: | |
description: "Path to requirements.txt file to install" | |
required: false | |
type: string | |
default: '' | |
custom-wheels: | |
description: "extra pip --find-links argument to find custom dpf wheels" | |
required: false | |
type: string | |
default: '' | |
generate_pdf: | |
description: "Whether to build the PDF doc" | |
type: string | |
default: 'True' | |
env: | |
PACKAGE_NAME: ansys-dpf-post | |
MODULE: post | |
jobs: | |
doc-style: | |
name: "Check doc style" | |
uses: ./.github/workflows/docs-style.yml | |
with: | |
vale_reporter: ${{ (inputs.event_name == 'pull_request') && 'github-check' || 'local' }} | |
secrets: inherit | |
docs: | |
name: "Documentation" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: "Set licensing if necessary" | |
if: inputs.ANSYS_VERSION > 231 | |
shell: bash | |
run: | | |
echo "ANSYS_DPF_ACCEPT_LA=Y" >> $GITHUB_ENV | |
echo "ANSYSLMD_LICENSE_FILE=1055@${{ secrets.LICENSE_SERVER }}" >> $GITHUB_ENV | |
- name: Setup Python | |
uses: actions/setup-python@v4.6.0 | |
with: | |
python-version: ${{ inputs.python_version }} | |
- name: "Install OS packages" | |
shell: bash | |
run: | | |
sudo apt update | |
sudo apt install pandoc texlive-latex-extra latexmk | |
- name: "Build Package" | |
id: build-package | |
uses: ansys/pydpf-actions/build_package@v2.3 | |
with: | |
python-version: ${{ inputs.python_version }} | |
ANSYS_VERSION: ${{inputs.ANSYS_VERSION}} | |
PACKAGE_NAME: ${{env.PACKAGE_NAME}} | |
MODULE: ${{env.MODULE}} | |
dpf-standalone-TOKEN: ${{secrets.DPF_PIPELINE}} | |
install_extras: plotting | |
wheel: false | |
wheelhouse: false | |
extra-pip-args: ${{ inputs.custom-wheels && format('--find-links {0}', inputs.custom-wheels) || '' }} | |
standalone_suffix: ${{ inputs.standalone_suffix }} | |
custom-requirements: ${{ inputs.custom-requirements }} | |
- name: "Setup headless display" | |
uses: pyvista/setup-headless-display-action@v2 | |
- name: "Install documentation requirements" | |
shell: bash | |
run: | | |
pip install -r requirements/requirements_docs.txt | |
- name: "List installed packages" | |
shell: bash | |
run: pip list | |
- name: "Build sphinx doc" | |
shell: bash | |
run: | | |
export SPHINX_APIDOC_OPTIONS=inherited-members | |
sphinx-apidoc -o docs/source/api src/ansys ${{inputs.build_extras}} -f --implicit-namespaces --separate --no-headings $DEBUG_SPHINX | |
- name: "Build HTML Documentation" | |
shell: bash | |
working-directory: docs | |
run: | | |
export TEMP=${{ runner.temp }} | |
make clean | |
echo "Making html doc..." | |
make html $DEBUG_HTML >> log.txt 2>&1 | |
- name: "Check for success" | |
shell: bash | |
working-directory: docs | |
run: | | |
case `tail -n 5 log.txt | grep -F "build succeeded" >/dev/null; echo $?` in | |
0) | |
echo "Build succeeded!" | |
exit 0;; | |
1) | |
echo "Documentation generation failed, please check previous step!" | |
exit 1;; | |
*) | |
echo "An error occurred while checking success of the previous step!" | |
exit 1;; | |
esac | |
- name: "Build PDF Documentation" | |
shell: bash | |
working-directory: docs | |
if: ${{ inputs.generate_pdf == 'true' }} | |
run: | | |
export TEMP=${{ runner.temp }} | |
echo "Making pdf doc..." | |
make pdf $DEBUG_PDF | |
- name: "Upload Documentation Build log" | |
uses: actions/upload-artifact@v3.1.0 | |
with: | |
name: doc-${{env.PACKAGE_NAME}}-log | |
path: docs/*.txt | |
if: always() | |
- name: "Upload HTML Documentation" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: HTML-doc-${{env.PACKAGE_NAME}} | |
path: | | |
docs/build/html/ | |
if: always() | |
- name: "Find PDF Documentation" | |
shell: bash | |
if: ${{ inputs.generate_pdf == 'true' }} | |
id: pdf | |
working-directory: docs/build/latex | |
run: | | |
pattern="PyDPF-*.pdf" | |
files=( $pattern ) | |
echo "PDF_file=${files[0]}" >> $GITHUB_OUTPUT | |
echo "Found PDF doc: ${files[0]}" | |
- name: "Zip PDF Documentation" | |
uses: vimtor/action-zip@v1.1 | |
if: ${{ inputs.generate_pdf == 'true' }} | |
with: | |
files: docs/build/latex/${{ steps.pdf.outputs.PDF_file }} | |
dest: PDF-doc-${{env.PACKAGE_NAME}}.zip | |
- name: "Upload PDF Documentation" | |
uses: actions/upload-artifact@v3.1.0 | |
if: inputs.generate_pdf == 'true' | |
with: | |
name: PDF-doc-${{env.PACKAGE_NAME}} | |
path: PDF-doc-${{env.PACKAGE_NAME}}.zip | |
- name: "Kill all servers" | |
uses: ansys/pydpf-actions/kill-dpf-servers@v2.3 | |
if: always() |