Add gh-aw agentic workflow for upgrading Python libraries (#7117)

* Add gh-aw agentic workflow for upgrading Python libraries

- upgrade-pylib.md: Claude-based workflow triggered via workflow_dispatch
- Runs `scripts/update_lib quick <name>` to sync a library from CPython
- Creates a PR with the result, referencing issue #6839
This commit is contained in:
Jeong, YunWon authored and GitHub committed 2026-02-14 11:26:03 +09:00
1 parent b9f693004a
commit f960a0fbad
5 files changed
+1291 -4

No files matched your search

+2
View File
@@ -66,3 +66,5 @@ Lib/test/certdata/*.0 generated
Lib/test/levenshtein_examples.json generated
Lib/test/test_stable_abi_ctypes.py generated
Lib/token.py generated
.github/workflows/*.lock.yml linguist-generated=true merge=ours
+14
View File
@@ -0,0 +1,14 @@
{
"entries": {
"actions/github-script@v8": {
"repo": "actions/github-script",
"version": "v8",
"sha": "ed597411d8f924073f98dfc5c65a23a2325f34cd"
},
"github/gh-aw/actions/setup@v0.43.22": {
"repo": "github/gh-aw/actions/setup",
"version": "v0.43.22",
"sha": "fe858c3e14589bf396594a0b106e634d9065823e"
}
}
}
File diff suppressed because it is too large. Load diff
+122
View File
@@ -0,0 +1,122 @@
---
description: |
Pick an out-of-sync Python library from the todo list and upgrade it
by running `scripts/update_lib quick`, then open a pull request.
on:
workflow_dispatch:
inputs:
name:
description: "Module name to upgrade (leave empty to auto-pick)"
required: false
type: string
timeout-minutes: 45
permissions:
contents: read
issues: read
pull-requests: read
network:
allowed:
- defaults
- rust
- python
engine: claude
runtimes:
python:
version: "3.12"
tools:
bash:
- ":*"
edit:
github:
toolsets: [repos, issues, pull_requests]
read-only: true
safe-outputs:
create-pull-request:
title-prefix: "Update "
labels: [pylib-sync]
draft: false
expires: 30
env:
PYTHON_VERSION: "v3.14.3"
ISSUE_ID: "6839"
---
# Upgrade Python Library
You are an automated maintenance agent for RustPython, a Python 3 interpreter written in Rust. Your task is to upgrade one out-of-sync Python standard library module from CPython.
## Step 1: Set up the environment
Clone CPython at the correct version tag under the working directory:
```bash
git clone --depth 1 --branch "$PYTHON_VERSION" https://github.com/python/cpython.git cpython
```
## Step 2: Pick a module to upgrade
If the user provided a module name via `${{ github.event.inputs.name }}`, use that module.
Otherwise, run the todo script to find candidates:
```bash
python3 scripts/update_lib todo
```
From the output, pick **one** module that:
- Is marked `[ ]` (not yet up-to-date)
- Has `[no deps]` or `[0/N deps]` (all dependencies are satisfied)
- Has a small diff count (`Δ` number) — prefer modules with smaller diffs for reliability
- Is NOT one of these complex modules: `opcode`, `datetime`, `collections`, `random`, `hashlib`, `tokenize`, `pdb`, `_pyrepl`, `concurrent`, `asyncio`, `multiprocessing`, `ctypes`, `idlelib`, `tkinter`, `shutil`, `tarfile`, `email`, `unittest`
## Step 3: Run the upgrade
Run the quick upgrade command. This will copy the library from CPython, migrate test files preserving RustPython markers, auto-mark test failures, and create a git commit:
```bash
python3 scripts/update_lib quick <module_name>
```
This takes a while because it builds RustPython (`cargo build --release`) and runs tests to determine which ones pass or fail.
If the command fails, report the error and stop. Do not try to fix Rust code or modify test files manually.
## Step 4: Verify the result
After the script succeeds, check what changed:
```bash
git log -1 --stat
git diff HEAD~1 --stat
```
Make sure the commit was created with the correct message format: `Update <name> from <version>`.
## Step 5: Create the pull request
Create a pull request. Reference issue #${{ env.ISSUE_ID }} in the body but do **NOT** use keywords that auto-close issues (Fix, Close, Resolve).
Use this format for the PR body:
```
## Summary
Upgrade `<module_name>` from CPython $PYTHON_VERSION.
Part of #$ISSUE_ID
## Changes
- Updated `Lib/<module_name>` from CPython
- Migrated test files preserving RustPython markers
- Auto-marked test failures with `@expectedFailure`
```
+5 -4
View File
@@ -939,7 +939,10 @@ mod decl {
/// Extract fields from StructTimeData into a libc::tm for mktime.
#[cfg(any(unix, windows))]
pub(super) fn tm_from_struct_time(t: &StructTimeData, vm: &VirtualMachine) -> PyResult<libc::tm> {
pub(super) fn tm_from_struct_time(
t: &StructTimeData,
vm: &VirtualMachine,
) -> PyResult<libc::tm> {
let invalid_tuple = || vm.new_type_error("mktime(): illegal time tuple argument");
let year: i32 = t
.tm_year
@@ -1002,9 +1005,7 @@ mod decl {
}
let secs = float.floor();
if secs < libc::time_t::MIN as f64 || secs > libc::time_t::MAX as f64 {
return Err(
vm.new_overflow_error("timestamp out of range for platform time_t")
);
return Err(vm.new_overflow_error("timestamp out of range for platform time_t"));
}
Ok(secs as libc::time_t)
}