Skip to content

Add a Caller pre-test Hook That Runs Before the .NET Unit Tests - #4269

Merged
ptr727 merged 3 commits into
developfrom
feature/pre-test-hook-4265
Nov 18, 2026
Merged

ptr727 merged 3 commits into
developfrom
feature/pre-test-hook-4265

Conversation

@ptr727

@ptr727 ptr727 commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #4265.

A .NET caller of validate-task.yml had no step of its own before its unit tests. A test that shells out to a system tool, such as exiftool or ffmpeg, therefore skipped or failed in CI. install-test-deps runs per Python leg after the .NET tests, and the validate hook runs in another job on another runner.

Each unit-test leg now runs a new opt-in caller hook, .github/actions/pre-test, before Setup .NET SDK step. It runs where a .NET test project (**/*Tests*.csproj) exists and the caller carries the hook. It takes no inputs and reports nothing back. A caller without the hook is unaffected, since the step skips, the same pattern the install-test-deps step relies on. install-test-deps keeps its own contract. The maintainer chose this shape on 2026-11-18.

docs/reusable-workflows.md documents the hook in "The Hook Contract" and the hooks table. It also states that every task finds a hook by its action.yml alone, the one name each hub task's gate reads.

Verification

  • tests/test_release_guards.py gains test_validator_pre_test_hook_runs_before_the_dotnet_tests. It asserts the order (checkout, pre-test hook, .NET SDK setup, unit tests) and the step's exact gate and uses:. 42 tests OK.
  • actionlint through scripts/docker_lint.py, ruff, and the prose gate pass.
  • The hub's own CI is unaffected, since the hub tracks no *Tests*.csproj and carries no pre-test hook.
  • End-to-end proof needs a caller. Once this is released, Run the Media Tests in CI With exiftool and ffmpeg Installed PhotoCleaner#277 adds .github/actions/pre-test/action.yml and bumps its pin.

Local passes

Three recorded passes.

  • First pass: the step read only action.yml, while GitHub also runs action.yaml. Fixed in ac0ba80 by checking both names here and at the install-test-deps check.
  • Second pass: every other hub task gate reads action.yml alone, so that per-site fix left validate-task.yml inconsistent. No fleet repository carries an action.yaml hook, so 7c04aac reverts ac0ba80 and documents the one name instead.
  • Third pass: clean.

The comments label covers the new step's one comment line, which states why the hook runs before the SDK setup.

🤖 Generated with Claude Code

ptr727 and others added 3 commits November 18, 2026 14:27
A .NET caller of validate-task.yml had no step of its own before its unit
tests, so a test that shells out to a system tool such as exiftool or ffmpeg
skipped or failed in CI. The install-test-deps hook runs per Python leg after
the .NET tests, and the validate hook runs in another job on another runner.

Each unit-test leg now runs the caller's .github/actions/pre-test composite
action before the .NET SDK setup, where a .NET test project exists and the
caller carries the hook. It takes no inputs and reports nothing back, and a
caller without it is unaffected. install-test-deps keeps its own contract.

Closes #4265

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GitHub runs a local action from action.yml or action.yaml, so the pre-test
step and the install-test-deps check each look for both. A caller whose hook
was action.yaml had its pre-test step skipped, or a false missing-hook error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every hub task gate reads a caller hook as action.yml, and no fleet repository
carries an action.yaml hook, so the two-name check is reverted for consistency
and the hook contract states the one name instead.

This reverts commit ac0ba80.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings November 18, 2026 22:31
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 50 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4e956a7 and 7c04aac.

Files selected for processing: 3

  • .github/workflows/validate-task.yml
  • docs/reusable-workflows.md
  • tests/test_release_guards.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Nov 18, 2026
@ptr727

ptr727 commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 7c04aac4c3050bce084a50f795eae1431f31d7e1, the content this pull request carries at that commit against develop, and it recorded 0 findings.

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.

🔵 Needs a closer look

Defer until a downstream .NET caller exercises the reusable workflow and confirms the local composite action installs the required system tool before tests, since this hub cannot verify that end-to-end behavior.

No open issues 🎉

What changed in this PR

Adds an optional caller-owned pre-test hook to reusable validation so .NET callers can install system tools before SDK setup and unit tests.

Changes:

  • Runs the pre-test hook when .NET test projects and the caller hook are present.
  • Documents the hook contract and action.yml discovery rule.
  • Adds regression coverage for the hook's gate and execution order.
File Description
tests/​test_release_guards.py Adds regression coverage verifying the pre-test hook's exact gate and placement before .NET setup and unit tests.
docs/​reusable-workflows.md Documents the pre-test hook contract, discovery rule, behavior, and hook catalog entry.
.github/​workflows/​validate-task.yml Runs the optional caller pre-test hook before .NET SDK setup and unit tests when applicable.

Review effort: Lite

@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.46%. Comparing base (b38e084) to head (7c04aac).
⚠️ Report is 243 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4269      +/-   ##
===========================================
- Coverage    81.60%   78.46%   -3.15%     
===========================================
  Files           26       42      +16     
  Lines         9070    15434    +6364     
===========================================
+ Hits          7402    12110    +4708     
- Misses        1668     3324    +1656     
Flag Coverage Δ
python-3.13 78.46% <ø> (-3.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727

ptr727 commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ptr727

ptr727 commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Answering the Copilot round on 7c04aac (#4269 (review)), whose headline counts no finding (0) and reads: "Defer until a downstream .NET caller exercises the reusable workflow and confirms the local composite action installs the required system tool before tests, since this hub cannot verify that end-to-end behavior."

No change needed. The hub tracks no *Tests*.csproj and carries no pre-test hook, so its own CI cannot run the step end to end, and that proof cannot block this merge. What the hub can check, it does: test_validator_pre_test_hook_runs_before_the_dotnet_tests asserts the step's position, gate and uses:, actionlint passes, and the skip for a caller without the hook is the same pattern the install-test-deps step already relies on. The downstream proof is named in the body under Verification: once released, ptr727/PhotoCleaner#277 adds .github/actions/pre-test/action.yml and bumps its pin, and its media tests then run in CI.

@ptr727
ptr727 merged commit c0bc6d6 into develop Nov 18, 2026
14 checks passed
@ptr727
ptr727 deleted the feature/pre-test-hook-4265 branch November 18, 2026 22:45
ptr727 added a commit that referenced this pull request Nov 18, 2026
…a pre-test Hook (#4270)

## Summary

Promotes three changes from develop to main:

- #4267: every ruff call that can reach a downstream repository's root
`hub_fetch_run.py` passes `--extend-exclude ./hub_fetch_run.py
--force-exclude`. That covers the hook snippets, the Python VS Code
tasks, `validate-task.yml`, the `pypi-build-default` action and the
`python-codestyle` skill. No repository adds the helper to its own ruff
config.
- #4268: each npm install the agent installers run passes
`--allow-scripts=<pkg>` for the one package it installs. npm 12
otherwise skips the package's `postinstall`, which leaves opencode
unable to start while the step reports clean.
- #4269: a new opt-in caller hook, `.github/actions/pre-test`, runs in
each `unit-test` leg before the .NET SDK setup, where a .NET test
project exists and the caller carries the hook. ptr727/PhotoCleaner#277
is waiting on it.

## Open after release

- **Native Windows check of #4268.** On a Windows host with an npm-owned
opencode, run `host-setup\windows\install-agents.ps1 -Upgrade -DryRun
opencode`. Expect `npm install -g --allow-scripts=@opencode/cli
@opencode/cli@latest`. Then run `-Upgrade opencode`, and expect
`opencode --version` to answer with no `install-scripts` warning. Linux
was verified natively, and the flag was measured against the real
package on npm 9 through 12.
- **Downstream proof of #4269.** ptr727/PhotoCleaner#277 adds the hook
and bumps its pin once this is released.

Closes #4263
Closes #4264
Closes #4265

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants