Add type hints (finally) #410
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
# Allow rebuilds via API. | |
repository_dispatch: | |
types: [rebuild] | |
env: | |
FORCE_COLOR: "1" | |
PYTHON_LATEST: "3.11" | |
jobs: | |
pre-commit: | |
name: "Pre-commit" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
- name: Locally install interrogate | |
run: python -m pip install . | |
- name: Run pre-commit | |
uses: pre-commit/[email protected] | |
tests: | |
name: "Python ${{ matrix.python-version }} on Ubuntu" | |
runs-on: "ubuntu-latest" | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["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 | |
cache: pip | |
- name: "Install dependencies" | |
run: | | |
python -VV | |
python -Im site | |
python -Im pip install --upgrade tox | |
- name: Run tox targets for ${{ matrix.python-version }} | |
run: python -Im tox run -f py$(echo ${{ matrix.python-version }} | tr -d .) | |
- name: Run mypy | |
run: python -Im tox run -e mypy | |
if: matrix.python-version == '3.11' | |
- name: Run mypy | |
run: python -Im tox run -e mypy | |
if: matrix.python-version == '3.11' | |
- name: Check MANIFEST.in | |
run: python -Im tox run -e manifest | |
if: matrix.python-version == '3.11' | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-data | |
path: ".coverage.*" | |
if-no-files-found: ignore | |
coverage: | |
runs-on: ubuntu-latest | |
needs: tests | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
# Use latest Python, so it understands all syntax. | |
python-version: ${{env.PYTHON_LATEST}} | |
cache: pip | |
- run: python -Im pip install --upgrade coverage[toml] | |
- name: Download coverage data | |
uses: actions/download-artifact@v3 | |
with: | |
name: coverage-data | |
- name: "Combine coverage and fail if it's <98%." | |
run: | | |
python -Im coverage combine | |
python -Im coverage html --skip-covered --skip-empty | |
# Report and write to summary. | |
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY | |
# Report again and fail if under 98%. | |
python -Im coverage report --fail-under=98 | |
- name: Upload HTML report if check failed. | |
uses: actions/upload-artifact@v3 | |
with: | |
name: html-report | |
path: htmlcov | |
if: ${{ failure() }} | |
build-package: | |
name: Build & verify package | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: hynek/build-and-inspect-python-package@v1 | |
install-dev: | |
name: "Verify Dev Env on ${{ matrix.os }}" | |
strategy: | |
matrix: | |
os: ["ubuntu-latest", "windows-latest", "macos-latest"] | |
runs-on: "${{ matrix.os }}" | |
steps: | |
- uses: "actions/checkout@v3" | |
- uses: "actions/setup-python@v4" | |
with: | |
python-version: ${{env.PYTHON_LATEST}} | |
- name: "Install in dev mode" | |
run: "python -Im pip install -e .[dev]" | |
- name: "Import package" | |
run: "python -Ic 'import interrogate; print(interrogate.__version__)'" | |
- name: "Create a badge" | |
run: interrogate --config pyproject.toml --generate-badge . src tests | |
if: runner.os != 'Windows' | |
env: | |
# TODO: set for only macos | |
DYLD_FALLBACK_LIBRARY_PATH: "/opt/homebrew/lib" | |
docs: | |
name: Check docs | |
runs-on: ubuntu-latest | |
steps: | |
- uses: "actions/checkout@v3" | |
- uses: actions/setup-python@v4 | |
with: | |
# Keep in sync with tox.ini/docs & .readthedocs.yaml | |
python-version: "3.11" | |
cache: pip | |
- run: python -Im pip install tox | |
- run: python -Im tox run -e docs | |
# Ensure everything required is passing for branch protection. | |
required-checks-pass: | |
if: always() | |
needs: | |
- pre-commit | |
- build-package | |
- coverage | |
- install-dev | |
- docs | |
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) }} |