2020-03-13 10:07:31 +00:00
|
|
|
---
|
|
|
|
name: CI
|
|
|
|
|
|
|
|
on:
|
2023-10-27 08:58:51 +00:00
|
|
|
merge_group:
|
2020-03-13 10:07:31 +00:00
|
|
|
push:
|
2022-08-18 08:36:49 +00:00
|
|
|
branches: [main]
|
2022-02-02 07:59:16 +00:00
|
|
|
tags: ["*"]
|
2020-03-13 10:07:31 +00:00
|
|
|
pull_request:
|
2020-07-20 08:10:55 +00:00
|
|
|
workflow_dispatch:
|
2020-03-13 10:07:31 +00:00
|
|
|
|
2021-11-19 13:51:46 +00:00
|
|
|
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"
|
2023-04-10 09:41:10 +00:00
|
|
|
# Use oldest version used in doctests / examples.
|
|
|
|
SETUPTOOLS_SCM_PRETEND_VERSION: "19.2.0"
|
2021-11-19 13:51:46 +00:00
|
|
|
|
2023-07-28 15:40:56 +00:00
|
|
|
permissions: {}
|
2022-09-29 09:00:18 +00:00
|
|
|
|
2020-03-13 10:07:31 +00:00
|
|
|
jobs:
|
|
|
|
tests:
|
2023-06-14 14:52:17 +00:00
|
|
|
name: Tests & Mypy on ${{ matrix.python-version }}
|
2023-01-11 15:50:27 +00:00
|
|
|
runs-on: ubuntu-latest
|
2020-03-13 10:07:31 +00:00
|
|
|
|
|
|
|
strategy:
|
2021-03-22 07:04:17 +00:00
|
|
|
fail-fast: false
|
2020-03-13 10:07:31 +00:00
|
|
|
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"
|
2022-11-08 07:41:42 +00:00
|
|
|
- "3.11"
|
2023-06-04 05:33:48 +00:00
|
|
|
- "3.12"
|
2023-06-29 10:23:03 +00:00
|
|
|
# - "pypy-3.7"
|
2022-08-21 07:42:03 +00:00
|
|
|
- "pypy-3.8"
|
2023-06-04 05:33:48 +00:00
|
|
|
- "pypy-3.9"
|
2023-07-09 09:42:35 +00:00
|
|
|
- "pypy-3.10"
|
2020-03-13 10:07:31 +00:00
|
|
|
|
|
|
|
steps:
|
2023-10-01 05:45:12 +00:00
|
|
|
- uses: actions/checkout@v4
|
2024-01-01 13:54:46 +00:00
|
|
|
- uses: actions/setup-python@v5
|
2020-03-13 10:07:31 +00:00
|
|
|
with:
|
2021-12-27 16:47:14 +00:00
|
|
|
python-version: ${{ matrix.python-version }}
|
2023-06-04 05:33:48 +00:00
|
|
|
allow-prereleases: true
|
2023-06-12 05:48:55 +00:00
|
|
|
cache: pip
|
2023-06-04 05:33:48 +00:00
|
|
|
|
2023-08-17 07:33:55 +00:00
|
|
|
- name: Prepare tox
|
2020-03-13 10:07:31 +00:00
|
|
|
run: |
|
2023-02-03 08:08:09 +00:00
|
|
|
V=${{ matrix.python-version }}
|
2020-03-13 10:07:31 +00:00
|
|
|
|
2023-02-03 08:08:09 +00:00
|
|
|
if [[ "$V" = pypy-* ]]; then
|
|
|
|
V=pypy3
|
2023-08-17 07:33:55 +00:00
|
|
|
IS_PYPY=1
|
2023-02-03 08:08:09 +00:00
|
|
|
else
|
|
|
|
V=py$(echo $V | tr -d .)
|
2023-08-17 07:33:55 +00:00
|
|
|
IS_PYPY=0
|
2023-02-03 08:08:09 +00:00
|
|
|
fi
|
|
|
|
|
2023-08-17 07:33:55 +00:00
|
|
|
echo IS_PYPY=$IS_PYPY >>$GITHUB_ENV
|
|
|
|
echo TOX_PYTHON=$V >>$GITHUB_ENV
|
|
|
|
|
2023-06-13 07:40:14 +00:00
|
|
|
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
|
2023-10-17 03:48:35 +00:00
|
|
|
if: env.IS_PYPY == '0' && matrix.python-version != '3.7'
|
2020-03-13 10:07:31 +00:00
|
|
|
|
2021-11-19 13:51:46 +00:00
|
|
|
- name: Upload coverage data
|
2024-01-02 15:35:50 +00:00
|
|
|
uses: actions/upload-artifact@v4
|
2020-08-17 14:22:33 +00:00
|
|
|
with:
|
2024-01-02 15:35:50 +00:00
|
|
|
name: coverage-data-${{ matrix.python-version }}
|
2022-08-18 08:36:49 +00:00
|
|
|
path: .coverage.*
|
2021-11-19 13:51:46 +00:00
|
|
|
if-no-files-found: ignore
|
2020-08-17 14:22:33 +00:00
|
|
|
|
2021-11-19 13:51:46 +00:00
|
|
|
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
|
2021-11-19 13:51:46 +00:00
|
|
|
needs: tests
|
|
|
|
|
|
|
|
steps:
|
2023-10-01 05:45:12 +00:00
|
|
|
- uses: actions/checkout@v4
|
2024-01-01 13:54:46 +00:00
|
|
|
- uses: actions/setup-python@v5
|
2023-06-12 05:48:55 +00:00
|
|
|
with:
|
2023-06-13 07:40:14 +00:00
|
|
|
python-version-file: .python-version-default
|
2023-06-12 05:48:55 +00:00
|
|
|
cache: pip
|
2021-11-19 13:51:46 +00:00
|
|
|
|
2021-12-05 05:15:08 +00:00
|
|
|
- name: Download coverage data
|
2024-01-02 15:35:50 +00:00
|
|
|
uses: actions/download-artifact@v4
|
2021-11-19 13:51:46 +00:00
|
|
|
with:
|
2024-01-02 15:35:50 +00:00
|
|
|
pattern: coverage-data-*
|
|
|
|
merge-multiple: true
|
2021-11-19 13:51:46 +00:00
|
|
|
|
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
|
|
|
|
2023-02-03 08:08:09 +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.
|
2023-08-06 19:33:03 +00:00
|
|
|
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
|
2023-06-14 15:11:06 +00:00
|
|
|
|
|
|
|
# Report again and fail if under 100%.
|
2023-02-03 08:08:09 +00:00
|
|
|
python -Im coverage report --fail-under=100
|
2021-11-19 13:51:46 +00:00
|
|
|
|
2021-12-27 16:47:14 +00:00
|
|
|
- name: Upload HTML report if check failed.
|
2024-01-02 15:35:50 +00:00
|
|
|
uses: actions/upload-artifact@v4
|
2020-03-13 10:07:31 +00:00
|
|
|
with:
|
2021-11-19 13:51:46 +00:00
|
|
|
name: html-report
|
|
|
|
path: htmlcov
|
2021-12-05 05:15:08 +00:00
|
|
|
if: ${{ failure() }}
|
2020-03-13 10:07:31 +00:00
|
|
|
|
2022-09-28 07:46:17 +00:00
|
|
|
docs:
|
|
|
|
name: Build docs & run doctests
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-10-01 05:45:12 +00:00
|
|
|
- uses: actions/checkout@v4
|
2024-01-01 13:54:46 +00:00
|
|
|
- uses: actions/setup-python@v5
|
2022-09-28 07:46:17 +00:00
|
|
|
with:
|
2023-01-29 10:37:16 +00:00
|
|
|
# Keep in sync with tox/docs and .readthedocs.yaml.
|
2023-11-28 12:16:17 +00:00
|
|
|
python-version: "3.12"
|
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
|
|
|
|
2022-09-29 07:36:19 +00:00
|
|
|
pyright:
|
|
|
|
name: Check types using pyright
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-10-01 05:45:12 +00:00
|
|
|
- uses: actions/checkout@v4
|
2024-01-01 13:54:46 +00:00
|
|
|
- uses: actions/setup-python@v5
|
2023-06-12 05:48:55 +00:00
|
|
|
with:
|
2023-06-13 07:40:14 +00:00
|
|
|
python-version-file: .python-version-default
|
2023-06-12 05:48:55 +00:00
|
|
|
cache: pip
|
2022-09-29 07:36:19 +00:00
|
|
|
|
2023-08-17 07:33:55 +00:00
|
|
|
- run: python -Im pip install tox
|
|
|
|
- run: python -Im tox run -e pyright
|
2022-09-29 07:36:19 +00:00
|
|
|
|
2020-03-13 10:07:31 +00:00
|
|
|
install-dev:
|
2021-12-27 16:47:14 +00:00
|
|
|
name: Verify dev env
|
|
|
|
runs-on: ${{ matrix.os }}
|
2020-03-13 10:07:31 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-08-18 08:36:49 +00:00
|
|
|
os: [ubuntu-latest, windows-latest]
|
2020-03-13 10:07:31 +00:00
|
|
|
|
|
|
|
steps:
|
2023-10-01 05:45:12 +00:00
|
|
|
- uses: actions/checkout@v4
|
2024-01-01 13:54:46 +00:00
|
|
|
- uses: actions/setup-python@v5
|
2023-06-12 05:48:55 +00:00
|
|
|
with:
|
2023-06-13 07:40:14 +00:00
|
|
|
python-version-file: .python-version-default
|
2023-06-12 05:48:55 +00:00
|
|
|
cache: pip
|
2023-06-04 05:33:48 +00:00
|
|
|
|
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
|
2023-08-17 07:20:45 +00:00
|
|
|
- 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) }}
|