CI #528
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: CI | |
on: | |
workflow_dispatch: | |
schedule: # UTC at 0300 | |
- cron: "0 3 * * *" | |
pull_request: | |
push: | |
tags: | |
- "*" | |
branches: | |
- main | |
env: | |
MAIN_PYTHON_VERSION: '3.9' | |
PYMECHANICAL_VERSION: '23.2' | |
RESET_EXAMPLES_CACHE: 0 | |
RESET_DOC_BUILD_CACHE: 0 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: write | |
pull-requests: write | |
packages: read | |
jobs: | |
style: | |
name: Code style | |
runs-on: ubuntu-latest | |
steps: | |
- name: PyAnsys code style checks | |
uses: ansys/actions/code-style@v4 | |
with: | |
python-version: ${{ env.MAIN_PYTHON_VERSION }} | |
use-python-cache: false | |
doc-style: | |
name: Documentation Style Check | |
runs-on: ubuntu-latest | |
steps: | |
- name: PyAnsys documentation style checks | |
uses: ansys/actions/doc-style@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
doc-build: | |
name: Documentation building | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/ansys/mechanical:23.2.0 | |
options: --entrypoint /bin/bash | |
needs: [style, doc-style] | |
steps: | |
- name: Install Git and checkout project | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
run: | | |
apt update | |
apt install -y python3.9 python3-pip | |
ln -s /usr/bin/python3.9 /usr/bin/python | |
python -m pip install --upgrade pip | |
python --version | |
pip3 --version | |
- name: Install system dependencies | |
run: | | |
apt update | |
apt install -y sudo curl lsb-release | |
apt install -y zip pandoc libgl1-mesa-glx mesa-utils xvfb texlive-latex-extra latexmk nodejs npm graphviz | |
apt install -y tini | |
# pip3 install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org | |
npm install -g @mermaid-js/mermaid-cli | |
- name: Install Python requirements | |
run: | | |
pip3 install -r requirements/requirements_doc.txt | |
- name: Retrieve PyMechanial version | |
run: | | |
echo "PYMECHANICAL_VERSION=$(python -c 'from ansys.mechanical.core import __version__; print(__version__)')" >> $GITHUB_ENV | |
echo "PyMechanical version is: $(python -c "from ansys.mechanical.core import __version__; print(__version__)")" | |
id: version | |
# - name: Cache Basic examples | |
# uses: actions/cache@v3 | |
# with: | |
# path: doc/source/basic | |
# key: Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ env.PYMECHANICAL_VERSION }}-${{ github.sha }} | |
# restore-keys: | | |
# Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ env.PYMECHANICAL_VERSION }} | |
# - name: "Cache docs build directory" | |
# uses: actions/cache@v3 | |
# with: | |
# path: doc/_build | |
# key: doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ env.PYMECHANICAL_VERSION }}-${{ github.sha }} | |
# restore-keys: | | |
# doc-build-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ env.PYMECHANICAL_VERSION }} | |
- name: Build docs | |
env: | |
SPHINXOPTS: '-j auto' | |
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }} | |
ANSYSCL232_DIR: /install/ansys_inc/v232/licensingclient | |
ANSYSLMD_LICENSE_FILE: 1055@${{ secrets.LICENSE_SERVER }} | |
ANSYS_WORKBENCH_LOGGING_FILTER_LEVEL: 0 | |
run: | | |
xvfb-run /install/ansys_inc/v232/aisol/.workbench_lite make -C doc html > doc_build_output.txt 2>&1 || true | |
cat doc_build_output.txt | |
# | |
# Check if "build succeeded" string is present in doc_build_output.txt | |
# | |
if grep -q "build succeeded" doc_build_output.txt; then | |
echo "Documentation building succeeded" | |
exit 0 | |
else | |
echo "Documentation building failed" | |
exit 1 | |
fi | |
- name: Upload HTML Documentation | |
uses: actions/upload-artifact@v3 | |
with: | |
name: documentation-html | |
path: doc/_build/html | |
retention-days: 7 | |
doc-deploy: | |
name: Documentation deploy | |
runs-on: ubuntu-latest | |
needs: [doc-build] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: documentation-html | |
path: documentation-html | |
- name: List all files | |
run: ls -R . | |
- name: Deploy to GitHub Pages | |
if: contains(github.ref, 'refs/heads/main') | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: gh-pages | |
folder: documentation-html/ | |
clean: true | |
single-commit: true |