fixed test #351
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
task: | |
type: choice | |
options: [tests, release] | |
default: tests | |
description: Only run tests or release a new version to PyPI after tests pass. | |
jobs: | |
tests: | |
strategy: | |
fail-fast: true | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
cache: pip | |
cache-dependency-path: pyproject.toml | |
- name: Install dependencies | |
run: | | |
pip install cython | |
python setup.py build_ext --inplace | |
pip install -e .[test] | |
- name: Run Tests | |
run: pytest --capture=no --cov --cov-report=xml . | |
- name: Codacy coverage reporter | |
if: matrix.os == 'ubuntu-latest' && github.repository == github.event.pull_request.head.repo.full_name | |
uses: codacy/codacy-coverage-reporter-action@v1 | |
with: | |
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
coverage-reports: coverage.xml | |
build_source_dist: | |
needs: tests | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.task == 'release') | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
name: Install Python | |
with: | |
python-version: "3.10" | |
- name: Build source distribution | |
run: | | |
pip install build | |
python -m build --sdist | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: dist/*.tar.gz | |
build_wheels: | |
name: Build wheels for ${{ matrix.os }} | |
needs: tests | |
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.task == 'release') | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: ["39", "310", "311"] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_BUILD: cp${{ matrix.python-version }}-* | |
- name: Save artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
path: wheelhouse | |
release: | |
needs: [build_wheels, build_source_dist] | |
runs-on: ubuntu-latest | |
permissions: | |
# For pypi trusted publishing | |
id-token: write | |
steps: | |
- name: Download build artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifact | |
path: dist | |
- name: Publish to PyPi | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
skip-existing: true | |
verbose: true |