Skip to content

Build and Test Package #1482

Build and Test Package

Build and Test Package #1482

Workflow file for this run

# check spelling, codestyle
name: Build and Test Package
# run only on main branch. This avoids duplicated actions on PRs
on:
pull_request:
merge_group:
push:
tags:
- "*"
branches:
- main
env:
MAIN_PYTHON_VERSION: '3.10'
LIBRARY_NAME: 'ansys-openapi-common'
jobs:
code-style:
name: "Code style"
runs-on: windows-latest
steps:
- uses: ansys/actions/code-style@v5
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
skip-install: "false"
doc-style:
name: Documentation Style Check
runs-on: ubuntu-latest
steps:
- name: PyAnsys documentation style checks
uses: pyansys/actions/doc-style@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
doc-build:
name: Build Documentation
runs-on: ubuntu-latest
needs: doc-style
steps:
- name: "Checkout the repository"
uses: actions/checkout@v4
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: "Install system dependencies"
run: |
sudo apt-get update && sudo apt-get install pandoc libkrb5-dev
- name: "Install Python dependencies"
run: |
python -m pip install --upgrade pip tox
python -m pip install poetry~=1.7.0
- name: Install library
run: |
poetry install --with docs --extras "oidc linux-kerberos"
- name: Build HTML
run: make -C doc html SPHINXOPTS="-W"
- name: Build PDF Documentation
run: |
sudo apt update
sudo apt-get install -y texlive-latex-extra latexmk texlive-xetex fonts-freefont-otf xindy
make -C doc latexpdf
- name: Upload HTML Documentation
uses: actions/upload-artifact@v4
with:
name: documentation-html
path: doc/build/html
retention-days: 7
- name: Upload PDF Documentation
uses: actions/upload-artifact@v4
with:
name: documentation-pdf
path: doc/build/latex/*.pdf
retention-days: 7
smoke-tests:
name: "Build wheelhouse for latest Python versions"
runs-on: ${{ matrix.os }}
needs: code-style
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- name: Install kerberos headers
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt install libkrb5-dev
- uses: ansys/actions/build-wheelhouse@v5
with:
library-name: ${{ env.LIBRARY_NAME }}
operating-system: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
tests:
name: Unit test on supported platforms
runs-on: ubuntu-latest
needs: smoke-tests
services:
# Label used to access the service container
kdc-server:
# Github container registry address
image: ghcr.io/ansys/kdc-container:v0.2
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
volumes:
# This is needed otherwise there won't be enough entropy to generate a new kerberos realm
- /dev/urandom:/dev/random
- /tmp/keytabs:/tmp/keytabs
ports:
- 749:749
- 88:88/udp
container:
image: python:${{ matrix.python-version }}
volumes:
- /tmp/keytabs:/tmp/keytabs
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Configure host kerberos
run: |
apt update
export DEBIAN_FRONTEND=noninteractive
apt install -yq krb5-user
cp ./tests/integration/krb5.conf /etc/krb5.conf
./tests/integration/configure_keytab.sh
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install 'tox<4' poetry
- name: Test with tox
run: tox -- --with-kerberos
- name: Upload coverage report
uses: codecov/codecov-action@v3
if: ${{ github.actor != 'dependabot[bot]' }}
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
build-library:
name: "Build library"
runs-on: ubuntu-latest
needs: [ doc-build, tests ]
steps:
- name: Install kerberos headers
run: |
sudo apt-get update
sudo apt install libkrb5-dev
- uses: ansys/actions/build-library@v5
with:
library-name: ${{ env.LIBRARY_NAME }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
release:
name: "Release"
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
needs: [build-library]
runs-on: ubuntu-latest
steps:
- uses: ansys/actions/release-pypi-public@v5
name: "Release to public PyPI"
with:
library-name: ${{ env.LIBRARY_NAME }}
twine-username: "__token__"
twine-token: ${{ secrets.PYPI_TOKEN }}
- uses: ansys/actions/release-github@v5
name: "Release to GitHub"
with:
library-name: ${{ env.LIBRARY_NAME }}
doc-deploy-stable:
name: "Deploy stable documentation"
runs-on: ubuntu-latest
needs: release
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
steps:
- name: Get Bot Application Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v3
with:
application_id: ${{ secrets.BOT_APPLICATION_ID }}
application_private_key: ${{ secrets.BOT_APPLICATION_PRIVATE_KEY }}
- uses: actions/download-artifact@v4
with:
name: documentation-html
path: ~/html
- name: Deploy
uses: JamesIves/[email protected]
with:
repository-name: pyansys/openapi-common-docs
token: ${{ steps.get_workflow_token.outputs.token }}
BRANCH: gh-pages
FOLDER: ~/html
CLEAN: true