attrs/.github/workflows/ci.yml

183 lines
4.3 KiB
YAML
Raw Normal View History

---
name: CI
on:
push:
branches: [main]
tags: ["*"]
pull_request:
branches: [main]
workflow_dispatch:
env:
2022-08-19 07:22:35 +00:00
FORCE_COLOR: "1" # Make tools pretty.
2022-09-28 07:53:07 +00:00
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_NO_PYTHON_VERSION_WARNING: "1"
# Use oldest version used in doctests / examples.
SETUPTOOLS_SCM_PRETEND_VERSION: "19.2.0"
# N.B. default Python version for setup-python comes from the .python-version
# file at the root of the project.
2022-09-29 09:00:18 +00:00
permissions:
contents: read
jobs:
tests:
2023-02-12 13:30:57 +00:00
name: Tests on ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
2022-08-19 07:22:35 +00:00
python-version:
2022-08-21 07:42:03 +00:00
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
2022-08-21 07:42:03 +00:00
- "pypy-3.7"
- "pypy-3.8"
- "pypy-3.9"
steps:
2022-03-17 13:08:32 +00:00
- uses: actions/checkout@v3
2022-08-15 07:21:23 +00:00
- uses: actions/setup-python@v4
with:
2021-12-27 16:47:14 +00:00
python-version: ${{ matrix.python-version }}
allow-prereleases: true
2023-02-12 13:30:57 +00:00
- run: python -Im pip install --upgrade wheel tox
- name: Determine Python version for tox
run: |
V=${{ matrix.python-version }}
if [[ "$V" = pypy-* ]]; then
V=pypy3
else
V=py$(echo $V | tr -d .)
fi
echo TOX_PYTHON=$V >>$GITHUB_ENV
- run: python -Im tox run -f ${{ env.TOX_PYTHON }}
- name: Upload coverage data
2022-03-17 13:08:32 +00:00
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: .coverage.*
if-no-files-found: ignore
coverage:
2021-12-27 16:47:14 +00:00
runs-on: ubuntu-latest
needs: tests
steps:
2022-03-17 13:08:32 +00:00
- uses: actions/checkout@v3
2022-08-15 07:21:23 +00:00
- uses: actions/setup-python@v4
- run: python -Im pip install --upgrade coverage[toml]
2021-12-05 05:15:08 +00:00
- name: Download coverage data
2022-03-17 13:08:32 +00:00
uses: actions/download-artifact@v3
with:
name: coverage-data
2021-12-27 16:47:14 +00:00
- name: Combine coverage and fail if it's <100%.
2021-12-05 05:15:08 +00:00
run: |
python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty
python -Im coverage report --fail-under=100
2021-12-27 16:47:14 +00:00
- name: Upload HTML report if check failed.
2022-03-17 13:08:32 +00:00
uses: actions/upload-artifact@v3
with:
name: html-report
path: htmlcov
2021-12-05 05:15:08 +00:00
if: ${{ failure() }}
2022-09-28 07:46:17 +00:00
docs:
name: Build docs & run doctests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
2023-01-29 10:37:16 +00:00
# Keep in sync with tox/docs and .readthedocs.yaml.
2023-02-12 13:55:48 +00:00
python-version: "3.11"
2022-09-28 07:46:17 +00:00
- run: python -Im pip install --upgrade wheel tox
- run: python -Im tox -e docs,changelog
mypy:
2023-02-12 13:30:57 +00:00
name: Mypy on ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- run: python -Im pip install --upgrade wheel tox
- run: python -Im tox run -e mypy
2022-09-28 07:46:17 +00:00
pyright:
name: Check types using pyright
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- run: python -Im pip install --upgrade wheel tox
- run: python -Im tox run -e pyright
install-dev:
2021-12-27 16:47:14 +00:00
name: Verify dev env
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
2022-03-17 13:08:32 +00:00
- uses: actions/checkout@v3
2022-08-15 07:21:23 +00:00
- uses: actions/setup-python@v4
- run: python -Im pip install -e .[dev]
- run: python -Ic 'import attr; print(attr.__version__)'
2023-02-12 13:30:57 +00:00
- run: python -Ic 'import attrs; print(attrs.__version__)'
2022-09-26 14:50:45 +00:00
2022-09-29 09:01:58 +00:00
# Ensure everything required is passing for branch protection.
required-checks-pass:
2022-09-26 14:50:45 +00:00
if: always()
needs:
- coverage
2022-09-28 07:46:17 +00:00
- docs
2022-09-26 14:50:45 +00:00
- install-dev
- mypy
# Pyright is currently flaky
# XXX: https://github.com/ekalinin/nodeenv/issues/324
# - pyright
2022-09-26 14:50:45 +00:00
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}