attrs/.github/workflows/ci.yml

138 lines
3.1 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.
2021-12-27 16:47:14 +00:00
TOX_TESTENV_PASSENV: FORCE_COLOR
PYTHON_LATEST: "3.10"
jobs:
tests:
2021-12-27 16:47:14 +00:00
name: tox 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.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11.0-beta - 3.11"
- "pypy-3.7"
- "pypy-3.8"
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 }}
- name: Install dependencies
run: |
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
2021-12-05 05:15:08 +00:00
python -m pip install --upgrade virtualenv tox tox-gh-actions
- run: python -m tox
- 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
with:
2021-12-05 05:15:08 +00:00
# Use latest Python, so it understands all syntax.
python-version: ${{env.PYTHON_LATEST}}
2021-12-27 16:47:14 +00:00
- run: python -m 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 -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m 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:
python-version: "3.10"
- run: tox -e docs
package:
2021-12-27 16:47:14 +00:00
name: Build & verify package
runs-on: ubuntu-latest
steps:
2022-03-17 13:08:32 +00:00
- uses: actions/checkout@v3
2022-08-21 07:42:03 +00:00
- uses: hynek/build-and-inspect-python-package@v1
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
with:
python-version: ${{env.PYTHON_LATEST}}
2021-12-27 16:47:14 +00:00
- run: python -m pip install -e .[dev]
- run: python -c 'import attr; print(attr.__version__)'
2022-09-26 14:50:45 +00:00
2022-09-28 07:46:17 +00:00
check: # This job does nothing and is only used for the branch protection
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
- package
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) }}