Skip to content

Commit

Permalink
Maintenance update (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Oct 7, 2023
1 parent 16470d7 commit 2db0300
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 21 deletions.
35 changes: 29 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,34 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pre-commit/action@v3.0.0
with:
fetch-depth: '1'
- name: set PY
shell: bash -el {0}
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- name: Install pre-commit
shell: bash -el {0}
run: pipx install pre-commit
- uses: actions/cache/restore@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
id: cache
- name: Run pre-commit
shell: bash -e {0}
run: |
echo '```console' > $GITHUB_STEP_SUMMARY
# Enable color output for pre-commit and remove it for the summary
pre-commit run --all-files --show-diff-on-failure --color=always | \
tee >(sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[mGK]//g' >> $GITHUB_STEP_SUMMARY) >&1
exit_code=${PIPESTATUS[0]}
echo '```' >> $GITHUB_STEP_SUMMARY
exit $exit_code
- if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
unit_test_suite:
name: Unit tests on ${{ matrix.os }} with Python ${{ matrix.python-version }}
needs: [pre-commit]
Expand All @@ -21,7 +48,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', 3.12-dev]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
Expand All @@ -31,8 +58,4 @@ jobs:
- name: Install hatch
run: pipx install hatch
- name: Testing
if: matrix.python-version != '3.12-dev'
run: hatch run +py=${{ matrix.python-version }} test:run
- name: Testing 3.12-dev
if: matrix.python-version == '3.12-dev'
run: hatch run +py=3.12 test:run
13 changes: 5 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
exclude: ^tests/data/
repos:
- repo: https://github.com/psf/black
rev: 23.7.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
hooks:
- id: black
- id: ruff
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
- id: mypy
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.285
hooks:
- id: ruff
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.10.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2']
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies:
Expand Down
12 changes: 5 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Operating System :: OS Independent",
]

Expand All @@ -35,12 +36,12 @@ dev = ["hatch", "pytest", "black", "ruff", "mypy", "pre-commit"]
source = "vcs"

[tool.hatch.envs.fmt]
dependencies = ["pre-commit"]
detached = true
scripts.run = "pre-commit run --all"
scripts.update = "pre-commit autoupdate"

[tool.hatch.envs.test]
dependencies = ["pytest"]
dependencies = ["pytest", "pytest-github-actions-annotate-failures"]
scripts.run = "pytest tests"
matrix = [{ python = ["3.8", "3.9", "3.10", "3.11", "3.12"] }]

Expand All @@ -50,11 +51,6 @@ sources = ["src"]
[tool.pytest.ini_options]
addopts = "-vv"

[tool.black]
line-length = 88
target-version = ['py38', 'py39', 'py310', 'py311']
include = '\.pyi?$'

[tool.mypy]
python_version = "3.8"
files = ["src", "tests"]
Expand Down Expand Up @@ -93,6 +89,7 @@ select = [
"PLE",
"PLR",
"PLW",
"PT",
"RUF",
"S",
"SIM",
Expand All @@ -102,6 +99,7 @@ select = [
"W",
"YTT",
]

ignore = [
"E402", # Module level import not at top of file
"E731", # Do not assign a lambda expression, use a def
Expand Down

0 comments on commit 2db0300

Please sign in to comment.