Skip to content

Improve safe-output helper test coverage - #75821

Merged
pelikhan merged 3 commits into
mainfrom
copilot/testify-expert-improve-test-quality
Nov 8, 2026
Merged

pelikhan merged 3 commits into
mainfrom
copilot/testify-expert-improve-test-quality

Conversation

Copilot AI commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Tests did not directly cover normalized, sorted JSON generation, and custom safe-output job cases were split across separate tests. The runtime checkout test was also located alongside unrelated config-helper tests.

  • Normalized JSON: Add table-driven cases for nil/empty names, normalization, duplicate keys, normalized callback values, sorted keys, and repeatability.
  • Custom jobs: Consolidate cases for nil/empty maps, a single uppercase/special-character name, and multiple sorted jobs; remove redundant unmarshalling assertions.
  • Test organization: Move TestUsesPatchesAndCheckouts to safe_outputs_runtime_test.go.

Example expected output for My.Custom-Job:

{"My_Custom_Job":""}

Copilot AI changed the title [WIP] Add high-value tests for buildNormalizedSortedJSON Improve safe-output helper test coverage Nov 8, 2026
Copilot AI requested a review from gh-aw-bot November 8, 2026 04:51
@pelikhan
pelikhan marked this pull request as ready for review November 8, 2026 06:06
Copilot AI adaptive review requested due to automatic review settings November 8, 2026 06:06
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from PR Specification Reviewer · gpt56 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.7K · ◷

Generated by PR Specification Reviewer for #75821

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: gpt56 max · ~1 AIC · ⌖ ~2 AIC · ⊞ 6.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

❌ Design Decision Gate 🏗️ failed to deliver outputs during design decision gate check.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #75821

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-08T06:12:00Z
review_event: COMMENT
top_themes: [test assertions that do not verify ordering, duplicate-key collision semantics]
files_reviewed: [pkg/workflow/safe_outputs_config_helpers_test.go, pkg/workflow/safe_outputs_runtime_test.go]
comment_count: 2

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Found two test-quality gaps; no production correctness issue identified.

Findings

Details
  • The sorting test uses assert.JSONEq, so it does not verify serialized key order.
  • The duplicate-normalization test does not distinguish which colliding value wins.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again

