attrs/.github/workflows/ci.yml

217 lines
5.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.
2021-12-27 16:47:14 +00:00
TOX_TESTENV_PASSENV: FORCE_COLOR
2022-09-28 07:53:07 +00:00
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_NO_PYTHON_VERSION_WARNING: "1"
PYTHON_LATEST: "3.10"
2022-09-29 09:00:18 +00:00
permissions:
contents: read
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-0"
2022-08-21 07:42:03 +00:00
- "pypy-3.7"
- "pypy-3.8"
steps:
- name: Harden Runner
uses: step-security/harden-runner@v1
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
files.pythonhosted.org:443
github.com:443
objects.githubusercontent.com:443
pypi.org:443
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
2022-09-28 07:53:07 +00:00
python -m pip install --upgrade wheel 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:
- name: Harden Runner
uses: step-security/harden-runner@v1
with:
egress-policy: block
allowed-endpoints: >
files.pythonhosted.org:443
github.com:443
pypi.org:443
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:
- name: Harden Runner
uses: step-security/harden-runner@v1
with:
egress-policy: block
allowed-endpoints: >
docs.python.org:443
files.pythonhosted.org:443
github.com:443
pypi.org:443
2022-09-28 07:46:17 +00:00
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
2022-09-28 07:53:07 +00:00
- run: python -m pip install --upgrade wheel tox
2022-09-29 09:00:18 +00:00
- run: python -m tox -e docs
2022-09-28 07:46:17 +00:00
pyright:
name: Check types using pyright
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@v1
with:
egress-policy: block
allowed-endpoints: >
files.pythonhosted.org:443
github.com:443
nodejs.org:443
pypi.org:443
registry.npmjs.org:443
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{env.PYTHON_LATEST}}
- run: python -m pip install --upgrade wheel tox
2022-09-29 09:00:18 +00:00
- run: python -m tox -e pyright
package:
2021-12-27 16:47:14 +00:00
name: Build & verify package
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@v1
with:
egress-policy: block
allowed-endpoints: >
files.pythonhosted.org:443
github.com:443
pypi.org:443
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:
- name: Harden Runner
uses: step-security/harden-runner@v1
with:
egress-policy: block
allowed-endpoints: >
files.pythonhosted.org:443
github.com:443
pypi.org:443
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
- pyright
2022-09-26 14:50:45 +00:00
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@v1
with:
egress-policy: block
2022-09-26 14:50:45 +00:00
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}