Skip to content

Delete stale HTML/ copy — HTMLTemplates.swift is the template source of truth (#434) - #452

Merged
tylervick merged 2 commits into
mainfrom
tylervick/template-source-of-truth-434
Aug 13, 2026
Merged

tylervick merged 2 commits into
mainfrom
tylervick/template-source-of-truth-434

Conversation

@tylervick

@tylervick tylervick commented Aug 13, 2026

Copy link
Copy Markdown
Member

Fixes #434.

Of the three options in #434, this takes option 1 — delete the stale HTML/ copy (Tyler's call): smallest change, makes HTMLTemplates.swift honestly the single source of truth, and removes the trap before the 4.0 report redesign (#439) starts from the wrong file.

What changed

  • Deleted Sources/XCTestHTMLReportCore/HTML/ (12 files). It was excluded from the build (Package.swift exclude: ["HTML"]), 28 diff hunks behind the compiled templates, and last touched in 2024 (Lazy load video and everything else #350) — one day before Support mixed children test types in test suites #349 hand-edited the "generated" file it supposedly generated. Verified nothing references it: the only build-level reference was the Package.swift exclude entry itself, now removed. All other repo matches for the filenames are coincidental (the report's output index.html, the text/html MIME type, comments naming templates conceptually).
  • Rewrote the stale header in HTMLTemplates.swift. It claimed DO NOT EDIT! This file is autogenerated by createTemplates.sh, but that script was deleted in remove ruby & thor tasks #295 and nothing has regenerated the file since. The header now states what is true: this file is the hand-maintained source of truth for the report's markup, styles, and scripts, and is edited directly.
  • Fixed .githooks/pre-commit so the SwiftLint exemption actually holds at commit time. The hook passes staged paths to SwiftLint explicitly, and SwiftLint ignores the config's excluded: list for explicitly passed paths unless given --force-exclude. Nobody had staged an edit to HTMLTemplates.swift since the hook existed, so this never fired — this PR's header edit was the first, and the hook failed with 15 line_length errors (2.5k–107k-char lines), file_length, and type_body_length, all on lines the config exempts. One flag (--force-exclude) brings the hook in line with CI, which lints from the repo root and has always honored the exclusion. And because SwiftLint exits nonzero with No lintable files found when every staged Swift file is excluded — exactly the template-only commits this PR unblocks; caught in review — the hook treats that specific outcome as success: zero lintable files means zero possible violations, so it cannot mask a real failure. Any other nonzero exit still fails the hook. The hook's comment claiming SwiftLint applies config exclusions to explicit paths was corrected too.
  • Zero rendered-output change. The only edit to HTMLTemplates.swift is the two-line header comment; no template string changes.

The two lint exemptions: KEEP, with corrected justifications

Both .swiftformat and .swiftlint.yml exempted HTMLTemplates.swift on the premise that it is generated. That premise is false, so each exemption was re-decided on its actual merits:

.swiftformat — KEEP. Dry-running SwiftFormat on the file with the exclusion removed rewrites ~2,300 lines (2,293 with SwiftFormat 0.62.1; the exact count is SwiftFormat-version-dependent): it re-indents every multiline string literal body from the file's 2-space base to the repo's 4-space style, moves the closing """ delimiters (which changes how much leading whitespace Swift strips — i.e. potentially the bytes of every rendered report), and converts struct HTMLTemplates to an enum. The existing comment's technical rationale was already correct; only its "generated" premise sentence was wrong. The comment now leads with "hand-maintained".

.swiftlint.yml — KEEP. With the exclusion removed, 15 lines exceed the line_length error threshold (200 chars) — long embedded HTML lines that no formatter can wrap — plus file_length (1226 lines) and type_body_length (1206 lines) violations that are intrinsic to a file of embedded templates. The alternatives (inline swiftlint:disable annotations scattered through template strings, or raising repo-wide thresholds) are both worse than one config exclusion. The comment now states the real reason instead of "Generated (carries a DO NOT EDIT header)".

Docs check

docs/superpowers/specs/2026-08-10-xcresulttool-legacy-migration-design.md and docs/superpowers/plans/2026-08-10-xcresulttool-legacy-migration.md mention the stale copy — as dated design records describing the problem and stating the source-of-truth question "must first settle" before the redesign. This PR is that settlement; the records stay accurate as history and need no edits.

Verification

  • swift build green with the directory deleted and the exclude entry removed.
  • Full test suite: 100 tests, 2 skipped, 0 failures, fixtures regenerated via ./prepareTestResults.sh. Re-ran the output-sensitive suites explicitly: DifferentialTests 6/6, ReproducibilityTests 7/7 — zero rendered-output change confirmed.
  • swiftformat --lint .: 0/71 files require formatting. swiftlint: exit 0 (pre-existing warnings only).
  • .githooks/pre-commit verified in both directions in a scratch worktree: only HTMLTemplates.swift staged (whitespace edit) → exit 0; a Swift file with a deliberate 259-char line staged → exit 1 with the violation reported (also exit 1 when staged alongside HTMLTemplates.swift, so the excluded file cannot shield others); only a non-Swift file staged → exit 0. shellcheck on the edited hook: clean.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements
    • Consolidated HTML report templates into a single maintained source while preserving report formatting and supported report details.
    • Continued support for activities, devices, attachments, screenshots, iterations, test groups, summaries, and test results in generated reports.
  • Maintenance
    • Improved staged Swift linting to respect configured exclusions and handle projects without lintable files.
    • Clarified template editing and formatting guidance for contributors.

…f truth (#434)

Tyler's ruling on #434: option 1 — delete the stale copy. The HTML/
directory was excluded from the build, 28 diff hunks behind the compiled
templates, and last touched (#350) one day before #349 hand-edited the
"generated" file it supposedly generated.

- Delete Sources/XCTestHTMLReportCore/HTML/ and the Package.swift exclude.
- Replace the false DO NOT EDIT header (createTemplates.sh was deleted in
  #295) with one declaring the file the hand-maintained source of truth.
- Keep both lint exemptions with corrected justifications (see PR).
- Fix .githooks/pre-commit: SwiftLint ignores the config excluded: list
  for explicitly passed paths, so the first-ever staged edit to
  HTMLTemplates.swift failed the hook on rules the config exempts; add
  --force-exclude to match CI behavior.

Zero rendered-output change: only the header comment changed in
HTMLTemplates.swift. Full suite 100/100 (2 pre-existing skips), incl.
DifferentialTests 6/6 and ReproducibilityTests 7/7.

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 013bd867-2502-4de5-854d-1de7dc94f2d4

📥 Commits

Reviewing files that changed from the base of the PR and between 5b150fb and ad77e0d.

📒 Files selected for processing (1)
  • .githooks/pre-commit
🚧 Files skipped from review as they are similar to previous changes (1)
  • .githooks/pre-commit

📝 Walkthrough

Walkthrough

The PR removes standalone HTML template resources, keeps template markup in HTMLTemplates.swift, updates maintenance comments, and changes staged-file SwiftLint handling.

Changes

Template source consolidation

Layer / File(s) Summary
Template packaging and source documentation
Package.swift, Sources/XCTestHTMLReportCore/Classes/HTMLTemplates.swift, Sources/XCTestHTMLReportCore/HTML/*
The package stops excluding the HTML directory. Standalone HTML templates are removed. HTMLTemplates.swift is documented as the maintained source of truth.
Lint maintenance configuration
.githooks/pre-commit, .swiftformat, .swiftlint.yml
The pre-commit hook applies configured SwiftLint exclusions to staged Swift paths, reports lint output, and accepts the “No lintable files found” result. Formatter and linter comments describe the hand-maintained HTML template.

Estimated code review effort: 2 (Simple) | ~10 minutes

Mergeability Score: ⚪ Minimal · up to ad77e

The PR removes an unused stale template copy, corrects documentation and commit-hook behavior, and reports no rendered-output change; no actionable merge-blocking risk remains after normal checks and review.

Possibly related issues

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: deleting the stale HTML directory and establishing HTMLTemplates.swift as the source of truth.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tylervick/template-source-of-truth-434

Comment @coderabbitai help to get the list of available commands.

… fix)

When HTMLTemplates.swift is the only staged Swift file, --force-exclude
leaves SwiftLint zero lintable paths and it exits 1 with "No lintable
files found", so the hook still blocked exactly the template-only
commits #434 set out to unblock. Treat that specific outcome as success:
zero lintable files means zero possible violations, so it cannot mask a
real lint failure. Any other nonzero exit still fails the hook.

Verified in a scratch worktree: HTMLTemplates.swift-only staging exits 0;
a staged 259-char-line Swift file still fails (alone and alongside the
excluded file); non-Swift-only staging exits 0. shellcheck clean.

Co-Authored-By: Claude Fable 5 <[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.

HTMLTemplates.swift claims to be generated, but the generator was deleted in #295

1 participant