Skip to content

generator: stamp tend version into workflow header - #316

Merged
max-sixty merged 2 commits into
mainfrom
generator/stamp-version-in-header
Apr 19, 2026
Merged

max-sixty merged 2 commits into
mainfrom
generator/stamp-version-in-header

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Summary

  • Stamp the running tend version into every generated workflow header: # Generated by tend 0.0.16. instead of # Generated by tend., via importlib.metadata.version("tend") in generator/src/tend/workflows.py.
  • Update plugins/tend-ci-runner/skills/nightly/SKILL.md Step 6 to read that anchor from the workflow YAML before and after uvx tend@latest init, surface the bump in the PR title (chore: update tend workflows (A → B)), and include a git diff --stat summary in the body.
  • Anchor is stable regardless of what templates pin for uvx tend@… or the max-sixty/tend@v1 action tag, so detection works on tend itself (where neither template embeds a concrete version today) and on downstream repos that pin to latest.
  • Pre-stamp workflows produce an empty OLD_VER; renderer omits the version line when either side is empty or both sides match, so the transitional regen (before / after this ships) won't print unknown → 0.0.17.
  • Closes nightly: include version bump and diff summary in "update tend workflows" PR body #313. Supersedes nightly: include version bump and diff stat in workflow-update PR body #314 (discussion).

Test plan

  • uv run pytest in generator/ — 164 passed (regtest snapshots refreshed for all 8 workflows × minimal + with-setup parameterizations).
  • pre-commit run on touched files — trim whitespace, ruff, typos, bang-backtick guard all pass.
  • End-to-end: first nightly run after this ships stamps the regenerated workflows with the published version; the subsequent nightly (once the publish has made uvx tend@latest carry this change) will be the first to show A → B when tend is bumped.

Every generated workflow now starts with `# Generated by tend X.Y.Z.`
instead of `# Generated by tend.`, giving downstream nightly regen a
stable anchor for detecting version bumps regardless of what templates
pin for uvx or the action tag.

Update plugins/tend-ci-runner/skills/nightly/SKILL.md Step 6 to read
that anchor before and after `uvx tend@latest init`, surface the bump
in the PR title (`chore: update tend workflows (A -> B)`), and include
a `git diff --stat` summary in the body. Pre-stamp workflows produce
an empty OLD_VER, and the renderer omits the version line when either
side is empty or both sides match.

Closes #313.

@tend-agent tend-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The stamp-in-header approach cleanly supersedes the template-regex fallback from #314 — one anchor per file, independent of what templates pin. Shell logic in plugins/tend-ci-runner/skills/nightly/SKILL.md handles the three transitional cases correctly (empty OLD, equal OLD/NEW, real bump), and the semver ERE matches the format importlib.metadata.version("tend") produces for the current pyproject.toml.

One release-maintenance concern worth flagging: the regtest snapshots now pin the literal version string (# Generated by tend 0.0.16. × 16 files). Every subsequent version = "X.Y.Z" bump in generator/pyproject.toml will fail uv run pytest until all 16 snapshots are regenerated with --regtest-reset. The release skill at .claude/skills/release/SKILL.md doesn't currently mention this step. Two options:

  • Scrub the version in the existing conftest.py register_converter_pre hook (e.g. re.sub(r'# Generated by tend [^.]+\.', '# Generated by tend X.Y.Z.', output)), so regtests only assert on structural content. test_extras_preserve_header already covers the "header is present" case via startswith("# Generated by tend ").
  • Or add a snapshot-regen step to the release skill.

The first avoids ongoing churn entirely; the second accepts it as explicit release friction. Not a blocker either way.

Pin a placeholder (`X.Y.Z`) in the workflow header instead of the literal
version, so a `version = ...` bump in `generator/pyproject.toml` doesn't
rewrite all 16 regtest snapshots. `test_extras_preserve_header` already
asserts the header is present.

Addresses review feedback on #316.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@tend-agent

Copy link
Copy Markdown
Collaborator Author

Applied option 1 — added a register_converter_pre scrubber in generator/tests/conftest.py that rewrites the stamped version to X.Y.Z before snapshot comparison, and regenerated the 16 outputs. test_extras_preserve_header continues to cover "header is present". Future version = ... bumps in generator/pyproject.toml no longer touch regtest snapshots.

@max-sixty
max-sixty merged commit 8563ce2 into main Apr 19, 2026
3 checks passed
@max-sixty
max-sixty deleted the generator/stamp-version-in-header branch April 19, 2026 18:55
@max-sixty max-sixty mentioned this pull request May 8, 2026
2 of 3 tasks
max-sixty added a commit that referenced this pull request May 8, 2026
## Summary

- Bumps generator version 0.0.16 → 0.0.17
- 57 commits since 0.0.16; the headline change is #375 (gate
fork-exposed scheduled workflows on `github.repository_owner` so
consumer-repo forks no-op on the cron and stop generating cross-repo
CheckSuite notifications back to `tend-agent`)
- Other notable changes: workflow header stamps tend version (#316),
bot-token rebound to `GITHUB_TOKEN` (#373), review skill
draft/light-mode + polling improvements (#308, #311, #315, #362)

## Test plan

- [x] `uv run pytest` — 188 passed
- [x] `pre-commit run --all-files` — clean
- [ ] After merge: tag 0.0.17, PyPI publishes, regenerate tend's own
workflows with `uvx tend@latest init`

Co-authored-by: Claude <[email protected]>
max-sixty added a commit that referenced this pull request May 8, 2026
## Summary

Regenerates `.github/workflows/tend-*.yaml` against the freshly
published 0.0.17. Brings tend's own deployment in line with what
consumers will see after their nightly regen:

- **Fork guard (#375)**: scheduled jobs now carry `if:
github.repository_owner == 'max-sixty'`, so forks of tend (or
fork-of-fork chains) no-op on the cron instead of failing on missing
secrets and pinging `tend-agent` with cross-repo CheckSuite
notifications.
- **Header (#316)**: workflow comment now reports the generator version
it was rendered from.
- **GITHUB_TOKEN rebind (#373)**: the bot token is now exported as
`GITHUB_TOKEN` (previously `GH_TOKEN`).

## Test plan

- [x] `uvx [email protected] init` produced a clean diff (8 files, +19/-16)
limited to header, `if:` guard, and the token env-var rename
- [ ] Watch tomorrow's scheduled runs to confirm the guard does not gate
out tend's own canonical workflow

Co-authored-by: Claude <[email protected]>
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.

nightly: include version bump and diff summary in "update tend workflows" PR body

2 participants