GitHub Action: redline the .docx files a PR changes#27
Open
JSv4 wants to merge 2 commits into
Open
Conversation
… files Closes #12. 'uses: JSv4/Python-Redlines@<ref>' now redlines every .docx a pull request (or push) changes, or an explicit original/modified pair, and surfaces the results where reviewers look: - action.yml — composite action: installs python-redlines from PyPI (prebuilt engine wheels, no .NET build), runs the driver, uploads the output dir as a workflow artifact, and links it from the job summary. Inputs cover file globs, base/head refs, author, engine (docxodus/xmlpowertools), comparison algorithm (wmlcomparer/docxdiff), move detection, and output/artifact knobs. - action/redline_changed.py — stdlib-only driver. Auto-detect mode resolves the comparison window from the triggering event (PR base/head with merge-base semantics, push before/after, or HEAD~1..HEAD), diffs with rename detection, extracts both sides from git (no dependence on checkout state), and writes <output-dir>/<path>/<name>.redline.docx with native Word tracked changes. Added/deleted files are reported but not redlined; pure renames skip the engine. Per-file failures are reported and fail the run after processing everything. Emits count/any-changes/redlines outputs and a job-summary table. - HTML previews: html-preview: auto|true|false renders each redline to browser-viewable HTML via the Docxodus Docx2Html dotnet tool's new --track-changes mode (Docxodus >= 7.1.0); 'auto' skips with a warning when the installed tool lacks support. - tests/test_action_script.py — 28 tests: input validation, name-status parsing, ref resolution (push/PR/merge-base/new-branch), pathspec filtering, output-path safety for absolute sources, plus two integration tests running the real engine over the repo fixtures. - .github/workflows/redline-action-test.yml — self-test running the action from the checkout in both modes and asserting on its outputs. - README.md / CLAUDE.md — usage and maintenance docs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0142X9VTMpdo639kHKQa4PE1
Path.is_absolute() is False on Windows for a rooted-but-driveless path like '/x/y', yet joining it onto output_dir still replaces the whole prefix, so the escape guard never fired (caught by the new unit test on the windows-latest CI matrix). Guard on drive/root/'..' components as well, and cover '..' traversal in the test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0142X9VTMpdo639kHKQa4PE1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #12.
This makes the repository usable directly as a GitHub Action, per the design discussed on the issue (inspired by vanbroup/build-guidelines-action): explicit file-pair configuration, an
authorinput for the tracked changes, plus an auto-detect mode that redlines every.docxa pull request changes.Minimal usage
For each
.docxthe PR modifies (or renames), the action extracts the base and head versions from git, runs the redline engine, writesredlines/<path>/<name>.redline.docxwith native Word tracked changes, uploads the lot as a workflow artifact, and posts a job-summary table (file → revision count → outputs). Explicit-pair mode (original:+modified:inputs) covers the "just compare these two files" case from the issue thread.What's in the change
action.yml— composite action. Installspython-redlines[docxodus|ooxmlpowertools]from PyPI (prebuilt engine wheels — nothing compiles at run time), runs the driver, uploads the artifact, links it from the summary. Inputs:filesglobs,base-ref/head-ref,author,engine,comparison(wmlcomparer/docxdiff),detect-moves,output-dir,html-preview,summary,upload-artifact/artifact-name, and version pins for the pip package and preview tool. Outputs:count,any-changes,redlines(JSON records),artifact-url.action/redline_changed.py— stdlib-only driver. Resolves the comparison window from the triggering event: PR base/head with merge-base semantics (matches the PR "files changed" view; falls back with a warning on shallow clones), pushbefore/after(with a parent-commit fallback for new branches), orHEAD~1..HEAD; missing commits are fetched by SHA. Diffs with rename detection and case-insensitive glob pathspecs, reads both sides out of git (independent of checkout state — important on PR merge commits), and reports added/deleted files without redlining them (no counterpart to compare). Pure renames skip the engine. A per-file engine failure is reported and fails the run only after every file is processed.html-preview: auto|true|falserenders each redline to browser-viewable HTML (ins/del/move markup) via the DocxodusDocx2Htmldotnet tool's new--track-changesmode, added in the companion PR docx2html: add --track-changes and story rendering flags Docxodus#269. Until that ships in a Docxodus release (≥ 7.1.0 on NuGet), the defaultautomode detects the missing capability and skips with a warning instead of producing a misleading "all changes accepted" preview;truemakes it a hard requirement;falseskips the .NET setup entirely.tests/test_action_script.py(28 tests): input validation,--name-status -zparsing, ref resolution across event shapes, pathspec filtering, output-path safety for absolute sources (caught a real bug where an absolutemodified:path escapedoutput-dir), and two integration tests running the real engine over the repo fixtures (9 revisions, matching the documented fixture count)..github/workflows/redline-action-test.ymlruns the action from the checkout in both modes and asserts on outputs; the auto-detect job builds a synthetic two-commit docx history in the runner's clone.Verification
python -m pytest tests/— 68 passed (40 existing + 28 new).python-redlines==0.3.0wheels: auto-detect over a scratch repo (modified + added + deleted docx classified correctly, 9 revisions) and explicit-pair with a locally-builtdocx2html --track-changesproducing an HTML preview with 11ins/delelements.🤖 Generated with Claude Code
https://claude.ai/code/session_0142X9VTMpdo639kHKQa4PE1
Generated by Claude Code