t.Run(tt.name, func(t *testing.T) {
jsonStr, err := buildNormalizedSortedJSON(tt.names, tt.valueFn)
require.NoError(t, err)
assert.JSONEq(t, tt.expected, jsonStr)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The sorting case does not actually verify sorted output because assert.JSONEq ignores object key order, and the repeatability check only compares two invocations.

💡 Verify the serialization order

Use an exact string assertion for this case (or explicitly compare key positions), so a regression that emits map order or otherwise unsorted keys is detected.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in f37eb1d9: the normalized JSON test now compares the exact serialized string, so sorted key order is covered.

CreatePullRequests: &CreatePullRequestsConfig{},
},
expected: false,
name: "collapses duplicate normalized names",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The duplicate-normalization case cannot detect which colliding value wins because the callback returns the same normalized name for both inputs.

💡 Make collision semantics observable

Use a stateful callback (for example, return distinct values on successive calls) and assert the documented/expected winner, so changes to duplicate handling do not silently pass.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in f37eb1d9: the callback returns distinct successive values for colliding normalized names, and the expected JSON verifies the second value wins.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Warning

The push_to_pull_request_branch operation failed: Cannot verify branch protection rules for "copilot/testify-expert-improve-test-quality": Resource not accessible by integration - https://docs.github.com/rest/branches/branch-protection\#get-branch-protection. Reading classic branch protection requires a GitHub App installation token or fine-grained PAT with Administration: read repository permission; GITHUB_TOKEN cannot provide this permission. Push blocked to prevent accidental writes to protected branches.. The code changes were not applied.

🏗️ Design Decision Gate — ADR Required

This PR exceeds the ADR volume threshold with 229 added lines under pkg/, but it does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/75821-improve-safe-output-helper-test-coverage.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch; it was generated from the PR diff and linked issue [testify-expert] Improve Test Quality: pkg/workflow/safe_outputs_config_helpers_test.go #75459.

  2. Complete the missing sections, refine the decision rationale, and confirm the alternatives and trade-offs.

  3. Commit any revisions to docs/adr/ on your branch.

  4. Reference the ADR in this PR body by adding:

    ADR: ADR-75821: Improve Safe-Output Helper Test Coverage (link unavailable: invalid HTTPS URL)

Once the ADR is linked in this PR body, this gate will re-run and verify the implementation matches the decision.

❓ Why ADRs Matter

ADRs create a searchable, permanent record of why the codebase looks the way it does and make significant decisions reviewable by future contributors.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What was decided and why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs, both positive and negative?

All ADRs are stored in docs/adr/ and numbered by PR number.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: gpt56 max · ~3 AIC · ⌖ ~2 AIC · ⊞ 7.7K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What this change does: This PR expands safe-output helper coverage with table-driven nil, normalization, duplicate-name, sorting, and custom-job cases. It also moves the runtime checkout test into its own test file.

Nice to have:

  1. Run each JSON case once (pkg/workflow/safe_outputs_config_helpers_test.go:L57-L61)

    • What this is: Every normalized-JSON row calls the helper twice and manually compares the two results.
    • Problem: The table already contains canonical JSON strings, so the second call and comparison branch add repeated test work.
    • Fix: Keep the first require.NoError and use assert.Equal(t, tt.expected, jsonStr); this checks the sorted bytes directly.
    • If we skip it: Each case retains an unnecessary second helper invocation and six lines of test code.

Verdict: fix 1 first.
Lean: -6 lines possible.

Generated by ✂️ Ponytail Reviewer for #75821 · codex · routed: gpt56 max · ~3 AIC · ⌖ ~1 AIC · ⊞ 118
Comment /ponytail to run again

require.NoError(t, err)
assert.JSONEq(t, tt.expected, jsonStr)

repeatedJSON, err := buildNormalizedSortedJSON(tt.names, tt.valueFn)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What this is: The table runs buildNormalizedSortedJSON twice for every case and adds a manual comparison. Problem: The table already stores canonical JSON strings, so the second call and error branch add repeated work and test plumbing without another input. Fix: Keep the first require.NoError and replace the JSON assertion plus repeat block with assert.Equal(t, tt.expected, jsonStr); that checks sorted bytes directly. If we skip it: Every case keeps an unnecessary second helper invocation and six lines of test code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in f37eb1d9: removed the repeated helper invocation and compare the expected canonical output exactly.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The tests use assert.JSONEq, which ignores object-member order, so the new sorted-key behavior remains unverified in both reported cases.

1 open issue
What changed in this PR

Improves test coverage and organization for safe-output JSON helpers and runtime checkout detection.

Changes:

  • Adds table-driven coverage for normalized, deduplicated, sorted, and repeatable JSON generation.
  • Consolidates custom safe-output job serialization cases, including empty configurations and name normalization.
  • Moves TestUsesPatchesAndCheckouts to the runtime-focused test file.
File Review
pkg/​workflow/​safe_outputs_config_helpers_test.go Adds normalized JSON and custom-job test cases. Moderate issue (4 votes): assert.JSONEq does not verify sorted key order at lines 55 and 119; compare compact output directly or otherwise assert raw ordering.
pkg/​workflow/​safe_outputs_runtime_test.go Houses checkout-detection tests alongside the runtime implementation.

Review effort: Lite (auto)

t.Run(tt.name, func(t *testing.T) {
jsonStr, err := buildNormalizedSortedJSON(tt.names, tt.valueFn)
require.NoError(t, err)
assert.JSONEq(t, tt.expected, jsonStr)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /tdd — requesting changes on two assertions that don't test what the PR description claims. No source bugs found; the three target tests pass and gofmt is clean.

📋 Key Themes & Highlights

Key Themes

  • Weak ordering assertions: assert.JSONEq is order-insensitive, so the sorts keys and multiple sorted jobs cases would still pass if sorting regressed. The PR says it covers sorted keys.
  • Verified: TestUsesPatchesAndCheckouts moved intact (17 cases); TestBuildNormalizedSortedJSON covers nil/empty, normalization, duplicate collapse, and repeatability; the My.Custom-Job → {"My_Custom_Job":""} example is exercised.

Positive Highlights

  • ✅ Table-driven consolidation removes the redundant unmarshalling assertions as intended.
  • ✅ Moving the runtime checkout test next to the code it covers improves navigability.

Verification

  • go test ./pkg/workflow/ -run 'TestUsesPatchesAndCheckouts|TestBuildNormalizedSortedJSON|TestBuildCustomSafeOutputJobsJSON' passes on b6e9d447.
  • A throwaway byte-exact probe confirmed the current output is sorted, so switching to assert.Equal should pass.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~3 AIC · ⌖ ~2 AIC · ⊞ 5.4K
Comment /matt to run again

t.Run(tt.name, func(t *testing.T) {
jsonStr, err := buildNormalizedSortedJSON(tt.names, tt.valueFn)
require.NoError(t, err)
assert.JSONEq(t, tt.expected, jsonStr)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/tdd] assert.JSONEq ignores key order, so the sorts keys case would still pass if the output order regressed. The expected strings are already in canonical order, so compare bytes exactly.

💡 Suggested change
assert.Equal(t, tt.expected, jsonStr)

A byte-exact check pins the sorted-keys behaviour the PR description claims to cover.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in f37eb1d9: the sorted-key case now compares the serialized JSON string exactly.

assert.Empty(t, jsonStr)
return
}
assert.JSONEq(t, tt.expected, jsonStr)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/tdd] Same gap in the multiple sorted jobs case: assert.JSONEq accepts any key order, so a sorting regression in buildCustomSafeOutputJobsJSON would not be caught. Use byte-exact assert.Equal here as well.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in f37eb1d9: multiple custom jobs now use an exact serialized JSON string assertion to verify key order.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (pkg/workflow/safe_outputs_config_helpers_test.go:55): The sorting case does not actually verify sorted output because assert.JSONEq ignores object key order, and the repeatability check only compares two invocations. - Improve safe-output helper test coverage #75821 (comment)
  3. Review (pkg/workflow/safe_outputs_config_helpers_test.go:38): The duplicate-normalization case cannot detect which colliding value wins because the callback returns the same normalized name for both inputs. - Improve safe-output helper test coverage #75821 (comment)
  4. Review (pkg/workflow/safe_outputs_config_helpers_test.go:57): What this is: The table runs buildNormalizedSortedJSON twice for every case and adds a manual comparison. Problem: The table already stores canonical JSON strings, so the second call and error branch add repeated work and test plumbing without another input. Fix: Keep the first require.NoError and replace the JSON assertion plus repeat block with assert.Equal(t, tt.expected, jsonStr); that checks sorted bytes directly. If we skip it: Every case keeps an unnecessary second helper invocation and six lines of test code. - Improve safe-output helper test coverage #75821 (comment)
  5. Review (pkg/workflow/safe_outputs_config_helpers_test.go:55): [/tdd] assert.JSONEq ignores key order, so the sorts keys case would still pass if the output order regressed. The expected strings are already in canonical order, so compare bytes exactly. - Improve safe-output helper test coverage #75821 (comment)
  6. Review (pkg/workflow/safe_outputs_config_helpers_test.go:119): [/tdd] Same gap in the multiple sorted jobs case: assert.JSONEq accepts any key order, so a sorting regression in buildCustomSafeOutputJobsJSON would not be caught. Use byte-exact assert.Equal here as well. - Improve safe-output helper test coverage #75821 (comment)
  7. Fix failing check safe_outputs (FAILURE): https://github.com/github/gh-aw/actions/runs/42453386098/job/128648405812.

Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI.

Sous-chef requested-head: b6e9d44
Sous-chef requested-work: 330211d562ef836a65db40453bd8444f58c413de2b49f206a9575618d1d41d42 36175cbe6f99ee40eaf5a449f02d401b717aa4d6214aa09551fce4e7d6ba916f 45940483b2e5998072adc393999eaad822684bfe63d9de9e52296508c5d5c583 5a79fe2033b8de3a86b7decec4bd8424655c38c7f85ad1ec7d2487aa34e9a7ec ac20939333bfeb3fefefd1d570e8db4281e6af267ed8f11fb2537cdd3ad239c8 c7cf93e497befdd5e698d00101b0703e4101fe4133d86d433f7c170d07402b7e
Sous-chef requested-state: 10e1d8a1501d7d9c18ba798a405c8c7409589eda7e0d14e5a22294fc017e8c3a

Generated by 👨🍳 PR Sous Chef · pi · haiku45 · ~12 AIC · ⌖ ~20 AIC · ⊞ 1.2K · ◷
Comment /souschef to run again

Copilot AI commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Copilot assignment requested for the following outstanding work:...

Starting the requested work: I’m merging the latest main, tightening the safe-output tests with byte-exact assertions and a collision-sensitive callback, then validating the focused package tests and replying to the assigned review threads.

Sous-chef requested-head: b6e9d44
Sous-chef requested-work: 330211d562ef836a65db40453bd8444f58c413de2b49f206a9575618d1d41d42 36175cbe6f99ee40eaf5a449f02d401b717aa4d6214aa09551fce4e7d6ba916f 45940483b2e5998072adc393999eaad822684bfe63d9de9e52296508c5d5c583 5a79fe2033b8de3a86b7decec4bd8424655c38c7f85ad1ec7d2487aa34e9a7ec ac20939333bfeb3fefefd1d570e8db4281e6af267ed8f11fb2537cdd3ad239c8 c7cf93e497befdd5e698d00101b0703e4101fe4133d86d433f7c170d07402b7e
Sous-chef requested-state: 10e1d8a1501d7d9c18ba798a405c8c7409589eda7e0d14e5a22294fc017e8c3a

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Triage

  • Category: test
  • Risk: low
  • Priority score: 35/100 (impact 14 + urgency 6 + quality 15)
  • Action: auto_merge
  • Reason: small, self-contained quality improvement with strong CI health and no functional risk.

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~7 AIC · ⌖ ~2 AIC · ⊞ 16K · ◷

@pelikhan
pelikhan merged commit b210376 into main Nov 8, 2026
92 checks passed
@pelikhan
pelikhan deleted the copilot/testify-expert-improve-test-quality branch November 8, 2026 16:20
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

PR triage: category=test | risk=low | total=35 | breakdown=impact 14, urgency 6, quality 15 | action=auto_merge | batch=pr-batch:quality-copilot

Generated by 🔧 PR Triage Agent · copilot · mai11 · ~3 AIC · ⌖ ~2 AIC · ⊞ 15.1K · ◷

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[testify-expert] Improve Test Quality: pkg/workflow/safe_outputs_config_helpers_test.go

4 participants