Skip to content

Commit 5ff6d20

Browse files
committed
Add helper CRON action for bumping cached cycle
1 parent c34d1b8 commit 5ff6d20

File tree

12 files changed

+636
-370
lines changed

12 files changed

+636
-370
lines changed

.bumper.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ search = 'version = "{current_version}"'
99
[[tool.bumper.files]]
1010
file = "./README.md"
1111
search = "rev: v{current_version}"
12+
13+
[[tool.bumper.files]]
14+
file = "./pre_commit_python_eol/__init__.py"
15+
search = '__version__ = "{current_version}"'

.flake8

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
[flake8]
2-
max-line-length=100
3-
import-order-style=pycharm
4-
application-import-names=pre_commit_python_eol,tests
52
extend-ignore=
6-
# pycodestyle
7-
E203,E226,E701
3+
E,F,W,
84
# flake8-annotations
95
ANN002,ANN003,ANN101,ANN102,ANN204,ANN206,
106
extend-exclude=

.github/workflows/bump_cache.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Check Cached Release Cycle
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 9 1 1,4,7,10 *"
7+
8+
jobs:
9+
bump-cache:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
issues: write
14+
15+
steps:
16+
- uses: actions/checkout@v5
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v6
20+
with:
21+
python-version-file: "pyproject.toml"
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v6
25+
with:
26+
version: "0.8.x"
27+
enable-cache: true
28+
cache-dependency-glob: "uv.lock"
29+
30+
- name: Bump Cache
31+
id: bump
32+
env:
33+
PUBLIC_PAT: ${{ secrets.PUBLIC_PAT }}
34+
run: |
35+
uv sync --no-dev --extra gha
36+
uv run ./pre_commit_python_eol/bump_cache.py
37+
{
38+
echo 'RES<<EOF'
39+
git diff ./cached_release_cycle.json
40+
echo EOF
41+
} >> "$GITHUB_OUTPUT"
42+
43+
- name: Open Issue If Bumped
44+
if: ${{ steps.bump.outputs.RES != ''}}
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
run: |
48+
today=$(date +"%Y-%m-%d")
49+
gh issue create \
50+
--title "($today) Release Cycle Cache Outdated" \
51+
--body '\`\`\`diff\n${{ steps.report.outputs.RES }}\n\`\`\`'

.github/workflows/lint_test.yml

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v6
20+
with:
21+
python-version-file: "pyproject.toml"
1722

1823
- name: Install uv
1924
uses: astral-sh/setup-uv@v6
2025
with:
21-
version: "0.7.x"
26+
version: "0.8.x"
2227
enable-cache: true
2328
cache-dependency-glob: "uv.lock"
2429

25-
- name: Set up Python
26-
uses: actions/setup-python@v5
27-
with:
28-
python-version-file: "pyproject.toml"
29-
3030
- name: Install dependencies
3131
run: uv sync --all-extras --dev
3232

@@ -38,21 +38,19 @@ jobs:
3838
runs-on: ubuntu-latest
3939
strategy:
4040
matrix:
41-
python-version: ["3.11", "3.12", "3.13"]
41+
python-version: ["3.11", "3.12", "3.13", "3.14-dev"]
4242
fail-fast: false
4343

4444
steps:
45-
- uses: actions/checkout@v4
45+
- uses: actions/checkout@v5
4646

47-
- name: Install uv
48-
uses: astral-sh/setup-uv@v6
49-
with:
50-
version: "0.7.x"
51-
enable-cache: true
52-
cache-dependency-glob: "uv.lock"
47+
- name: Get Non-Hyphenated Python Version
48+
id: get-pyver
49+
run: |
50+
echo "PYVER=$(cut -d '-' -f 1 <<< ${{ matrix.python-version }})" >> $GITHUB_OUTPUT
5351
5452
- name: Set up (release) Python ${{ matrix.python-version }}
55-
uses: actions/setup-python@v5
53+
uses: actions/setup-python@v6
5654
if: "!endsWith(matrix.python-version, '-dev')"
5755
with:
5856
python-version: ${{ matrix.python-version }}
@@ -63,13 +61,21 @@ jobs:
6361
with:
6462
python-version: ${{ matrix.python-version }}
6563

64+
- name: Install uv
65+
uses: astral-sh/setup-uv@v6
66+
with:
67+
version: "0.8.x"
68+
enable-cache: true
69+
cache-dependency-glob: "uv.lock"
70+
6671
- name: Install dependencies
6772
run: |
68-
uv venv
69-
uv pip install tox-gh-actions tox-uv
73+
uv venv --python ${{ steps.get-pyver.outputs.PYVER }}
74+
uv pip install tox-uv
7075
7176
- name: Run tests w/tox
72-
run: uv run tox
77+
run: |
78+
uv run tox -e ${{ steps.get-pyver.outputs.PYVER }}
7379
7480
- name: Cache coverage for ${{ matrix.python-version }}
7581
uses: actions/upload-artifact@v4
@@ -84,15 +90,15 @@ jobs:
8490
needs: test
8591

8692
steps:
87-
- uses: actions/checkout@v4
93+
- uses: actions/checkout@v5
8894

8995
- name: Set up Python
90-
uses: actions/setup-python@v5
96+
uses: actions/setup-python@v6
9197
with:
9298
python-version-file: "pyproject.toml"
9399

94100
- name: Pull coverage workflow artifacts
95-
uses: actions/download-artifact@v4
101+
uses: actions/download-artifact@v5
96102
with:
97103
path: cov_cache/
98104

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ jobs:
1212
contents: write
1313

1414
steps:
15-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@v5
1616

