Skip to content

Merge pull request #413 from richardsheridan/try-setup-cached-uv #1520

Merge pull request #413 from richardsheridan/try-setup-cached-uv

Merge pull request #413 from richardsheridan/try-setup-cached-uv #1520

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]
jobs:
Merge-Dependabot:
if: github.event_name == 'pull_request'
timeout-minutes: 1
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- uses: fastify/github-action-merge-dependabot@v3.10.1
with:
merge-method: merge
use-github-auto-merge: true
Verify:
name: 'Verify requirement pinning'
timeout-minutes: 2
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@v4.1.2
- name: Setup python
uses: actions/setup-python@v5.1.0
with:
python-version: "3.12"
- name: Install requirements
run: |
python -m pip install -U pip
# Optimistically assume SHA checks won't change much
python -m pip install pip-compile-multi
- name: Verify requirements
run: pip-compile-multi verify
Blacken:
name: 'Formatting and linting'
timeout-minutes: 2
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@v4.1.2
- name: Setup python
uses: actions/setup-python@v5.1.0
with:
cache: pip
cache-dependency-path: requirements/lint.txt
python-version: "3.12"
- name: Install requirements
run: |
python -m pip install -U pip
python -m pip install -r requirements/lint.txt
- name: Run Black
id: black
run: black --check --diff trio_parallel _trio_parallel_workers
continue-on-error: true
- name: Run flake8
id: flake8
run: |
flake8 --extend-ignore=D,E,W,F401,F403,F405,F821,F822,ASYNC114 \
--extend-select=ASYNC900,ASYNC910,ASYNC911
continue-on-error: true
- name: Fail on error
if: steps.black.outcome != 'success' || steps.flake8.outcome != 'success'
run: exit 1
Build:
name: Build
timeout-minutes: 5
runs-on: ubuntu-latest
outputs:
python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }}
settings: ${{ steps.outputs.outputs.settings }}
steps:
- name: Checkout
uses: actions/checkout@v4.1.2
with:
fetch-depth: 0
- name: Build inspect and upload
id: baipp
uses: hynek/build-and-inspect-python-package@v2.2.1
- name: Set outputs
id: outputs
run: |
echo "settings=$(
tar cz \
pyproject.toml \
requirements/install.txt \
requirements/test.txt \
| base64 -w 0
)" >> $GITHUB_OUTPUT
cd ${{ steps.baipp.outputs.dist }} && sha256sum *.* >> $GITHUB_STEP_SUMMARY
Test:
name: 'Test ${{ matrix.os }} (${{ matrix.python }})'
needs: Build
timeout-minutes: 10
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
experimental: [ false ]
test-timeout: [ 10 ]
os:
- windows-latest
- ubuntu-latest
- macos-latest
python: ${{ fromJson(needs.Build.outputs.python-versions) }}
include:
# pypy/linux is comparable to cpy/win
- os: ubuntu-latest
python: 'pypy-3.10'
experimental: false
test-timeout: 10
# - os: ubuntu-latest
# python: '3.13-dev'
# experimental: true
# test-timeout: 3
exclude:
- os: macos-latest
python: '3.8'
steps:
- name: Input settings
run: echo "${{ needs.Build.outputs.settings }}" | base64 -d | tar xz
shell: bash
- name: Setup python
uses: actions/setup-python@v5.1.0
with:
python-version: '${{ matrix.python }}'
- name: Setup and Cache UV
uses: hynek/setup-cached-uv@747c045009c1fc51b8d77af224dffc47acaf5993
with:
cache-suffix: '-${{ matrix.python }}'
cache-dependency-path: '**/requirements/test.txt'
- name: Download build artifact
uses: actions/download-artifact@v4.1.2
with:
name: Packages
path: dist
- name: Install requirements
run: |
uv pip install --system -r requirements/test.txt
- name: Install wheel
shell: bash
run: |
uv pip install --system `echo ./dist/*.whl` --no-deps
- name: Run tests
timeout-minutes: ${{ matrix.test-timeout }}
run: |
pytest trio_parallel --cov-report xml:coverage-${{ matrix.os }}-${{ matrix.python }}.xml
coverage report
mv .coverage .coverage.${{ matrix.os }}-${{ matrix.python }}
shell: bash
- name: Upload coverage
if: always()
uses: actions/upload-artifact@v4.3.1
with:
name: Coverage-${{ matrix.os }}-${{ matrix.python }}
path: "*coverage*${{ matrix.os }}-${{ matrix.python }}*"
if-no-files-found: error
Examples:
name: 'Test examples ${{ matrix.os }} (${{ matrix.python }})'
timeout-minutes: 10
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-latest
- ubuntu-latest
- macos-latest
python:
- '3.12'
- 'pypy-3.10'
steps:
- name: Checkout
uses: actions/checkout@v4.1.2
- name: Setup python
uses: actions/setup-python@v5.1.0
with:
cache: pip
cache-dependency-path: requirements/test.txt
python-version: '${{ matrix.python }}'
- name: Install requirements
run: |
python -m pip install -U pip
python -m pip install -r requirements/test.txt
- name: Install editable source
run: |
python -m pip install -e . --no-deps
- name: Run tests
run: |
python -m pytest --no-cov docs/source
Extras:
name: 'Test [test] extra'
timeout-minutes: 5
runs-on: ubuntu-latest
needs: Build
steps:
- name: Setup python
uses: actions/setup-python@v5.1.0
with:
python-version: '3.12'
- name: Download build artifact
uses: actions/download-artifact@v4.1.2
with:
name: Packages
path: dist
- name: Run tests
shell: bash
run: |
wheel=`echo ./dist/*.whl`
python -m pip install $wheel[test]
pytest --pyargs trio_parallel
Coverage:
name: Coverage
if: always()
needs: Test
timeout-minutes: 1
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.2
- name: Download coverage artifact
uses: actions/download-artifact@v4.1.2
with:
pattern: Coverage-*
merge-multiple: true
- name: Setup python
uses: actions/setup-python@v5.1.0
with:
cache: pip
cache-dependency-path: requirements/coverage.txt
python-version: "3.12"
- name: Install coverage
run: |
pip install -U pip
pip install -r requirements/coverage.txt
- name: Run coverage
run: |
coverage combine
coverage html
coverage report --fail-under=100 --show-missing --format markdown \
>> $GITHUB_STEP_SUMMARY
- name: Upload report
if: always()
uses: actions/upload-artifact@v4.3.1
with:
name: Report
path: htmlcov/
if-no-files-found: error
All:
name: All checks and tests
if: always()
timeout-minutes: 1
needs: [ Verify, Blacken, Build, Examples, Test, Extras, Coverage ]
runs-on: ubuntu-latest
steps:
- name: Check all needs have passed
uses: re-actors/alls-green@v1.2.2
with:
jobs: ${{ toJSON(needs) }}
Release:
name: Release on PyPI
if: github.event_name == 'release'
needs: All
timeout-minutes: 1
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/trio-parallel
permissions:
id-token: write
steps:
- name: Download build artifact
uses: actions/download-artifact@v4.1.2
with:
name: Packages
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Update:
name: Update GitHub Release
if: github.event_name == 'release'
needs: All
timeout-minutes: 1
runs-on: ubuntu-latest
# permissions:
# contents: write #TODO this should be default but maybe must be set
steps:
- name: Download build artifact
uses: actions/download-artifact@v4.1.2
with:
name: Packages
path: dist
- name: Upload to GitHub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.ref_name }} dist/* --repo ${{ github.repository }}