|
| 1 | +# Project Context Overview |
| 2 | + |
| 3 | +This document captures the current state of the **CPython Patch PR Action** repository, the key |
| 4 | +capabilities that have been implemented so far, and any manual configuration that enables the |
| 5 | +nightly workflows to run end-to-end. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Action capabilities |
| 10 | + |
| 11 | +- **Version detection** |
| 12 | + - GitHub tag fetcher with python.org fallback. |
| 13 | + - Runner availability validation against `actions/python-versions`. |
| 14 | + - Pre-release guard (opt-in via `include_prerelease`). |
| 15 | + - Track alignment + idempotence helpers. |
| 16 | +- **Scanning & rewriting** |
| 17 | + - Globs for common Python version files. |
| 18 | + - Regex matchers covering workflows, Dockerfiles, runtime files, `pyproject.toml`, `Pipfile`, |
| 19 | + Conda `environment.yml`, etc. |
| 20 | + - Dry-run summaries and targeted patch computation that preserves Docker suffixes. |
| 21 | +- **Git / PR integration** |
| 22 | + - Branch+commit helper (`chore/bump-python-<track>`). |
| 23 | + - Pull-request helper with Octokit throttling & duplicate-PR prevention. |
| 24 | +- **Testing & coverage** |
| 25 | + - Vitest suite with >90% coverage (run `npm run test -- --coverage`). |
| 26 | + - Git-based integration tests using temporary repositories. |
| 27 | +- **Documentation & metadata** |
| 28 | + - README with SEO-friendly quick start and advanced configuration. |
| 29 | + - CHANGELOG (Keep a Changelog format). |
| 30 | + - SECURITY policy outlining required permissions and endpoints. |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## GitHub workflows |
| 35 | + |
| 36 | +### `.github/workflows/fixtures.yml` |
| 37 | +Runs the action in **dry-run** mode against local fixtures: |
| 38 | + |
| 39 | +- CI jobs: install, build (`npm run build`), bundle (`npm run bundle`), then `uses: ./` with |
| 40 | + `dry_run: true`. |
| 41 | +- Fixture matrix (`fixtures/basic`, `fixtures/workflow`) ensures core scanners stay stable. |
| 42 | +- No secrets required (read-only `GITHUB_TOKEN` is sufficient). |
| 43 | + |
| 44 | +### `.github/workflows/nightly.yml` |
| 45 | +Weekly **Monday 03:00 UTC** E2E run against a sandbox repository: |
| 46 | + |
| 47 | +- Builds/bundles this repo. |
| 48 | +- Clones the sandbox repo and executes the action in non-dry-run mode (`dry_run: false`). |
| 49 | +- Writes a summary containing repository, branch, track, automerge flag, files changed, |
| 50 | + and `skipped_reason`. |
| 51 | +- Requires secrets and optional variables (see next section). |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## Sandbox configuration |
| 56 | + |
| 57 | +Set the following in **Settings → Secrets and variables → Actions**: |
| 58 | + |
| 59 | +| Name | Type | Required | Description | |
| 60 | +|------|------|----------|-------------| |
| 61 | +| `SANDBOX_REPO` | Secret | ✅ | Repo slug e.g. `username/python-sandbox`. | |
| 62 | +| `SANDBOX_TOKEN` | Secret | ✅ | PAT with `contents: read/write` and `pull-requests: read/write` scopes for the sandbox repo. | |
| 63 | +| `SANDBOX_TRACK` | Variable | Optional (`3.11` default) | CPython minor to track. | |
| 64 | +| `SANDBOX_DEFAULT_BRANCH` | Variable | Optional (`main` default) | Branch to check out before running. | |
| 65 | +| `SANDBOX_AUTOMERGE` | Variable | Optional (`false` default) | Pass-through to the action’s `automerge` input. | |
| 66 | + |
| 67 | +### Sandbox repo content |
| 68 | + |
| 69 | +Include deliberate CPython version pins (e.g. Dockerfile, `.github/workflows/*.yml`, |
| 70 | +`runtime.txt`, `pyproject.toml`, `Pipfile`, `environment.yml`). A sample prompt for scaffolding |
| 71 | +the sandbox is captured in the main discussion and can be reused to populate example files. |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## Running locally |
| 76 | + |
| 77 | +```bash |
| 78 | +npm ci |
| 79 | +npm run lint |
| 80 | +npm run test -- --coverage |
| 81 | +npm run bundle |
| 82 | +node dist/index.js # Placeholder run output |
| 83 | +``` |
| 84 | + |
| 85 | +Use `node dist/index.js` to confirm the bundled action executes; currently it only logs |
| 86 | +configuration and emits `skipped_reason: not_implemented`. |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## Roadmap snapshot (docs/tasks.md) |
| 91 | + |
| 92 | +Tasks 1–31 are marked complete, covering scaffolding, metadata, docs, scanning engine, |
| 93 | +rewrite logic, branch/PR automation, dry-run workflows, sandbox nightly job, and Octokit |
| 94 | +throttling. Task 32 onward focuses on bundling `dist/`, release workflows, CodeQL, |
| 95 | +example consumer repos, and additional guardrails. |
| 96 | + |
| 97 | +Refer to `docs/tasks.md` for the full list of upcoming work. |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +_Last updated: 2025-10-09_ |
0 commit comments