Skip to content

Acohen/build

Acohen/build #52

Workflow file for this run

name: GitHub CI
# 'on' controls when this script is run.
on:
pull_request: # This means every time a PR is made, the script runs.
workflow_dispatch: # This means when looking at the repo, you can click 'actions' then 'GitHub CI', and select 'Run Workflow' on any targets branch .
push: # This means after a push (to main branch) This script also runs, just to be sure everything is fine.
tags:
- "*"
branches:
- main
# Environment Variables
env:
MAIN_PYTHON_VERSION: '3.10' # We need 3.9 for building sphinx
LIBRARY_NAME: 'ansys-turbogrid-client' # The repo name
LIBRARY_NAMESPACE: 'ansys.turbogrid.client'
DOCUMENTATION_CNAME: 'turbogrid.docs.pyansys.com'
PIP_EXTRA_INDEX_URL: 'https://${{ secrets.PYANSYS_PYPI_PRIVATE_PAT }}@pkgs.dev.azure.com/pyansys/_packaging/pyansys/pypi/simple/'
# This deals with concurrent runs of this script.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true # This means multiple runs of the same script on the same branch will cancel the oldest ones.
# Under here we have the scheduler graph of all the jobs, each being a vertex, directed by the 'needs:' fields (needs describes a child node).
jobs:
# The style job will fail if any changes are needed by any styler.
# The best way to avoid these failures is to install the styler on your vscode, with format-on-save.
# There are numerous internet tutorials to follow for all the installation and settings configurations.
code-style:
name: "Code Style Checks"
runs-on: ubuntu-latest
steps:
- name: "PyAnsys code style checks"
uses: pyansys/actions/code-style@v4 # This action looks in .pre-commit-config.yaml for code check tasks.
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
doc-style:
name: "Documentation Style Checks"
runs-on: ubuntu-latest
steps:
- name: PyAnsys documentation style checks
uses: pyansys/actions/doc-style@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
doc-build:
# Documentation is built in the environment of this script run,
# it is uploaded as a build artifact, then sent to the doc website.
name: "Documentation"
needs: [doc-style]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3 # This checks out the repo, with the base directory being the base repo directory.
- name: "Set up Python"
uses: actions/setup-python@v4
with:
python-version: '3.10' # 3.9 is required for Sphinx
# Using the newest version of pip, install all the dependencies.
# The syntax .[NAME] refers to the project.optional-dependencies in pyproject.toml
# python -m pip install ansys-turbogrid-api --index-url https://${{ secrets.PYANSYS_PYPI_PRIVATE_PAT }}@pkgs.dev.azure.com/pyansys/_packaging/pyansys/pypi/simple/ --no-dependencies
- name: "Install packages for documentation build"
run: |
python -m venv ./.venv
source ./.venv/bin/activate
python -m pip install -U pip
python -m pip install .
python -m pip install .[doc]
- name: Build the documentation (HTML)
run: |
source ./.venv/bin/activate
cd doc
make html
# Upload the doc/build/html folder as a build artifact.
# You can see the artifact on the action page, if the run succeeded.
- name: "Upload HTML documentation"
uses: actions/upload-artifact@v3
with:
name: "documentation-html"
path: doc/_build/html
retention-days: 7
# Currently, we update the doc on every script run.
# TODO: we need a better system for controlling when documentation is updated.
- name: "Deploy dev doc"
uses: pyansys/actions/doc-deploy-dev@v3
with:
doc-artifact-name: 'documentation-html'
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
# # Stable doc, which is versioned, but I don't know how yet.
# - name: "Deploy release doc"
# uses: pyansys/actions/doc-deploy-stable@v3
# with:
# doc-artifact-name: 'documentation-html'
# cname: ${{ env.DOCUMENTATION_CNAME }}
# token: ${{ secrets.GITHUB_TOKEN }}
# python-version: ${{ env.MAIN_PYTHON_VERSION }}
# The build job is responsible for creating the build artifact and uploading it to PYPI using twine.
build:
name: Build
needs: [code-style]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
# python -m pip install ansys-turbogrid-api --index-url https://${{ secrets.PYANSYS_PYPI_PRIVATE_PAT }}@pkgs.dev.azure.com/pyansys/_packaging/pyansys/pypi/simple/ --no-dependencies
- name: Pull PyTurboGrid API Package
run: |
python -m pip install ansys-turbogrid-api
- name: "Build library source and wheel artifacts"
uses: pyansys/actions/build-library@v4
with:
library-name: ${{ env.LIBRARY_NAME }}
- name: "Build a wheelhouse of the Python library"
uses: pyansys/actions/build-wheelhouse@v4
with:
library-name: ${{ env.LIBRARY_NAME }}
library-namespace: ${{ env.LIBRARY_NAMESPACE }}
operating-system: windows-latest
python-version: '3.10'
- name: "Release to the private PyPI repository"
uses: pyansys/actions/release-pypi-private@v1
with:
library-name: ${{ env.LIBRARY_NAME }}
twine-username: "__token__"
twine-token: ${{ secrets.PYANSYS_PYPI_PRIVATE_PAT }}
# - name: Build package
# run: |
# python -m pip install build
# python -m build
# - name: Check package
# run: |
# pip install twine
# twine check dist/*
# - name: "Upload wheel and binaries"
# uses: actions/upload-artifact@v3
# with:
# name: ${{ env.LIBRARY_NAME }}-artifacts
# path: dist/
# retention-days: 7