Skip to content

feat: generate pymechanical-stubs & its Sphinx documentation for 23.2 #134

feat: generate pymechanical-stubs & its Sphinx documentation for 23.2

feat: generate pymechanical-stubs & its Sphinx documentation for 23.2 #134

Workflow file for this run

name: GitHub CI
on:
pull_request:
workflow_dispatch:
push:
tags:
- "*"
branches:
- main
- release/*
env:
PYMECHANICAL_PORT: 10000 # default won't work on GitHub runners
PYMECHANICAL_START_INSTANCE: FALSE
DOCKER_PACKAGE: ghcr.io/ansys/mechanical
DOCKER_IMAGE_VERSION: 23.2.0
DOCKER_MECH_CONTAINER_NAME: mechanical
MAIN_PYTHON_VERSION: '3.10'
PACKAGE_NAME: ansys-mechanical-stubs
PACKAGE_NAMESPACE: ansys.mechanical.stubs
DOCUMENTATION_CNAME: scripting.mechanical.docs.pyansys.com
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
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 }}
doc-style:
name: Documentation Style Check
runs-on: ubuntu-latest
steps:
- name: PyAnsys documentation style checks
uses: ansys/actions/doc-style@v4
with:
vale-config: package/doc/.vale.ini
token: ${{ secrets.GITHUB_TOKEN }}
doc-build:
name: Create docstrings
needs: [style, doc-style]
runs-on: ubuntu-latest
container:
image: ghcr.io/ansys/mechanical:23.2.0
options: --entrypoint /bin/bash
strategy:
matrix:
python-version: ['3.9']
steps:
- name: Install Git and checkout project
uses: actions/checkout@v3
- name: Install dependencies
run: |
apt update
apt install --reinstall ca-certificates
apt install software-properties-common -y
add-apt-repository ppa:deadsnakes/ppa -y
apt install python${{ matrix.python-version }} -y
ln -s /usr/bin/python${{ matrix.python-version }} /usr/bin/python
apt install python${{ matrix.python-version }}-venv -y
python -m ensurepip --default-pip
pip install --upgrade pip
python --version
pip --version
apt update
apt install -y lsb-release
apt install -y mono-complete
apt install -y make
apt-get install -y zip
pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org pip setuptools
pip install --upgrade pip flit pytz tzdata
cd package
mkdir -p src/ansys/mechanical/stubs
touch src/ansys/mechanical/stubs/__init__.py
pip install -e .[doc]
- name: Run main.py
env:
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }}
ANSYSCL232_DIR: /install/ansys_inc/v232/licensingclient
ANSYSLMD_LICENSE_FILE: 1055@${{ secrets.LICENSE_SERVER }}
ANSYS_WORKBENCH_LOGGING_CONSOLE: 0
ANSYS_WORKBENCH_LOGGING: 0
ANSYS_WORKBENCH_LOGGING_FILTER_LEVEL: 2
AWP_ROOTDV_DEV: /install/ansys_inc/v232
NUM_CORES: 1
run: |
python main.py > results.txt
continue-on-error: True
- name: Check main.py results
run: |
cat results.txt
# Check if failure occurred
output=$(grep -c "Done processing all mechanical stubs" results.txt)
if [ $output -eq 1 ]; then
echo "All mechanical stubs were created"
exit 0
else
echo "There was an issue creating the mechanical stubs"
exit 1
fi
- name: Retrieve Mechanial version
run: |
cd package
pip install -e .
echo "MECHANICAL_VERSION=$(python -c 'from ansys.mechanical.stubs import __version__; print(__version__)')" >> $GITHUB_ENV
echo "Mechanical version is: $(python -c "from ansys.mechanical.stubs import __version__; print(__version__)")"
- name: Install build and twine, and build dist artifacts
run: |
cd package
python -m pip install .[package]
python -m pip install build twine
python -m build && python -m twine check dist/*
- name: "Upload distribution artifacts to GitHub artifacts"
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}-artifacts
path: package/dist/
retention-days: 7
# - name: Install package and create wheelhouse
# run: |
# cd package
# python -m pip install .[package]
# python -m pip install importlib-metadata
# python -m pip wheel .[package] -w wheelhouse
# - name: "Compress the wheelhouse"
# uses: vimtor/[email protected]
# with:
# files: package/wheelhouse
# dest: ${{ env.PACKAGE_NAME }}-v${{ env.MECHANICAL_VERSION }}-wheelhouse-ubuntu-latest-${{ matrix.python-version }}.zip
# - name: "Upload the compressed wheelhouse"
# uses: actions/upload-artifact@v4
# with:
# name: ${{ env.PACKAGE_NAME }}-v${{ env.MECHANICAL_VERSION }}-wheelhouse-ubuntu-latest-${{ matrix.python-version }}
# path: ${{ env.PACKAGE_NAME }}-v${{ env.MECHANICAL_VERSION }}-wheelhouse-ubuntu-latest-${{ matrix.python-version }}.zip
# retention-days: 7
- name: Create Sphinx documentation
run: |
make -C package/doc html
- name: Generate needed files for deploying pages
run: |
touch package/doc/_build/html/.nojekyll
echo ${{ env.DOCUMENTATION_CNAME }} >> package/doc/_build/html/CNAME
- name: Upload HTML Documentation
uses: actions/upload-artifact@v3
with:
name: documentation-html
path: package/doc/_build/html
retention-days: 7
doc-deploy:
name: Documentation deploy
runs-on: ubuntu-latest
needs: [doc-build]
steps:
- name: Checkout
uses: actions/checkout@v3
- 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