ci(build): select Windows pull request tests from the test graph of main #15153

Closed
starlord-93 wants to merge 1 commit from upstream-pr/15153 into main
starlord-93 commented 2026-11-02 18:58:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by starlord-93 on 2026-11-02T18:58:31Z.


What

The Windows pull request job restores test-graph.json (the graph that push builds of main save) on pull requests, not only for select runs. tools/build_mingw_host_only_tests.py and tools/build_changed_guest_tests.py take --graph: a changed core/libs header or library CMakeLists.txt selects only the tests whose graph scope includes it (select_tests.select), plus tests whose own sources changed.

Every test is still selected when the graph is missing or invalid, when a changed header is not in the graph, when select_tests.py treats a path as build-wide (core/libs/CMakeLists.txt, cmake/, 3rdparty/ and the others in FULL), and when the root CMakeLists.txt, build.yml, either script or select_tests.py changes. select_tests.py is added to both scripts' build-wide sets because the selection now depends on it. The job timeout, push builds and production-source-only changes are unchanged.

Conflicts with #12159, #14315, #14317 and #14414 in the build-wide blocks of the two scripts; each of them merges cleanly with main. If one merges first, I rebase this.

Tested

Linux, Python 3.13: python3 -m unittest tools/tests/test_build_changed_guest_tests.py tools/tests/test_mingw_host_only_test_targets.py tools/tests/test_select_tests.py passes (106 tests, 3 skipped), including 12 new tests for graph narrowing, the fallbacks, case-insensitive executable matching and the workflow steps. The full tools/tests suite has the same 3 failures on main and on this branch (test_patch_lib_atrac9 x2, test_run_report_schema pinned validator). Not tested on a Windows runner: this pull request's own Windows job selects every test because it changes build.yml and the scripts.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: Fixes #15049
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5125764474 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15153). Originally posted by [starlord-93](https://github.com/starlord-93) on 2026-11-02T18:58:31Z. --- ### What The Windows pull request job restores `test-graph.json` (the graph that push builds of main save) on pull requests, not only for `select` runs. `tools/build_mingw_host_only_tests.py` and `tools/build_changed_guest_tests.py` take `--graph`: a changed `core/libs` header or library `CMakeLists.txt` selects only the tests whose graph scope includes it (`select_tests.select`), plus tests whose own sources changed. Every test is still selected when the graph is missing or invalid, when a changed header is not in the graph, when `select_tests.py` treats a path as build-wide (`core/libs/CMakeLists.txt`, `cmake/`, `3rdparty/` and the others in `FULL`), and when the root `CMakeLists.txt`, `build.yml`, either script or `select_tests.py` changes. `select_tests.py` is added to both scripts' build-wide sets because the selection now depends on it. The job timeout, push builds and production-source-only changes are unchanged. Conflicts with #12159, #14315, #14317 and #14414 in the build-wide blocks of the two scripts; each of them merges cleanly with main. If one merges first, I rebase this. ### Tested Linux, Python 3.13: `python3 -m unittest tools/tests/test_build_changed_guest_tests.py tools/tests/test_mingw_host_only_test_targets.py tools/tests/test_select_tests.py` passes (106 tests, 3 skipped), including 12 new tests for graph narrowing, the fallbacks, case-insensitive executable matching and the workflow steps. The full `tools/tests` suite has the same 3 failures on main and on this branch (`test_patch_lib_atrac9` x2, `test_run_report_schema` pinned validator). Not tested on a Windows runner: this pull request's own Windows job selects every test because it changes `build.yml` and the scripts. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: Fixes #15049 - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-02 19:10:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T19:10:44Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The PR can restore a valid test graph from an older main commit and use it to omit tests added since that graph was generated.

What I ran

Reviewed all five changed files at head ce73562ac71a11c13879e78bf6fa43a10af9f82c, against PR base a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8. The head merges cleanly against that current main preview. Environment: Debian 12, Linux 6.1, Python 3.11.2, Git 2.39.5; no compiler or build was run.

git diff --check a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8...ce73562ac71a11c13879e78bf6fa43a10af9f82c
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 15153 --output-dir /tmp/anyps5-pr-precheck-15153
git worktree add --detach /tmp/AnyPS5-review-15153 refs/review/15153/head
cd /tmp/AnyPS5-review-15153
python3 -m unittest tools/tests/test_build_changed_guest_tests.py tools/tests/test_mingw_host_only_test_targets.py tools/tests/test_select_tests.py
python3 tools/pr_stack_check.py 15153 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck-15153/stack
python3 tools/pr_overlap.py --branch refs/review/15153/head --repo boykopovar/AnyPS5 --jobs 8
gh pr checks 15153 --repo boykopovar/AnyPS5

The focused Python tests ran against the exact PR head. The precheck ran syntax, registration and two related unit-test suites as well.

Results

Check Result Note
Diff, conventions and Python syntax passed Exact PR head and base.
Focused Python tests passed 106 tests; 3 skipped.
Test registration passed Script tests are registered.
Current-main merge preview passed Exact head merges cleanly.
Test-graph freshness failed A valid prior graph is not tied to the current base SHA.
Overlap helper failed Parser error; exact pairwise merge previews with the four named PRs were clean.
Hosted checks not run Conventions and intake passed; labels were pending. No Windows run was available.
Build and C++ tests not applicable This change is Python and workflow code.
Commands and unedited outputs

Focused Python suite:

Ran 106 tests in 7.326s

OK (skipped=3)

Conventions output from the precheck:

All conventions checks passed.

The precheck's optional helpers were absent from its isolated PR checkout:

/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck-15153/head-ce73562ac71a-1baefdab/tools/pr_test_quality.py': [Errno 2] No such file or directory

The same precheck's base-source negative-control attempt could not run the new tests against the old helper signature:

TypeError: guest_test_targets() takes from 2 to 3 positional arguments but 4 were given

Synthetic stale-graph probe (run from the repository root):

python3 - <<'PY'
from pathlib import Path
import json, sys, tempfile
sys.path.insert(0, "tools")
import build_mingw_host_only_tests as runner
changed = {"core/libs/prx/libFoo/include/Foo.hpp"}
graph_data = {"tests": {"old_test": {"target": "core/libs/old_target.exe", "registered": [], "arguments": [], "sets": [], "requires": [], "depends": []}}, "closures": {"core/libs/old_target.exe": ["core/libs/prx/libFoo/include/Foo.hpp"]}}
targets = {"old": {"name": "old_target", "artifacts": [{"path": "core/libs/old_target.exe"}], "sources": []}, "new": {"name": "new_target", "artifacts": [{"path": "core/libs/new_target.exe"}], "sources": [{"path": "core/libs/tests/NewTest.cpp"}]}}
with tempfile.TemporaryDirectory() as directory:
    graph = Path(directory) / "graph.json"
    graph.write_text(json.dumps(graph_data))
    print(sorted(runner.narrow_broad_change(["new_target", "old_target"], runner.BROAD_CHANGES, Path.cwd(), targets, changed, graph)))
    print(sorted(runner.narrow_broad_change(["new_target", "old_target"], runner.BROAD_CHANGES, Path.cwd(), targets, changed, None)))
PY
['old_target']
['new_target', 'old_target']

Overlap helper output:

pr_overlap: Invalid \\uXXXX escape: line 1 column 655256 (char 655255)

Hosted status snapshot:

conventions\tpass\t20s
intake\tpass\t23s
labels\tpending\t0

Negative control

Assertion Change to code under test Did the new test fail?
A graph from the exact main base is required before narrowing the current test set. No mutation. I supplied a structurally valid graph that lacked a target present in the current target list; the selector returned only the old graph's target. Not exercised by the PR's tests; no stale-but-valid-graph case is present.

Findings

Blocking

  • The Windows job restores by the exact base-SHA cache key and also supplies the prefix fallback test-graph-Windows-. If the exact cache is missing, the fallback can provide a graph generated by an earlier main. select_tests.load_graph validates the JSON shape but records or checks no source commit. The new selector then accepts that graph whenever the changed header is present in its old closures. A test target added to current main after graph generation is absent from those closures and can be skipped. I reproduced the selection using a valid old graph: the current target set contained old_target and new_target, but the selector chose only old_target; with no graph it chose both.

    Remove prefix-cache fallback for PR test selection so a missing exact graph triggers the existing full-selection fallback, or store and verify the graph's source SHA against the current base SHA. Add a regression test for a valid but stale graph.

Non-blocking

  • The PR lists overlap with #12159, #14315, #14317 and #14414. Those live heads each merge cleanly with this head in pairwise previews; the repository overlap helper could not complete, so its automated overlap report remains unavailable.

Sources

Not verified

  • I did not run a Windows workflow or local Windows build. The Linux C++/Python full suite's three failures described in the PR were not reproduced; they are author-reported as also occurring on main.
  • The precheck's negative-control run is not evidence that the new assertions fail against the bug; the base checkout predates the changed helper signature.
  • pr_overlap.py could not complete its repository-wide scan.

To get this to a good state

Bind the graph to the exact main SHA or use only the exact cache key for PR selection, and test that an older valid graph falls back to all current targets. I will rerun the same precheck and focused Python suite on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5741926952 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15153#pullrequestreview-5741926952). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T19:10:44Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The PR can restore a valid test graph from an older `main` commit and use it to omit tests added since that graph was generated. ## What I ran Reviewed all five changed files at head `ce73562ac71a11c13879e78bf6fa43a10af9f82c`, against PR base `a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8`. The head merges cleanly against that current `main` preview. Environment: Debian 12, Linux 6.1, Python 3.11.2, Git 2.39.5; no compiler or build was run. ```sh git diff --check a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8...ce73562ac71a11c13879e78bf6fa43a10af9f82c python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 15153 --output-dir /tmp/anyps5-pr-precheck-15153 git worktree add --detach /tmp/AnyPS5-review-15153 refs/review/15153/head cd /tmp/AnyPS5-review-15153 python3 -m unittest tools/tests/test_build_changed_guest_tests.py tools/tests/test_mingw_host_only_test_targets.py tools/tests/test_select_tests.py python3 tools/pr_stack_check.py 15153 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck-15153/stack python3 tools/pr_overlap.py --branch refs/review/15153/head --repo boykopovar/AnyPS5 --jobs 8 gh pr checks 15153 --repo boykopovar/AnyPS5 ``` The focused Python tests ran against the exact PR head. The precheck ran syntax, registration and two related unit-test suites as well. ## Results | Check | Result | Note | |---|---|---| | Diff, conventions and Python syntax | passed | Exact PR head and base. | | Focused Python tests | passed | 106 tests; 3 skipped. | | Test registration | passed | Script tests are registered. | | Current-main merge preview | passed | Exact head merges cleanly. | | Test-graph freshness | failed | A valid prior graph is not tied to the current base SHA. | | Overlap helper | failed | Parser error; exact pairwise merge previews with the four named PRs were clean. | | Hosted checks | not run | Conventions and intake passed; labels were pending. No Windows run was available. | | Build and C++ tests | not applicable | This change is Python and workflow code. | <details> <summary>Commands and unedited outputs</summary> Focused Python suite: ```text Ran 106 tests in 7.326s OK (skipped=3) ``` Conventions output from the precheck: ```text All conventions checks passed. ``` The precheck's optional helpers were absent from its isolated PR checkout: ```text /usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck-15153/head-ce73562ac71a-1baefdab/tools/pr_test_quality.py': [Errno 2] No such file or directory ``` The same precheck's base-source negative-control attempt could not run the new tests against the old helper signature: ```text TypeError: guest_test_targets() takes from 2 to 3 positional arguments but 4 were given ``` Synthetic stale-graph probe (run from the repository root): ```sh python3 - <<'PY' from pathlib import Path import json, sys, tempfile sys.path.insert(0, "tools") import build_mingw_host_only_tests as runner changed = {"core/libs/prx/libFoo/include/Foo.hpp"} graph_data = {"tests": {"old_test": {"target": "core/libs/old_target.exe", "registered": [], "arguments": [], "sets": [], "requires": [], "depends": []}}, "closures": {"core/libs/old_target.exe": ["core/libs/prx/libFoo/include/Foo.hpp"]}} targets = {"old": {"name": "old_target", "artifacts": [{"path": "core/libs/old_target.exe"}], "sources": []}, "new": {"name": "new_target", "artifacts": [{"path": "core/libs/new_target.exe"}], "sources": [{"path": "core/libs/tests/NewTest.cpp"}]}} with tempfile.TemporaryDirectory() as directory: graph = Path(directory) / "graph.json" graph.write_text(json.dumps(graph_data)) print(sorted(runner.narrow_broad_change(["new_target", "old_target"], runner.BROAD_CHANGES, Path.cwd(), targets, changed, graph))) print(sorted(runner.narrow_broad_change(["new_target", "old_target"], runner.BROAD_CHANGES, Path.cwd(), targets, changed, None))) PY ``` ```text ['old_target'] ['new_target', 'old_target'] ``` Overlap helper output: ```text pr_overlap: Invalid \\uXXXX escape: line 1 column 655256 (char 655255) ``` Hosted status snapshot: ```text conventions\tpass\t20s intake\tpass\t23s labels\tpending\t0 ``` </details> ## Negative control | Assertion | Change to code under test | Did the new test fail? | |---|---|---| | A graph from the exact `main` base is required before narrowing the current test set. | No mutation. I supplied a structurally valid graph that lacked a target present in the current target list; the selector returned only the old graph's target. | Not exercised by the PR's tests; no stale-but-valid-graph case is present. | ## Findings ### Blocking - The Windows job restores by the exact base-SHA cache key and also supplies the prefix fallback `test-graph-Windows-`. If the exact cache is missing, the fallback can provide a graph generated by an earlier `main`. `select_tests.load_graph` validates the JSON shape but records or checks no source commit. The new selector then accepts that graph whenever the changed header is present in its old closures. A test target added to current `main` after graph generation is absent from those closures and can be skipped. I reproduced the selection using a valid old graph: the current target set contained `old_target` and `new_target`, but the selector chose only `old_target`; with no graph it chose both. Remove prefix-cache fallback for PR test selection so a missing exact graph triggers the existing full-selection fallback, or store and verify the graph's source SHA against the current base SHA. Add a regression test for a valid but stale graph. ### Non-blocking - The PR lists overlap with #12159, #14315, #14317 and #14414. Those live heads each merge cleanly with this head in pairwise previews; the repository overlap helper could not complete, so its automated overlap report remains unavailable. ## Sources - [PR workflow cache keys and prefix fallback](https://github.com/boykopovar/AnyPS5/blob/ce73562ac71a11c13879e78bf6fa43a10af9f82c/.github/workflows/build.yml#L685-L690) - [Graph loader checks structure but not the source commit](https://github.com/boykopovar/AnyPS5/blob/ce73562ac71a11c13879e78bf6fa43a10af9f82c/tools/select_tests.py#L201-L221) - [Host test selector accepts valid graphs and maps their outputs](https://github.com/boykopovar/AnyPS5/blob/ce73562ac71a11c13879e78bf6fa43a10af9f82c/tools/build_mingw_host_only_tests.py#L180-L205) - [Guest test selector uses the same narrowing helper](https://github.com/boykopovar/AnyPS5/blob/ce73562ac71a11c13879e78bf6fa43a10af9f82c/tools/build_changed_guest_tests.py#L29-L51) - [Selection uses only graph-recorded test closures](https://github.com/boykopovar/AnyPS5/blob/ce73562ac71a11c13879e78bf6fa43a10af9f82c/tools/select_tests.py#L273-L285) ## Not verified - I did not run a Windows workflow or local Windows build. The Linux C++/Python full suite's three failures described in the PR were not reproduced; they are author-reported as also occurring on `main`. - The precheck's negative-control run is not evidence that the new assertions fail against the bug; the base checkout predates the changed helper signature. - `pr_overlap.py` could not complete its repository-wide scan. ## To get this to a good state Bind the graph to the exact `main` SHA or use only the exact cache key for PR selection, and test that an older valid graph falls back to all current targets. I will rerun the same precheck and focused Python suite on the updated head.
adriadam10 commented 2026-11-07 00:32:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-07T00:32:44Z.

Review: CHANGES_REQUESTED


Thanks for this. Two things block it:

  • Stale graph (same point as MarcZX10's review): the restore step can fall back to a test-graph.json saved by an older main commit. A test whose executable was added after that commit is not in the graph, so a header change that should build it selects nothing for it and the job passes without linking it. Either restore only the exact base-SHA key on pull requests, or keep the prefix fallback and also feed the scripts the paths changed between the graph's commit (taken from cache-matched-key) and the PR head, so those tests are selected too. Falling back to every test when the graph does not match the current base is also fine. Please add a test where the graph lacks a currently configured executable (the host-only and guest scripts both need one). Ducengarth and veosett posted concrete patches for either option.
  • main moved: #12159 merged and touches the same build-wide blocks in tools/build_mingw_host_only_tests.py, so this now conflicts. Please rebase and keep its transitive-dependency selection working with --graph.

Once those are in, the change itself (graph narrowing with the fallbacks) looks right to me.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5808882499 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15153#pullrequestreview-5808882499). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-11-07T00:32:44Z. **Review:** CHANGES_REQUESTED --- Thanks for this. Two things block it: - Stale graph (same point as MarcZX10's review): the restore step can fall back to a `test-graph.json` saved by an older `main` commit. A test whose executable was added after that commit is not in the graph, so a header change that should build it selects nothing for it and the job passes without linking it. Either restore only the exact base-SHA key on pull requests, or keep the prefix fallback and also feed the scripts the paths changed between the graph's commit (taken from `cache-matched-key`) and the PR head, so those tests are selected too. Falling back to every test when the graph does not match the current base is also fine. Please add a test where the graph lacks a currently configured executable (the host-only and guest scripts both need one). Ducengarth and veosett posted concrete patches for either option. - `main` moved: #12159 merged and touches the same build-wide blocks in `tools/build_mingw_host_only_tests.py`, so this now conflicts. Please rebase and keep its transitive-dependency selection working with `--graph`. Once those are in, the change itself (graph narrowing with the fallbacks) looks right to me.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!15153
No description provided.