Skip to content

[AAASM-2863] ✅ (release-python): Add test for resolve step's PEP 440 conversion#111

Merged
Chisanan232 merged 4 commits into
masterfrom
v0.0.1/AAASM-2863/pep440_test
Jun 13, 2026
Merged

[AAASM-2863] ✅ (release-python): Add test for resolve step's PEP 440 conversion#111
Chisanan232 merged 4 commits into
masterfrom
v0.0.1/AAASM-2863/pep440_test

Conversation

@Chisanan232

Copy link
Copy Markdown
Contributor

Description

Hardens the python-sdk release pipeline's agent-assembly tag → PEP 440 version conversion with a unit-test that exercises the same code the workflow runs.

Implementation:

  1. Extract the sed-based conversion out of release-python.yml's resolve job and into .github/scripts/tag-to-pep440.sh, exposing it as a sourceable tag_to_pep440 function plus a CLI fall-through.
  2. Update the resolve job to source the helper (with a matching actions/checkout so the file is on disk).
  3. Add .github/scripts/test_tag_to_pep440.sh — a bash fixture suite that sources the same helper and covers all six AAASM-2863 fixture categories plus a handful of edge cases.
  4. Add .github/workflows/release-python-conversion-test.yml — a tiny PR-scoped workflow that shellchecks the two scripts and runs the suite. Scoped tightly so the existing multi-OS Python ci.yaml matrix is not pulled in by shell-script edits.

Result: the workflow and the test now share the exact regex, so the test proves the workflow's behaviour rather than a copy of it.

Type of Change

  • ♻️ Refactoring (extract conversion to script)
  • ✅ Tests (new fixture suite)

Breaking Changes

  • No — conversion semantics are byte-for-byte identical to the inlined sed at release-python.yml master HEAD.

Related Issues

Testing

Local run on macOS (Apple silicon):

$ bash .github/scripts/test_tag_to_pep440.sh
== tag_to_pep440 fixtures ==
OK    v0.0.1               -> 0.0.1
OK    v0.0.1-alpha.1       -> 0.0.1a1
OK    v0.0.1-alpha.10      -> 0.0.1a10
OK    v0.0.1-beta.2        -> 0.0.1b2
OK    v0.0.1-rc.3          -> 0.0.1rc3
OK    v1.23.456-alpha.789  -> 1.23.456a789
OK    v10.20.30            -> 10.20.30
OK    v0.0.1-dev.1         -> 0.0.1-dev.1
OK    v0.0.1-beta.42       -> 0.0.1b42
OK    v0.0.1-rc.99         -> 0.0.1rc99
== empty-input guard ==
OK    empty input rejected
Summary: 11 passed, 0 failed, 11 total

actionlint and shellcheck -x clean on both new shell scripts and both touched workflows.

  • Unit tests added (new bash fixture suite)
  • Integration tests added/updated
  • Manual testing performed (local 11/11 pass)
  • No tests required

Checklist

  • Code follows project style guidelines (GitEmoji commits, one logical unit each)
  • Self-review completed
  • Comments added for complex logic (script header + per-fixture intent)
  • Documentation updated if needed (header comments document local-run command)
  • All tests passing

Acceptance criteria coverage

