Skip to content

Introduce a Python automation library - #993

Draft
zaniebot wants to merge 7 commits into
mainfrom
zb/python-automations-library
Draft

zaniebot wants to merge 7 commits into
mainfrom
zb/python-automations-library

Conversation

@zaniebot

@zaniebot zaniebot commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

The GitHub automations currently spread data handling, API calls, and workflow decisions across shell scripts, jq, and inline code. Introduce uv-automations, an internal Python 3.14+ package with typed GitHub values, exhaustive state handling, immutable results, and explicit Actions adapters. Move the deterministic pull-request labeling and conflict-discovery stages into Python, including context preparation, repository and head checks, matrix selection, label publication, and cleanup. GitHub Actions retains the job graph, credential exchange, and separate publisher jobs. The package README sketches the same boundary for issue context, workflow retries, promotion, rebasing, and releases.

@astral-automations-bot astral-automations-bot Bot added internal:automations Related to internal automations internal A refactor or improvement that is not user-facing labels Sep 9, 2026
@zaniebot zaniebot added priority:2 Important: bounded correctness, release reliability, committed work, or proven performance gains. size:4 Complex: architectural or security-sensitive work requiring broad or cross-repository context. labels Sep 9, 2026
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/python-automations-library branch from 8c73fc1 to ea4a5ed Compare September 9, 2026 22:34
@zaniebot zaniebot added the risk:1 Negligible risk of localized mistakes that are obvious and easy to correct. label Sep 11, 2026
@zaniebot
zaniebot force-pushed the zb/python-automations-library branch from ea4a5ed to c7580b2 Compare September 23, 2026 14:42
@codspeed

codspeed Bot commented Sep 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 41 untouched benchmarks


Comparing zb/python-automations-library (1881e69) with main (40efebb)

Open in CodSpeed

@zaniebot zaniebot added risk:3 Credible risk of meaningful incorrect behavior or regression; bounded or recoverable. and removed risk:1 Negligible risk of localized mistakes that are obvious and easy to correct. labels Sep 25, 2026
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/python-automations-library branch 2 times, most recently from cba2b77 to 95956d8 Compare October 6, 2026 00:11
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/python-automations-library branch from 95956d8 to ec011cc Compare October 9, 2026 20:17
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/python-automations-library branch from ec011cc to 1ea6b57 Compare October 20, 2026 15:05
Comment on lines +80 to +81
version: "0.12.13"
checksum: "745765a3b6e360ad76743599ae5c42e9278c7edf8bbff9fc76d05bf2623a04dd"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Use a uv version that supports the root configuration

uv 0.12.13 deserializes build-constraint-dependencies as requirement strings, but the root pyproject.toml now contains { requirement, hashes } tables. The new type-check command reads that manifest directly, and the nested project commands also parse it during workspace discovery, causing these jobs to fail before Python runs. Update the new uv pins and matching checksums in all three workflows to the compatible version already used by neighboring jobs.

Comment on lines +43 to +45
@dataclass(frozen=True, slots=True)
class LabelPlan:
labels: tuple[str, ...]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Enforce label policy when constructing LabelPlan

The CLI currently calls validate_label_plan, but the library permits LabelPlan(("bot:rebase",)), which apply_labels forwards to the publisher without checking the allowlist, count, or uniqueness. The frozen dataclass prevents mutation but does not establish the invariant its consumer relies on; every future caller must remember the validation sequence. Require the allowlist when constructing LabelPlan and enforce these constraints there, with both recommendation and JSON adapters delegating to that checked construction.

Comment on lines +92 to +97
for value in [
'{"labels":[],"summary":""}\n{"labels":["bug"],"summary":""}',
'{"labels":["bug"],"labels":[],"summary":""}',
'{"labels":[],"summary":NaN}',
]:
with self.subTest(value=value):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Give CLI rejection scenarios separate named tests

This case-table loop runs three full CLI integration scenarios against the same output path, contrary to the repository's explicit integration-test convention. The cases cannot be selected independently, and an unexpected output write in one case contaminates subsequent assertions. Follow the direct invocation pattern in the neighboring test_cli: use separately named tests with isolated fixtures for the distinct CLI rejection behaviors, leaving additional decoder permutations in test_json.py.

This branch was successfully deployed

1 active deployment
automations — 53041ca7 Deployed Oct 20, 2026 by astral-automations-bot[bot] via review-code-quality / report #11160
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal:automations Related to internal automations internal A refactor or improvement that is not user-facing priority:2 Important: bounded correctness, release reliability, committed work, or proven performance gains. risk:3 Credible risk of meaningful incorrect behavior or regression; bounded or recoverable. size:4 Complex: architectural or security-sensitive work requiring broad or cross-repository context.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants