Skip to content

maint: Tech review

maint: Tech review #37

Workflow file for this run

name: CI/CD
on:
pull_request:
push:
tags:
- "*"
branches:
- main
env:
MAIN_PYTHON_VERSION: '3.12'
DOCUMENTATION_CNAME: allie-flowkit-python.docs.pyansys.com
PACKAGE_NAME: allie-flowkit-python
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
packages: write
jobs:
code-style:
name: "Code style checks"
runs-on: ubuntu-latest
steps:
- name: "Run PyAnsys code style checks"
uses: ansys/actions/code-style@v6
smoke-tests:
name: Build and Smoke tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.10', '3.11', '3.12']
should-release:
- ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags') }}
exclude:
- should-release: false
os: macos-latest
steps:
- name: Build wheelhouse and perform smoke test
uses: ansys/actions/build-wheelhouse@v6
with:
library-name: ${{ env.PACKAGE_NAME }}
operating-system: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
docs-style:
name: Documentation Style Check
runs-on: ubuntu-latest
steps:
- name: PyAnsys documentation style checks
uses: ansys/actions/doc-style@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
docs-build:
name: Documentation Build
runs-on: ubuntu-latest
needs: [docs-style]
steps:
- name: Setup headless display
uses: pyvista/setup-headless-display-action@v2
- name: "Run Ansys documentation building action"
uses: ansys/actions/doc-build@v6
with:
add-pdf-html-docs-as-assets: true
package:
name: Package library
needs: [docs-build, smoke-tests]
runs-on: ubuntu-latest
steps:
- name: Build library source and wheel artifacts
uses: ansys/actions/build-library@v6
with:
library-name: ${{ env.PACKAGE_NAME }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
upload_dev_docs:
name: Upload dev documentation
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [package]
steps:
- name: Deploy the latest documentation
uses: ansys/actions/doc-deploy-dev@v6
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
tests:
name: "Tests"
runs-on: ${{ matrix.os }}
needs: [code-style]
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.9', '3.12']
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Testing
uses: ansys/actions/tests-pytest@v6
timeout-minutes: 12
with:
checkout: false
skip-install: true
pytest-extra-args: "--cov=ansys.allie.flowkit.python --cov-report=term --cov-report=html:.cov/html --cov-report=xml:.cov/coverage.xml"
- name: Upload coverage results (HTML)
uses: actions/upload-artifact@v4
if: (matrix.python-version == env.MAIN_PYTHON_VERSION) && (runner.os == 'Linux')
with:
name: coverage-html
path: .cov/html
retention-days: 7
release:
name: "Release project"
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
needs: [code-style]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Release to GitHub
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
upload_docs_release:
name: Upload release documentation
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Deploy the stable documentation
uses: ansys/actions/doc-deploy-stable@v6
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
release-docker:
name : Generate Docker release
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check if tag name contains 'dev'
run: echo "IS_DEV_TAG=$(echo ${{ github.ref_name }} | grep -q 'dev' && echo 'true' || echo 'false')" >> $GITHUB_ENV
- name: Decompose tag into components
if: env.IS_DEV_TAG == 'false'
run: |
if [[ ${{ github.ref_name }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# Split the tag into its components
IFS='.' read -ra PARTS <<< "${{ github.ref_name }}"
echo "X=${PARTS[0]}" >> $GITHUB_ENV
echo "Y=${PARTS[1]}" >> $GITHUB_ENV
echo "Z=${PARTS[2]}" >> $GITHUB_ENV
else
echo "Invalid tag format. Expected vX.Y.Z but got ${{ github.ref_name }}"
exit 1
fi
- name: Build and push Docker image
uses: docker/build-push-action@v6
if: env.IS_DEV_TAG == 'false'
with:
context: .
file: docker/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ github.repository }}:${{ env.X }} ,
ghcr.io/${{ github.repository }}:${{ env.X }}.${{ env.Y }} ,
ghcr.io/${{ github.repository }}:${{ env.X }}.${{ env.Y }}.${{ env.Z }} ,
ghcr.io/${{ github.repository }}:latest
- name: Build and push Docker image dev
if: env.IS_DEV_TAG == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
main-repo-release:
name: Update main allie repo and create release
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
needs: [release-docker, release]
runs-on: ubuntu-latest
steps:
- name: Checkout allie repository
run: |
git clone --branch main https://${{ secrets.ALLIE_RELEASE_TOKEN }}@github.com/ansys-internal/allie.git
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'allie/scripts/releasehelper/go.mod'
- name: Run tag script
run: |
cd allie/scripts/releasehelper
go run main.go "tag" ${{ github.ref_name }} ${{ secrets.ALLIE_RELEASE_TOKEN }}
- name: Commit and push to allie
run: |
cd allie
git config --global user.email '${{ github.actor }}@users.noreply.github.com'
git config --global user.name '${{ github.actor }}'
git commit -a -m 'New release triggered by ${{ github.event.repository.name }}'
git push origin main
- name: Run release script
run: |
cd allie/scripts/releasehelper
go run main.go "release" ${{ github.ref_name }} ${{ secrets.ALLIE_RELEASE_TOKEN }}