Skip to content

Commit

Permalink
use pytest-split in GitHub Action (#224)
Browse files Browse the repository at this point in the history
* use pytest-split in GitHub Action

* fix test_set_template breaking test_get_plotly_font_color_default by modifying global plotly template

* migrate from pytest-release.yml reusable workflow to separate pytest and pypi publish workflows

latter no longer being a reusable workflow so should now work with PyPI trusted publishing (see pypa/gh-action-pypi-publish/issues/166)
  • Loading branch information
janosh authored Oct 7, 2024
1 parent c185585 commit 77df823
Show file tree
Hide file tree
Showing 6 changed files with 851 additions and 35 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish to PyPI

on:
release:
types: [published]

jobs:
tests:
uses: ./.github/workflows/test.yml

release:
runs-on: ubuntu-latest
needs: tests
if: needs.tests.result == 'success'
permissions:
id-token: write
steps:
- name: Check out repo
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Build and upload dist
run: |
pip install build twine
python -m build
twine check dist/* --strict
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@ on:
release:
types: [published]
workflow_dispatch:
workflow_call:

jobs:
tests:
strategy:
matrix:
os: [ubuntu-latest] # windows-latest
uses: janosh/workflows/.github/workflows/pytest-release.yml@main
split: [1, 2, 3, 4]
uses: janosh/workflows/.github/workflows/pytest.yml@main
with:
os: ${{ matrix.os }}
python-version: "3.10"
test-cmd: |
pytest --durations 20 --cov . \
--splits 4 --group ${{ matrix.split }} \
--splitting-algorithm least_duration
find-scripts:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ test = [
"lxml>=4.9",
"pdfCropMargins>=2",
"pytest-cov>=5",
"pytest-split>=0.9",
"pytest>=8",
"weasyprint>=60",
]
Expand Down
Loading

0 comments on commit 77df823

Please sign in to comment.