attrs/.github/workflows/ci.yml

178 lines
4.2 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"
2023-07-28 15:40:56 +00:00
permissions: {}
2022-09-29 09:00:18 +00:00
jobs:
tests:
2023-06-14 14:52:17 +00:00
name: Tests & Mypy 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"
# - "pypy-3.7"
2022-08-21 07:42:03 +00:00
- "pypy-3.8"
- "pypy-3.9"
2023-07-09 09:42:35 +00:00
- "pypy-3.10"
steps:
- uses: actions/checkout@v4
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-06-12 05:48:55 +00:00
cache: pip
2023-08-17 07:33:55 +00:00
- name: Prepare tox
run: |
V=${{ matrix.python-version }}
if [[ "$V" = pypy-* ]]; then
V=pypy3
2023-08-17 07:33:55 +00:00
IS_PYPY=1
else
V=py$(echo $V | tr -d .)
2023-08-17 07:33:55 +00:00
IS_PYPY=0
fi
2023-08-17 07:33:55 +00:00
echo IS_PYPY=$IS_PYPY >>$GITHUB_ENV
echo TOX_PYTHON=$V >>$GITHUB_ENV
python -Im pip install tox
2023-08-17 07:33:55 +00:00
- run: python -Im tox run -e ${{ env.TOX_PYTHON }}-tests
- run: python -Im tox run -e ${{ env.TOX_PYTHON }}-mypy
if: env.IS_PYPY == '0'
- 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:
2023-06-14 15:11:06 +00:00
name: Combine & check coverage.
2021-12-27 16:47:14 +00:00
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v4
2022-08-15 07:21:23 +00:00
- uses: actions/setup-python@v4
2023-06-12 05:48:55 +00:00
with:
python-version-file: .python-version-default
2023-06-12 05:48:55 +00:00
cache: pip
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
2023-06-14 15:11:06 +00:00
- name: Combine coverage & fail if it's <100%.
2021-12-05 05:15:08 +00:00
run: |
2023-06-14 15:11:06 +00:00
python -Im pip install coverage[toml]
2023-06-14 14:52:17 +00:00
python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty
2023-06-14 15:11:06 +00:00
# Report and write to summary.
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
2023-06-14 15:11:06 +00:00
# Report again and fail if under 100%.
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@v4
2022-09-28 07:46:17 +00:00
- 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"
2023-06-12 05:48:55 +00:00
cache: pip
2022-09-28 07:46:17 +00:00
2023-08-17 07:33:55 +00:00
- run: python -Im pip install tox
- run: python -Im tox run -e docs,changelog
2022-09-28 07:46:17 +00:00
pyright:
name: Check types using pyright
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
2023-06-12 05:48:55 +00:00
with:
python-version-file: .python-version-default
2023-06-12 05:48:55 +00:00
cache: pip
2023-08-17 07:33:55 +00:00
- run: python -Im pip install 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:
- uses: actions/checkout@v4
2022-08-15 07:21:23 +00:00
- uses: actions/setup-python@v4
2023-06-12 05:48:55 +00:00
with:
python-version-file: .python-version-default
2023-06-12 05:48:55 +00:00
cache: pip
2023-06-14 14:52:17 +00:00
- name: Install in dev mode & import
run: |
python -Im pip install -e .[dev]
python -Ic 'import attr; print(attr.__version__)'
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
- 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) }}