AAASM-2863 AC Status
Test file present, runnable via documented command bash .github/scripts/test_tag_to_pep440.sh
6 fixture categories exercised Stable, alpha (x2), beta, rc, multi-digit base — 6 of 11 cases
CI runs the test New workflow release-python-conversion-test.yml (PR-scoped to .github/scripts/** + release-python.yml)
Logic extracted; workflow sources function instead of inlining sed Done — resolve job sources .github/scripts/tag-to-pep440.sh

… script

Move the sed-based agent-assembly tag → PEP 440 version conversion out of
the release-python.yml `resolve` job's inline bash and into a single
sourceable script `.github/scripts/tag-to-pep440.sh` exposing
`tag_to_pep440 <tag>`. This makes the conversion the unit-under-test for
the AAASM-2863 follow-up test harness rather than a copy of the regex.

Refs AAASM-2863.
Replace the inline sed in the `resolve` job's repository_dispatch branch
with a `source` + call into the new `.github/scripts/tag-to-pep440.sh`
helper. Adds the matching `actions/checkout@v6` step so the working tree
is on disk for the source call (the job previously did not check out).

Conversion semantics are unchanged — the helper holds the same sed
expression byte-for-byte. The win is that the AAASM-2863 unit tests now
exercise the exact code path the workflow runs.

Refs AAASM-2863.
Cover the six AAASM-2863 fixture categories — stable, alpha (single +
double digit), beta, rc, and multi-digit base version with a large
pre-release counter — by sourcing the same helper the workflow runs.

Adds extra coverage for the v-prefix-only case, unknown pre-release
types passing through, multi-digit beta/rc counters, and the empty-input
fail-fast guard the workflow depends on to avoid emitting an empty
pypi_version.

Runnable locally with `bash .github/scripts/test_tag_to_pep440.sh`;
CI wiring follows in a separate commit.

Refs AAASM-2863.
Add a small CI workflow that lints and runs the tag → PEP 440 fixture
suite whenever the conversion script, its test, the release-python
workflow that sources the script, or this workflow itself changes.

The existing ci.yaml is intentionally not broadened to cover
.github/scripts/** — that workflow drives the full Python test matrix
across multiple OSes and runs on Python source changes; gating it on
a shell-script edit would be overkill. A dedicated workflow keeps the
trigger surface tight and the runtime under a few seconds.

Refs AAASM-2863.
@Chisanan232

Chisanan232 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

Claude Code review — AAASM-2863

CI state

Both checks SUCCESS on head:

Workflow Result
CodeQL — Analyze (python) ✅ SUCCESS
Run tag → PEP 440 fixture suite (new) ✅ SUCCESS

The new dedicated workflow (release-python-conversion-test.yml) fired on this PR exactly as designed — its paths filter matched both the new helper and the workflow it sources. MERGEABLE, blocked only on review.

Scope vs. acceptance criteria

AC Status Where
Test file present + runnable via documented command .github/scripts/test_tag_to_pep440.sh runs as bash test_tag_to_pep440.sh.
≥6 fixture categories exercised ✅ — 11/11 pass 6 ticket-spec fixtures + 5 edge cases (v-prefix-only, unknown pre-release passthrough, multi-digit beta/rc, empty-input guard).
CI runs the test New workflow release-python-conversion-test.yml (path-scoped).
Logic extracted into a reusable shell function the workflow sources ✅ — Option A taken .github/scripts/tag-to-pep440.sh exposes tag_to_pep440() (sourceable + CLI fallthrough). resolve job in release-python.yml sources it.

Why the extraction matters

Without Option A, the test would have proved its own copy of the regex, not the workflow's actual code path. The whole reason the ticket existed was that AAASM-2857's sed conversion was only "verified across 5 representative tags" — meaning the workflow's conversion wasn't testable without running the workflow. By extracting tag_to_pep440() into a sourceable script the workflow uses, the test now exercises the same bytes the workflow executes. Genuinely closes the gap.

Diff audit — 4 atomic commits, 4 files

Commit Files Purpose
♻️ Extract tag → PEP 440 conversion into a reusable script .github/scripts/tag-to-pep440.sh (new, 44 lines) Helper
♻️ Source tag → PEP 440 helper from resolve job .github/workflows/release-python.yml (+11 -3) Wiring + actions/checkout@v6 added to resolve (job previously did not check out the tree)
✅ Add test for tag → PEP 440 conversion .github/scripts/test_tag_to_pep440.sh (110 lines) Test harness
🤖 Run tag → PEP 440 fixture suite on PR .github/workflows/release-python-conversion-test.yml (47 lines) CI invocation

Net: +212 / -3 across 4 files.

Notable design decisions (subagent's, validated)

  • Dedicated tiny workflow rather than extending ci.yaml: ci.yaml's pull_request.paths allowlist is intentionally scoped to Python source + project config. Wedging shell-script test paths into that allowlist would broaden CI's responsibility. A dedicated 47-line workflow that fires only on changes to the helper or the workflow that sources it keeps CI cost proportional. Correct call.
  • resolve job needed actions/checkout@v6 added: previously the job did its work entirely in inline bash and didn't check out the repo. Sourcing the new helper requires the file in the workspace. Subagent caught this — without the checkout, the source command would fail and the workflow would break.

Forward-compatibility

The pattern (extract → source → test) is reusable. If node-sdk wants to add a similar test for its own bash logic (e.g. the dist-tag derivation in Publish 4 runtime sub-packages), it can follow the same shape.

Verdict

Ready for human approval and merge. All 4 ACs covered. Option A (extraction) is the correct choice — without it, the test would have been worthless theatre. The dedicated test workflow is scoped tightly and runs fast.

— Claude Code

@Chisanan232 Chisanan232 merged commit eb8727d into master Jun 13, 2026
2 checks passed
@Chisanan232 Chisanan232 deleted the v0.0.1/AAASM-2863/pep440_test branch June 13, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant