Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/workspace-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,10 @@ jobs:
with:
path: all-results
pattern: results-*
merge-multiple: true
# Each shard includes smoke_timings.json. Flattening artifacts lets
# concurrent downloads overwrite that shared name and corrupt JSON.
# Both provenance and aggregation already walk nested directories.
merge-multiple: false
- name: Checkout Heart result provenance guard
uses: actions/checkout@v4
with:
Expand Down
28 changes: 28 additions & 0 deletions tests/test_result_provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,34 @@ def test_clean_shard_and_explicit_local_replay(tmp_path, monkeypatch):
assert provenance.main([str(tmp_path), "--root", str(tmp_path)]) == 0


def test_nested_artifacts_keep_same_named_sidecars_and_validate_every_shard(tmp_path):
runner = tmp_path / "runner"
results = tmp_path / "all-results"
for name in ("first", "second"):
artifact = results / f"results-scripts-{name}"
artifact.mkdir(parents=True)
(artifact / "report.json").write_text(json.dumps(shard(runner / name / "test.py")))
(artifact / "smoke_timings.json").write_text(json.dumps({"timings": [name]}))

assert len(list(results.rglob("smoke_timings.json"))) == 2
assert provenance.main([str(results), "--root", str(runner)]) == 0

# Nesting must not hide a foreign shard behind a passing sibling.
foreign = results / "results-scripts-second" / "report.json"
foreign.write_text(json.dumps(shard(tmp_path / "outside/test.py")))
assert provenance.main([str(results), "--root", str(runner)]) == 1


@pytest.mark.parametrize("payload", ['{"results":', '{"results": {}}'])
def test_nested_malformed_result_shard_still_fails(tmp_path, payload, capsys):
artifact = tmp_path / "all-results" / "results-scripts-example"
artifact.mkdir(parents=True)
report = artifact / "report.json"
report.write_text(payload)
assert provenance.main([str(artifact.parent), "--root", str(tmp_path)]) == 1
assert str(report) in capsys.readouterr().err


def test_symlink_escape_is_rejected(tmp_path):
root = tmp_path / "runner"
root.mkdir()
Expand Down
13 changes: 13 additions & 0 deletions tests/test_workflow_wiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,19 @@ def test_timing_artifacts_stay_out_of_the_aggregate_namespace():
assert not _timing_step(job_name)["with"]["name"].startswith(prefix)


def test_validation_result_download_preserves_artifact_directories():
"""Same-named sidecars must never share a concurrent download destination."""
analyze = _load("workspace-validation.yml")["jobs"]["analyze"]
download = _step(analyze, "Download all result artifacts")
assert download["with"]["merge-multiple"] is False
assert download["with"]["path"] == "all-results"
guard = _step(analyze, "Reject foreign result paths before aggregation")
aggregate = _step(analyze, "Aggregate into report.json")
assert "all-results" in guard["run"]
assert "all-results/" in aggregate["run"]
assert analyze["steps"].index(guard) < analyze["steps"].index(aggregate)


# --- the discard-stale-results guard --------------------------------------
#
# A workspace repo that tracks its own test-results/ (one did, by accident, in
Expand Down
Loading