Skip to content

GitHub CI

GitHub CI #2800

Workflow file for this run

# check spelling, codestyle
name: GitHub CI
# run only on main branch. This avoids duplicated actions on PRs
on:
workflow_dispatch:
schedule: # UTC at 0300
- cron: "0 3 * * *"
pull_request:
push:
tags:
- "*"
branches:
- main
env:
MAIN_PYTHON_VERSION: '3.12'
PACKAGE_NAME: 'pyconverter-xml2py'
PACKAGE_NAMESPACE: 'pyconverter.xml2py'
DOCUMENTATION_CNAME: 'pyconverter-xml2py.docs.pyansys.com'
RESET_PIP_CACHE: 10
RESET_AUTOSUMMARY_CACHE: 10
RESET_DOC_BUILD_CACHE: 10
ON_CI: true
permissions:
contents: read
pull-requests: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
code-style:
name: "Code style"
runs-on: ubuntu-latest
steps:
- name: PyAnsys code style checks
uses: ansys/actions/code-style@1096998b81f7ebdea116b683e11f3a8bda759ca6 # v10.0.14
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@1096998b81f7ebdea116b683e11f3a8bda759ca6 # v10.0.14
with:
token: ${{ secrets.GITHUB_TOKEN }}
vulnerabilities:
name: "Check library vulnerabilities"
runs-on: ubuntu-latest
steps:
- name: "Check library vulnerabilities with default mode"
uses: ansys/actions/check-vulnerabilities@1096998b81f7ebdea116b683e11f3a8bda759ca6 # v10.0.14
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
python-package-name: ${{ env.PACKAGE_NAME }}
dev-mode: ${{ github.ref != 'refs/heads/main' }}
actions-security:
name: "Check actions security"
runs-on: ubuntu-latest
needs: [vulnerabilities]
steps:
- uses: ansys/actions/check-actions-security@1096998b81f7ebdea116b683e11f3a8bda759ca6 # v10.0.14
with:
generate-summary: true
token: ${{ secrets.GITHUB_TOKEN }}
auditing-level: 'high'
trust-ansys-actions: true
smoke-tests: # Needs to be re-enabled prior to release
name: Build and Smoke tests (Linux)
runs-on: ubuntu-latest
needs: [code-style]
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
steps:
- name: Build wheelhouse and perform smoke test
uses: ansys/actions/build-wheelhouse@1096998b81f7ebdea116b683e11f3a8bda759ca6 # v10.0.14
with:
library-name: ${{ env.PACKAGE_NAME }}
operating-system: ${{ runner.os }}
python-version: ${{ matrix.python-version }}
smoke-tests-macos-windows:
name: Build and Smoke tests (macOS and Windows)
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
runs-on: ${{ matrix.os }}
needs: [code-style]
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
python-version: ['3.10', '3.11', '3.12', '3.13']
steps:
- name: Build wheelhouse and perform smoke test
uses: ansys/actions/build-wheelhouse@1096998b81f7ebdea116b683e11f3a8bda759ca6 # v10.0.14
with:
library-name: ${{ env.PACKAGE_NAME }}
operating-system: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
build-test:
name: "Build and unit testing"
runs-on: ubuntu-latest
# needs: [smoke-tests]
steps:
- name: "Install Git and checkout project"
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: "Setup Python"
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: "Install os packages"
run: |
sudo apt update
sudo apt-get install pandoc
- name: "Cache pip"
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 # zizmor: ignore[cache-poisoning]
with:
path: ~/.cache/pip
key: Python-v${{ env.RESET_PIP_CACHE }}-${{ runner.os }}-${{ hashFiles('pyproject.toml') }}
restore-keys: |
Python-v${{ env.RESET_PIP_CACHE }}-${{ runner.os }}
# The token will expire in 2025.
- name: "Checkout mapdl-cmd-doc repository"
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: ansys-internal/mapdl-cmd-doc
ref: feat/pyconverter-xml2py-predifined-format
token: ${{ secrets.MAPDL_CMD_DOC_TOKEN }}
path: mapdl-cmd-doc
persist-credentials: false
- name: "Unit testing requirements installation"
run: |
python -m pip install .[tests]
- name: "Unit testing"
run: |
pytest -v --durations=10 --maxfail=10 \
--reruns 7 --reruns-delay 3 --ghdir ${GITHUB_WORKSPACE}\
--cov=pyconverter.xml2py --cov-report=xml:coverage.xml --cov-report=html\
--cov-report term
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
with:
name: coverage.xml
flags: coverage
- name: Upload coverage artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: coverage.xml
path: ./coverage.xml
doc-build:
name: Documentation building
runs-on: ubuntu-latest
needs: [doc-style]
steps:
- name: "Install Git and checkout project"
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: "Setup Python"
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: "Cache pip"
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 # zizmor: ignore[cache-poisoning]
with:
path: ~/.cache/pip
key: Python-pyconverter.xml2py-v${{ env.RESET_PIP_CACHE }}-${{ env.MAIN_PYTHON_VERSION }}-${{ hashFiles('pyproject.toml') }}
restore-keys: |
Python-pyconverter.xml2py-v${{ env.RESET_PIP_CACHE }}-${{ env.MAIN_PYTHON_VERSION }}
- name: "Install pyconverter-xml2py"
run: |
pip install --upgrade pip
pip install .[doc]
- name: "Retrieve pyconverter.xml2py version"
run: |
echo "PYCONVERTER_VERSION=$(python -c 'from pyconverter.xml2py import __version__; print(__version__)')" >> $GITHUB_ENV
echo "pyconverter.xml2py version is: $(python -c 'from pyconverter.xml2py import __version__; print(__version__)')"
- name: "Cache docs build directory"
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 # zizmor: ignore[cache-poisoning]
with:
path: doc/_build
key: doc-build-pyconverter-xml2py-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ env.PYCONVERTER_VERSION }}-${{ github.sha }}
restore-keys: |
doc-build-pyconverter-xml2py-v${{ env.RESET_DOC_BUILD_CACHE }}-${{ env.PYCONVERTER_VERSION }}
- name: "Cache autosummary"
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 # zizmor: ignore[cache-poisoning]
with:
path: doc/source/**/_autosummary/**/*.rst
key: autosummary-pyconverter-xml2py-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ env.PYCONVERTER_VERSION }}-${{ github.sha }}
restore-keys: |
autosummary-pyconverter-xml2py-v${{ env.RESET_AUTOSUMMARY_CACHE }}-${{ env.PYCONVERTER_VERSION }}
- name: "Run Ansys documentation building action"
uses: ansys/actions/doc-build@1096998b81f7ebdea116b683e11f3a8bda759ca6 # v10.0.14
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
checkout: false
skip-install: true
sphinxopts: -j auto
dependencies: "graphviz"
package:
name: Package library
runs-on: ubuntu-latest
needs: [doc-build, build-test]
steps:
- name: Build library source and wheel artifacts
uses: ansys/actions/build-library@1096998b81f7ebdea116b683e11f3a8bda759ca6 # v10.0.14
with:
library-name: ${{ env.PACKAGE_NAME }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
release:
name: "Release project to GitHub"
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
needs: [package]
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
contents: write
steps:
- name: Release to GitHub
uses: ansys/actions/release-github@1096998b81f7ebdea116b683e11f3a8bda759ca6 # v10.0.14
with:
token: ${{ secrets.GITHUB_TOKEN }}
library-name: ${{ env.PACKAGE_NAME }}
add-artifact-attestation-notes: true
release-pypi:
name: "Release project to PyPI"
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags') }}
needs: [package]
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
contents: write
steps:
- name: "Download the library artifacts from build-library step"
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: ${{ env.PACKAGE_NAME }}-artifacts
path: ${{ env.PACKAGE_NAME }}-artifacts
- name: "Upload artifacts to PyPI using trusted publisher"
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
repository-url: "https://upload.pypi.org/legacy/"
print-hash: true
packages-dir: ${{ env.PACKAGE_NAME }}-artifacts
skip-existing: false
doc-deploy-stable:
name: "Deploy stable documentation"
# Deploy release documentation when creating a new tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
runs-on: ubuntu-latest
permissions:
contents: write
needs: [release, release-pypi]
steps:
- name: "Deploy the stable documentation"
uses: ansys/actions/doc-deploy-stable@1096998b81f7ebdea116b683e11f3a8bda759ca6 # v10.0.14
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}
doc-deploy-dev:
name: "Deploy development documentation"
# Deploy development only when merging to main
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
needs: [package]
steps:
- name: "Deploy the latest documentation"
uses: ansys/actions/doc-deploy-dev@1096998b81f7ebdea116b683e11f3a8bda759ca6 # v10.0.14
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}