Skip to content

Update test and deploy workflow #2

Update test and deploy workflow

Update test and deploy workflow #2

Workflow file for this run

name: Test and Deploy
# This workflow:
# - runs tests on pull requests
# - runs tests on pushing to main
# - if it's a tag push and the tag starts with v, and if the tests pass,
# deploys to PyPI using Trusted Publishers:
# https://docs.pypi.org/trusted-publishers/
# on: controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main
# branch or for tags starting with v
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
test:
name: ${{ matrix.platform }} py${{ matrix.python-version }}
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', '3.11']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# these libraries enable testing on Qt on linux
- uses: tlambert03/setup-qt-libs@v1
# strategy borrowed from vispy for installing opengl libs on windows
- name: Install Windows OpenGL
if: runner.os == 'Windows'
run: |
git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
powershell gl-ci-helpers/appveyor/install_opengl.ps1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools tox tox-gh-actions
# torch on Linux installs on GPU by default which brings in
# massive CUDA binaries and kill the job on CI
python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
python -m pip install .[testing]
# this runs the platform-specific tests declared in tox.ini
- name: Test with tox
uses: aganders3/headless-gui@v1
with:
run: python -m tox
env:
PLATFORM: ${{ matrix.platform }}
- name: Coverage
uses: codecov/codecov-action@v3
deploy:
needs: [test]
runs-on: ubuntu-latest
if: contains(github.ref, 'tags')
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
- name: Build
run: |
git tag
python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Publish to GitHub
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
name: ${{ env.tag }}
# body: add when we add release notes
draft: false
prerelease: ${{ contains(github.ref, 'rc') }}
files: |
dist/*