feat: add missing APIs #665
Workflow file for this run
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: GitHub CI | |
on: | |
pull_request: | |
workflow_dispatch: | |
push: | |
tags: | |
- "*" | |
branches: | |
- main | |
env: | |
MAIN_PYTHON_VERSION: '3.10' | |
PACKAGE_NAME: ansys-mechanical-stubs | |
PACKAGE_NAMESPACE: ansys.mechanical.stubs | |
PACKAGE_PATH: src/ansys/mechanical/stubs | |
DOCUMENTATION_CNAME: scripting.mechanical.docs.pyansys.com | |
LICENSE_SERVER: ${{ secrets.LICENSE_SERVER }} | |
ANSYSLMD_LICENSE_FILE: 1055@${{ secrets.LICENSE_SERVER }} | |
ANSYS_WORKBENCH_LOGGING_CONSOLE: 0 | |
ANSYS_WORKBENCH_LOGGING: 0 | |
ANSYS_WORKBENCH_LOGGING_FILTER_LEVEL: 2 | |
NUM_CORES: 1 | |
MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY }} | |
MEILISEARCH_HOST_URL: ${{ vars.MEILISEARCH_HOST_URL }} | |
MEILISEARCH_PUBLIC_API_KEY: ${{ secrets.MEILISEARCH_PUBLIC_API_KEY }} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
update-changelog: | |
name: "Update CHANGELOG for new tag" | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags') | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- uses: ansys/actions/doc-deploy-changelog@v8 | |
with: | |
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} | |
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} | |
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} | |
style: | |
name: Code style | |
runs-on: ubuntu-latest | |
steps: | |
- name: "PyAnsys code style checks" | |
uses: ansys/actions/code-style@v8 | |
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@v8 | |
with: | |
vale-config: doc/.vale.ini | |
token: ${{ secrets.GITHUB_TOKEN }} | |
gen-stubs: | |
name: Generate Mechanical stubs | |
needs: [style, doc-style] | |
runs-on: ${{ matrix.os }} | |
container: | |
image: ghcr.io/ansys/mechanical:${{ matrix.mechanical.image }} | |
options: --entrypoint /bin/bash | |
strategy: | |
matrix: | |
os: [public-ubuntu-latest-8-cores] | |
mechanical: [ | |
{ image: '24.1.0', version: '241' }, | |
{ image: '24.2.0', version: '242' }, | |
] | |
python-version: ['3.10', '3.11', '3.12'] | |
steps: | |
- name: "Install Git and clone project" | |
uses: actions/checkout@v4 | |
- name: "Install dependencies" | |
env: | |
AWP_ROOTDV_DEV: /install/ansys_inc/v${{ matrix.mechanical.version }} | |
ANSYSCL${{ matrix.mechanical.version }}_DIR: /install/ansys_inc/v${{ matrix.mechanical.version }}/licensingclient | |
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 | |
apt install -y lsb-release mono-complete make git zip | |
python -m ensurepip --default-pip | |
python -m pip install --upgrade pip | |
python --version | |
python -m pip --version | |
python -m pip install -e .[build,doc] | |
python -m pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org pip setuptools | |
python -m pip install --upgrade pip flit pytz tzdata ansys-pythonnet | |
- name: "Generate the Mechanical stub files" | |
env: | |
AWP_ROOTDV_DEV: /install/ansys_inc/v${{ matrix.mechanical.version }} | |
ANSYSCL${{ matrix.mechanical.version }}_DIR: /install/ansys_inc/v${{ matrix.mechanical.version }}/licensingclient | |
run: | | |
python src/ansys/mechanical/stubs/stub_generator/create_files.py > results.txt | |
continue-on-error: True | |
- name: "Check stubs were generated" | |
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: "Upload v${{ matrix.mechanical.version }} stubs" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: v${{ matrix.mechanical.version }}-${{ matrix.python-version }} | |
path: ${{ env.PACKAGE_PATH }}/v${{ matrix.mechanical.version }} | |
retention-days: 7 | |
smoke-tests: | |
name: Build wheelhouse | |
runs-on: ${{ matrix.os }} | |
needs: [gen-stubs] | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
python-version: ['3.10', '3.11', '3.12'] | |
steps: | |
- name: "Install Git and clone project" | |
uses: actions/checkout@v4 | |
- name: "Download stubs" | |
uses: ./.github/workflows/setup-stubs/ | |
with: | |
folder-pattern: "v[0-9][0-9][0-9]-${{ matrix.python-version }}" | |
package-path: "${{ env.PACKAGE_PATH }}" | |
python-version: ${{ matrix.python-version }} | |
- name: Install build requirements | |
run: | | |
pip install -U pip | |
pip install build | |
- name: Build project | |
run: | | |
python -m build | |
- name: Install on Windows | |
if: matrix.os == 'windows-latest' | |
run: | | |
New-Item -Path $PWD -Name "wheelhouse" -ItemType "Directory" | |
cd dist | |
$files = Get-ChildItem -Path $PWD | Where-Object { $_.Extension -eq '.whl' } | |
foreach ($file in $files) { | |
Copy-Item -Path "$file" -Destination "..\wheelhouse" | |
pip install $file | |
} | |
- name: Install on Ubuntu | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
mkdir wheelhouse | |
cp dist/*.whl wheelhouse | |
pip install dist/*.whl | |
- name: "Retrieve Mechanical version" | |
shell: python | |
run: | | |
import os | |
from ${{ env.PACKAGE_NAMESPACE }} import __version__ | |
# Get the GITHUB_ENV variable | |
github_env = os.getenv('GITHUB_ENV') | |
with open(github_env, "a") as f: | |
f.write(f"MECHANICAL_VERSION={__version__}") | |
print(f"Mechanical version is {__version__}") | |
- name: "Compress the wheelhouse" | |
uses: vimtor/[email protected] | |
with: | |
files: wheelhouse | |
dest: ${{ env.PACKAGE_NAME }}-v${{ env.MECHANICAL_VERSION }}-wheelhouse-${{ matrix.os }}-${{ matrix.python-version }}.zip | |
- name: "Upload the compressed wheelhouse" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.PACKAGE_NAME }}-v${{ env.MECHANICAL_VERSION }}-wheelhouse-${{ matrix.os }}-${{ matrix.python-version }} | |
path: ${{ env.PACKAGE_NAME }}-v${{ env.MECHANICAL_VERSION }}-wheelhouse-${{ matrix.os }}-${{ matrix.python-version }}.zip | |
retention-days: 7 | |
doc-build: | |
name: Make html and markdown documentation | |
needs: [smoke-tests] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.10'] | |
steps: | |
- name: "Install Git and clone project" | |
uses: actions/checkout@v4 | |
- name: "Download stubs" | |
uses: ./.github/workflows/setup-stubs/ | |
with: | |
folder-pattern: "v[0-9][0-9][0-9]-${{ matrix.python-version }}" | |
package-path: "${{ env.PACKAGE_PATH }}" | |
python-version: ${{ matrix.python-version }} | |
- name: "Install project & doc dependencies" | |
run: | | |
python -m pip install -e .[doc] | |
- name: "Generate HTML documentation" | |
run: | | |
make -C doc html | |
make -C doc pdf | |
- name: "Upload original Sphinx HTML documentation" | |
uses: actions/upload-artifact@v4 | |
if: matrix.python-version == env.MAIN_PYTHON_VERSION | |
with: | |
name: original-documentation-html | |
path: doc/_build/html | |
retention-days: 7 | |
- name: "Generate Markdown documentation" | |
run: | | |
make -C doc markdown | |
- name: "Upload original markdown documentation" | |
uses: actions/upload-artifact@v4 | |
if: matrix.python-version == env.MAIN_PYTHON_VERSION | |
with: | |
name: original-documentation-md | |
path: doc/_build/markdown | |
retention-days: 7 | |
- name: "Replace Windows apostrophes with single quotes" | |
run: | | |
python scripts/replace-windows-apostrophes.py | |
- name: "Make all hrefs local in Markdown" | |
run: | | |
python scripts/fix-href-md.py | |
- name: "Make all hrefs local in HTML" | |
run: | | |
python scripts/fix-href-html.py | |
- name: "Clean ID in first row" | |
run: | | |
python scripts/01-clean-id.py | |
- name: "Clean empty rows" | |
run: | | |
python scripts/02-clean-empty-row.py | |
- name: "Create table of contents" | |
run: | | |
python scripts/03-create-toc-from-html-mechanical.py | |
- name: "Fix paths in toc.yml" | |
shell: bash | |
run: | | |
# Remove doc/_build/html from paths in toc.yml file | |
sed -i -e 's;doc/_build/html/;;g' output/toc.yml | |
- name: "Add header to tables" | |
run: | | |
python scripts/04-add-header-to-tables.py | |
- name: "Remove links in heading" | |
run: | | |
python scripts/05-remove-link-in-heading.py | |
- name: "Upload toc.yml" | |
if: matrix.python-version == env.MAIN_PYTHON_VERSION | |
uses: actions/upload-artifact@v4 | |
with: | |
name: toc-file | |
path: output/ | |
- name: "Upload Markdown documentation" | |
uses: actions/upload-artifact@v4 | |
if: matrix.python-version == env.MAIN_PYTHON_VERSION | |
with: | |
name: documentation-md | |
path: doc/_build/markdown | |
retention-days: 7 | |
- name: "Upload HTML documentation" | |
uses: actions/upload-artifact@v4 | |
if: matrix.python-version == env.MAIN_PYTHON_VERSION | |
with: | |
name: documentation-html | |
path: doc/_build/html | |
retention-days: 7 | |
- name: Upload PDF Documentation | |
if: matrix.python-version == env.MAIN_PYTHON_VERSION | |
uses: actions/upload-artifact@v4 | |
with: | |
name: documentation-pdf | |
path: doc/_build/latex/doc.pdf | |
retention-days: 7 | |
build-library: | |
name: Build library | |
runs-on: ubuntu-latest | |
needs: [doc-build] | |
steps: | |
- name: "Install Git and clone project" | |
uses: actions/checkout@v4 | |
- name: "Set up Python" | |
uses: ansys/actions/_setup-python@v8 | |
with: | |
python-version: ${{ env.MAIN_PYTHON_VERSION }} | |
use-cache: false | |
- name: "Download stubs" | |
uses: ./.github/workflows/setup-stubs/ | |
with: | |
folder-pattern: "v[0-9][0-9][0-9]-${{ env.MAIN_PYTHON_VERSION }}" | |
package-path: "${{ env.PACKAGE_PATH }}" | |
python-version: ${{ env.MAIN_PYTHON_VERSION }} | |
- name: "Install build and twine" | |
shell: bash | |
run: | | |
python -m pip install build twine | |
- name: "Build distribution artifacts" | |
shell: bash | |
run: | | |
python -m build | |
- name: "Check build health" | |
shell: bash | |
run: | | |
python -m twine check dist/* | |
- name: "Upload distribution artifacts to GitHub artifacts" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.PACKAGE_NAME }}-artifacts | |
path: dist/ | |
retention-days: 7 | |
release: | |
runs-on: ubuntu-latest | |
needs: [build-library, update-changelog] | |
environment: release | |
permissions: | |
id-token: write | |
contents: write | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags') | |
steps: | |
- name: "Release to the public PyPI repository" | |
uses: ansys/actions/release-pypi-public@v8 | |
with: | |
library-name: ${{ env.PACKAGE_NAME }} | |
use-trusted-publisher: true | |
- name: "Release to GitHub" | |
uses: ansys/actions/release-github@v8 | |
with: | |
library-name: ${{ env.PACKAGE_NAME }} | |
doc-deploy-dev: | |
name: "Deploy development documentation" | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
needs: [doc-build] | |
steps: | |
- name: "Deploy development documentation" | |
uses: ansys/actions/doc-deploy-dev@v8 | |
with: | |
cname: ${{ env.DOCUMENTATION_CNAME }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
doc-artifact-name: 'documentation-html' | |
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} | |
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} | |
doc-deploy-stable: | |
name: "Deploy stable documentation" | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags') | |
runs-on: ubuntu-latest | |
needs: release | |
steps: | |
- name: "Deploy stable documentation" | |
uses: ansys/actions/doc-deploy-stable@v8 | |
with: | |
cname: ${{ env.DOCUMENTATION_CNAME }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
doc-artifact-name: 'documentation-html' | |
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} | |
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} |