1717
- name: Install uv
1818
uses: astral-sh/setup-uv@v6
1919
with:
20-
version: "0.7.x"
20+
version: "0.8.x"
2121
enable-cache: true
2222
cache-dependency-glob: "uv.lock"
2323

2424
- name: Set up Python
25-
uses: actions/setup-python@v5
25+
uses: actions/setup-python@v6
2626
with:
2727
python-version-file: "pyproject.toml"
2828

.pre-commit-config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ repos:
1717
- id: flake8
1818
additional_dependencies:
1919
- flake8-annotations
20+
- flake8-define-class-attributes
2021
- repo: https://github.com/pre-commit/pre-commit-hooks
21-
rev: v5.0.0
22+
rev: v6.0.0
2223
hooks:
2324
- id: check-case-conflict
2425
- id: check-json
@@ -35,6 +36,6 @@ repos:
3536
- id: python-check-blanket-type-ignore
3637
- id: python-use-type-annotations
3738
- repo: https://github.com/astral-sh/ruff-pre-commit
38-
rev: v0.12.2
39+
rev: v0.13.0
3940
hooks:
4041
- id: ruff-check

.ruff.toml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ select = [
1212
"B", # flake8-bugbear
1313
"C4", # flake8-comprehensions
1414
"D", # pydocstyle/flake8-docstrings
15+
"E", # pycodestyle
1516
"F", # Pyflakes
1617
"FIX", # flake8-fixme
1718
"N", # pep8-naming
19+
"W", # pycodestyle
1820
]
1921

2022
ignore = [
@@ -55,10 +57,3 @@ ignore = [
5557
"D101",
5658
"D103",
5759
]
58-
59-
[lint.flake8-bugbear]
60-
extend-immutable-calls = [
61-
# Typer CLI
62-
"typer.Option",
63-
"typer.Argument",
64-
]

pre_commit_python_eol/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__version__ = "2025.5.0"
2+
__url__ = "https://github.com/sco1/pre-commit-check-eol"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import json
2+
import platform
3+
from pathlib import Path
4+
5+
from pre_commit_python_eol import __url__, __version__
6+
7+
try:
8+
import httpx
9+
except ImportError:
10+
raise RuntimeError(
11+
"httpx was not installed, please install the 'gha' dependency group"
12+
) from None
13+
14+
USER_AGENT = (
15+
f"pre-commit-check-eol/{__version__} ({__url__}) "
16+
f"httpx/{httpx.__version__} "
17+
f"{platform.python_implementation()}/{platform.python_version()}"
18+
)
19+
20+
CACHE_SOURCE = (
21+
"https://raw.githubusercontent.com/python/devguide/refs/heads/main/include/release-cycle.json"
22+
)
23+
LOCAL_CACHE = Path("./cached_release_cycle.json")
24+
25+
26+
def bump_cache() -> None:
27+
"""Update the cached release cycle JSON from the source repository."""
28+
with httpx.Client(headers={"User-Agent": USER_AGENT}) as client:
29+
r = client.get(CACHE_SOURCE)
30+
r.raise_for_status()
31+
32+
rj = r.json()
33+
34+
with LOCAL_CACHE.open("w", encoding="utf8") as f:
35+
json.dump(rj, f, indent=2, ensure_ascii=False)
36+
f.write("\n") # Add in trailing newline
37+
38+
39+
if __name__ == "__main__":
40+
bump_cache()

pyproject.toml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ classifiers = [
1717
"Programming Language :: Python :: 3.11",
1818
"Programming Language :: Python :: 3.12",
1919
"Programming Language :: Python :: 3.13",
20+
"Programming Language :: Python :: 3.14",
2021
"Typing :: Typed",
2122
]
2223

@@ -35,24 +36,30 @@ Changelog = "https://github.com/sco1/pre-commit-python-eol/blob/main/CHANGELOG.m
3536
[project.scripts]
3637
checkeol = "pre_commit_python_eol.check_eol:main"
3738

38-
[tool.uv]
39-
dev-dependencies = [
39+
[dependency-groups]
40+
dev = [
4041
"black~=25.0",
4142
"flake8~=7.1",
4243
"flake8-annotations~=3.1",
44+
"flake8-define-class-attributes~=0.2",
4345
"isort~=6.0",
4446
"mypy~=1.14",
4547
"pre-commit~=4.0",
4648
"pytest~=8.3",
47-
"pytest-cov~=6.0",
48-
"pytest-randomly~=3.16",
49+
"pytest-cov~=7.0",
50+
"pytest-randomly~=4.0",
4951
"ruff~=0.9",
5052
"sco1-bumper~=2.0",
5153
"time-machine~=2.16",
5254
"tox~=4.23",
5355
"tox-uv~=1.17",
5456
]
5557

58+
[project.optional-dependencies]
59+
gha = [
60+
"httpx~=0.28",
61+
]
62+
5663
[tool.black]
5764
line-length = 100
5865

@@ -69,6 +76,7 @@ disallow_incomplete_defs = true
6976
disallow_untyped_calls = true
7077
disallow_untyped_decorators = true
7178
disallow_untyped_defs = true
79+
enable_error_code = "exhaustive-match"
7280
ignore_missing_imports = true
7381
no_implicit_optional = true
7482
show_error_codes = true
@@ -77,6 +85,10 @@ warn_return_any = true
7785
warn_unused_configs = true
7886
warn_unused_ignores = true
7987

88+
[tool.uv.build-backend]
89+
module-name = "pre_commit_python_eol"
90+
module-root = ""
91+
8092
[build-system]
81-
requires = ["hatchling"]
82-
build-backend = "hatchling.build"
93+
requires = ["uv_build"]
94+
build-backend = "uv_build"

0 commit comments

Comments
 (0)