Skip to content

nightly: include version bump and diff stat in workflow-update PR body - #314

Closed
tend-agent wants to merge 2 commits into
mainfrom
skills/nightly-pr-version-summary
Closed

tend-agent wants to merge 2 commits into
mainfrom
skills/nightly-pr-version-summary

Conversation

@tend-agent

Copy link
Copy Markdown
Collaborator

Summary

  • In plugins/tend-ci-runner/skills/nightly/SKILL.md Step 6, extract the pinned tend version from workflow YAML before and after uvx tend@latest init, and surface the bump in the PR title (chore: update tend workflows (A → B)) plus body.
  • Always include a git diff --stat .github/workflows summary in the body so maintainers can see which files changed without opening the diff.
  • Detection supports uvx [email protected] and tend==X.Y.Z markers; when either side is empty or both match, the title and body omit the version line (matches the current state where templates use uvx tend@latest and max-sixty/tend@v1).

Addresses #313.

Test plan

  • Regex extraction verified against three inputs: uvx [email protected] init → 1.2.3, tend==0.0.16 → 0.0.16, uvx tend@latest init → empty.
  • Title rendering verified for bump (0.0.15 → 0.0.16), same version, and empty detection — only the bump case adds the suffix.
  • pre-commit run on the modified skill: passes (trim-whitespace, typos, bang-backtick guard).
  • End-to-end behavior will be validated on the next nightly run.

Extract the pinned tend version (if any) from the workflow YAML before and
after regeneration, and surface the delta alongside a `git diff --stat`
summary in the PR title/body. Falls back to omitting the version line when
no version pin is embedded (the current state, since templates use
`uvx tend@latest` and `max-sixty/tend@v1`) or when both sides match.

Addresses #313.

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

@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.

One structural concern on the cross-block state dependency — see inline. The regex and title/body rendering themselves look correct, and the issue is latent until templates pin a tend version, but worth addressing now so the feature actually fires when it's needed.

PR:

`````bash
NEW_VER=$(extract_tend_version)

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.

NEW_VER=$(extract_tend_version) and the [ -n "$OLD_VER" ] condition reference the function and variable defined in the earlier bash block. Per the running-in-ci skill and CLAUDE.md, shell state doesn't persist between bash tool calls — so when the agent runs this as a separate invocation from block 1 (the natural pattern, since git status output drives the branch), both are gone. OLD_VER reads as empty, extract_tend_version is undefined, and the version-bump line never renders.

Latent today because the current workflow templates use uvx tend@latest — so OLD_VER/NEW_VER are always empty and the fallback path runs correctly either way. But once a version gets pinned in the templates, the feature would silently no-op.

Two fixes: (1) consolidate into one script with an if around the PR-creation branch so everything runs in one bash call; or (2) stash OLD_VER to a temp file in block 1 (echo "$OLD_VER" > "$TMPDIR/tend-old-ver") and re-source it plus redefine extract_tend_version here.

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.

Good catch — fixed in de974f7. Took option 2: OLD_VER is now stashed to $TMPDIR/tend-old-ver in block 1 and read back in block 3, and the grep is inlined at both extraction sites rather than wrapped in a function (since the function can't survive the bash boundary either).

…ndary

Shell state doesn't persist between Bash tool calls, so `OLD_VER` and
`extract_tend_version` defined in the capture block would be gone when
the PR-creation block ran as a separate invocation. Latent today because
the templates use `uvx tend@latest`, but would silently no-op once a
version gets pinned.

Write OLD_VER to $TMPDIR/tend-old-ver in block 1 and read it back in
block 3; inline the grep at both extraction sites instead of defining a
function.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner

another option is to write out the version into the generated files; could we do that?

@tend-agent

Copy link
Copy Markdown
Collaborator Author

Yes — the generator knows its own version via importlib.metadata.version("tend"), so we could stamp it into the HEADER constant in generator/src/tend/workflows.py (e.g. # Generated by tend 0.0.16. Regenerate with: uvx tend@latest init). That gives detection a single well-defined anchor on every generated workflow regardless of what templates pin, and the nightly skill can just grep one line from HEAD vs the regenerated tree.

A few things worth weighing:

  • It's a strict superset of what this PR does: header-stamp makes the version visible for tend's own nightly (currently neither template in this repo pins a version, so the dual regex would detect nothing) and for downstream repos that use uvx tend@latest.
  • Every tend bump would produce a one-line header diff across all tend-*.yaml files, which is the signal we want but adds a small amount of regen churn when the template body is otherwise unchanged.
  • It makes this PR's extraction logic redundant. Cleanest path is probably to close this and open a two-part change (generator stamp + nightly skill reads the stamp), rather than keeping the template-regex fallback.

Happy to redirect if you'd like me to go that way.

@max-sixty

Copy link
Copy Markdown
Owner

yes, let's pursue that

@tend-agent

Copy link
Copy Markdown
Collaborator Author

Closing in favor of the header-stamp approach. Will open a replacement PR that adds Generated by tend X.Y.Z. to the workflow header and has the nightly skill read it, which is a strict superset of what this PR did.

@tend-agent tend-agent closed this Apr 19, 2026
max-sixty pushed a commit that referenced this pull request Apr 19, 2026
## 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 #313. Supersedes #314
([discussion](#314 (comment))).

## 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.

---------

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

2 participants