Skip to content

Commit

Permalink
Merge pull request #208 from treyhunner/fix-everything
Browse files Browse the repository at this point in the history
Remove so much junk
  • Loading branch information
treyhunner authored May 10, 2024
2 parents 8a3243a + e416f97 commit 179d3d7
Show file tree
Hide file tree
Showing 13 changed files with 367 additions and 1,300 deletions.
18 changes: 0 additions & 18 deletions .github/dependabot.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .github/workflows/constraints.txt

This file was deleted.

149 changes: 61 additions & 88 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,135 +5,93 @@ on:
- pull_request

jobs:
build-package:
name: Build & verify package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: hynek/build-and-inspect-python-package@v2
id: baipp

outputs:
python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }}

tests:
name: ${{ matrix.session }} ${{ matrix.python }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
name: Tests on ${{ matrix.python-version }}
needs: build-package
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- { python: "3.10", os: "ubuntu-latest", session: "pre-commit" }
- { python: "3.10", os: "ubuntu-latest", session: "safety" }
- { python: "3.10", os: "ubuntu-latest", session: "mypy" }
- { python: "3.9", os: "ubuntu-latest", session: "mypy" }
- { python: "3.8", os: "ubuntu-latest", session: "mypy" }
- { python: "3.10", os: "ubuntu-latest", session: "tests" }
- { python: "3.9", os: "ubuntu-latest", session: "tests" }
- { python: "3.8", os: "ubuntu-latest", session: "tests" }
- { python: "3.10", os: "windows-latest", session: "tests" }
- { python: "3.10", os: "macos-latest", session: "tests" }
- { python: "3.10", os: "ubuntu-latest", session: "typeguard" }
- { python: "3.10", os: "ubuntu-latest", session: "xdoctest" }
- { python: "3.10", os: "ubuntu-latest", session: "docs-build" }

env:
NOXSESSION: ${{ matrix.session }}
FORCE_COLOR: "1"
PRE_COMMIT_COLOR: "always"
python-version: ${{ fromJson(needs.build-package.outputs.python-versions) }}

steps:
- name: Check out the repository
uses: actions/[email protected]

- name: Set up Python ${{ matrix.python }}
uses: actions/[email protected]
- uses: actions/checkout@v4
- name: Download pre-built packages
uses: actions/download-artifact@v4
with:
python-version: ${{ matrix.python }}

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Upgrade pip in virtual environments
shell: python
run: |
import os
import pip
with open(os.environ["GITHUB_ENV"], mode="a") as io:
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
name: Packages
path: dist
- run: tar xf dist/*.tar.gz --strip-components=1
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: pip

- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
pipx install poetry
poetry --version
- name: Install Nox
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
- name: Compute pre-commit cache key
if: matrix.session == 'pre-commit'
id: pre-commit-cache
shell: python
run: |
import hashlib
import sys
python = "py{}.{}".format(*sys.version_info[:2])
payload = sys.version.encode() + sys.executable.encode()
digest = hashlib.sha256(payload).hexdigest()
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8])
pipx install nox
pipx inject nox nox-poetry
print("::set-output name=result::{}".format(result))
- name: Restore pre-commit cache
uses: actions/[email protected]
if: matrix.session == 'pre-commit'
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
path: ~/.cache/pre-commit
key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ steps.pre-commit-cache.outputs.result }}-
name: coverage-data-${{ matrix.python-version }}
path: .coverage.*
if-no-files-found: ignore

- name: Run Nox
run: |
nox --force-color --python=${{ matrix.python }}
nox --force-color --python=${{ matrix.python-version }}
- name: Upload coverage data
if: always() && matrix.session == 'tests'
uses: "actions/[email protected]"
with:
name: coverage-data
path: ".coverage.*"

- name: Upload documentation
if: matrix.session == 'docs-build'
uses: actions/[email protected]
with:
name: docs
path: docs/_build

coverage:
runs-on: ubuntu-latest
needs: tests
steps:
- name: Check out the repository
uses: actions/checkout@v3.3.0
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4.5.0
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
python-version-file: .python-version-default
cache: pip

- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
pipx install poetry
poetry --version
- name: Install Nox
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
pipx install nox
pipx inject nox nox-poetry
- name: Download coverage data
uses: actions/[email protected]
Expand All @@ -150,3 +108,18 @@ jobs:
- name: Upload coverage report
uses: codecov/[email protected]

required-checks-pass:
name: Ensure everything required is passing for branch protection
if: always()

needs:
- coverage

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) }}
13 changes: 0 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@ repos:
language: system
types: [python]
require_serial: true
- id: pyupgrade
name: pyupgrade
description: Automatically upgrade syntax for newer versions.
entry: pyupgrade
language: system
types: [python]
args: [--py37-plus]
- id: reorder-python-imports
name: Reorder python imports
entry: reorder-python-imports
language: system
types: [python]
args: [--application-directories=src]
- id: trailing-whitespace
name: Trim Trailing Whitespace
entry: trailing-whitespace-fixer
Expand Down
1 change: 1 addition & 0 deletions .python-version-default
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sphinx configuration."""

from datetime import datetime


Expand Down
Loading

0 comments on commit 179d3d7

Please sign in to comment.