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
30 changes: 26 additions & 4 deletions .github/workflows/scripts/test-quarantine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ issue. These correspond to Case A and Case B in
history cutoff commit, exact evidence identity, and the `origin/main`
history commit used for the decision. The receipt also identifies Case B
tests with at least one post-cutoff failure whose source snapshot contains
the unquarantine commit. Assembly history is
the unquarantine commit. An authenticated, cached lookup verifies that the
original Case B tracking number is an issue (open or closed), not a PR.
`case_b_issue_verified` is required at the safe-output boundary; the agent
need not repeat the lookup through integrity-filtered tools. Lookup errors
abort collection, while a definitive missing issue is ineligible.
Assembly history is
reconstructed across the resolved test project, including deleted
quarantine files. Same-project partial declarations are also evaluated as a
logical type for type-level quarantine history, so sibling declaration
Expand All @@ -48,8 +53,24 @@ issue. These correspond to Case A and Case B in
method and partial
type moves between files preserve their logical history, and issue-URL-only
replacements are not remove/add transitions. Automated unquarantine requires an exact
`first-quarantine` match and fails closed otherwise.
4. The pre-activation job uploads all three files as the one-day
`first-quarantine` match and fails closed otherwise. `introduced_utc` records
the exact target's introduction, rather than a later issue-URL replacement.
4. `collect_unquarantine_eligibility.py` fully paginates 30 days of main builds
and results for pipelines 84 and 87 before activation. It preserves exact
result names and per-pipeline denominators, maps rows through the shared
source resolver, and requires zero failures, real passes, 66% build
appearance, 60-day age, first-quarantine history, and no human suppression or
re-quarantine blocklist match. Unresolved rows fail closed. Ambiguous
re-quarantine PR ownership conservatively excludes targets sharing the issue
in that file; a truncated diff excludes the whole file.
Class/assembly coverage uses effective resolved overrides, including inherited
test attributes; abstract types are not independent assembly runners.
Suppressions recognize runtime and declaring method identities, and method-wide
references block data rows without matching a different argument row.
The compact receipt records complete collection, pipeline counts, eligible
source targets, and the history receipt's SHA-256. Missing pages or malformed
responses abort pre-activation; they never become an empty candidate list.
The pre-activation job uploads all four files as the one-day
`test-quarantine-evidence-<run-id>` artifact.
5. The agent may choose a new-quarantine or re-quarantine candidate only from
the corresponding deterministic eligible-test list injected into its
Expand All @@ -72,7 +93,7 @@ issue. These correspond to Case A and Case B in
target changes. It rejects unrelated edits, mixed additions/removals,
duplicate targets, stale project source, additions that do not match an
eligible Case A or Case B receipt, and removals whose exact current history
is not `first-quarantine`.
is not `first-quarantine` or lacks bound deterministic Part 2 eligibility.

Agent-provided log excerpts and URLs are for human display only. They are not
accepted as validation evidence.
Expand Down Expand Up @@ -210,6 +231,7 @@ Run the deterministic collector fixtures:

```bash
python3 -B .github/workflows/scripts/test-quarantine/test_collect_case_a_eligibility.py
python3 -B .github/workflows/scripts/test-quarantine/test_collect_unquarantine_eligibility.py
```

Run the pull-request action-boundary fixtures:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,12 +536,16 @@ def build_source_index(root):
)
declaration_line = clean.count("\n", 0, position)
attributes = attribute_block(lines, declaration_line)
prefix_start = max(
clean.rfind(delimiter, 0, position) for delimiter in (";", "{", "}", "]")
) + 1
quarantined = has_quarantine_attribute(attributes)
if quarantined:
type_quarantines[(str(project_root), type_name)] = True
type_index.setdefault(type_name, []).append({
"type": type_name,
"base": entry[5],
"is_abstract": re.search(r"\babstract\b", clean[prefix_start:position]) is not None,
"path": relative_path,
"project_root": str(project_root),
"quarantined": quarantined,
Expand Down Expand Up @@ -579,6 +583,13 @@ def build_source_index(root):
"type": type_name,
"method": method,
"method_line": method_line + 1,
"is_test": any(
re.search(
r"\[\s*(?:global::)?(?:\w+\.)*\w*(?:Fact|Theory)(?:Attribute)?\b",
sanitize_csharp(attribute),
) is not None
for attribute in logical_attributes(attributes)
),
"project_root": project_root,
"method_quarantined": bool(parsed_attributes["method"]),
"method_operating_systems": (
Expand Down Expand Up @@ -2545,6 +2556,10 @@ def collect_requarantine_history(
"type": declaration["type"],
"method": declaration["method"],
"issue": issue,
"introduced_utc": next((
event.get("utc") for event in events
if event["status"] == "added"
), None),
"status": (
classify_current_quarantine_history(events)
if issue is not None else "ambiguous"
Expand Down Expand Up @@ -2615,6 +2630,10 @@ def collect_requarantine_history(
"method": declaration["method"],
"data": data_attribute["data"],
"issue": issue,
"introduced_utc": next((
event.get("utc") for event in events
if event["status"] == "added"
), None),
"status": (
classify_current_quarantine_history(events)
if issue is not None else "ambiguous"
Expand Down Expand Up @@ -2672,6 +2691,10 @@ def collect_requarantine_history(
"type": declaration["type"],
"method": None,
"issue": issue,
"introduced_utc": next((
event.get("utc") for event in events
if event["status"] == "added"
), None),
"status": (
classify_current_quarantine_history(events)
if issue is not None else "ambiguous"
Expand Down Expand Up @@ -2716,6 +2739,10 @@ def collect_requarantine_history(
"scope": "assembly",
"path": assembly["path"],
"issue": assembly["issue"],
"introduced_utc": next((
event.get("utc") for event in events
if event["status"] == "added"
), None),
"type": None,
"method": None,
"status": (
Expand Down Expand Up @@ -2982,6 +3009,38 @@ def github_commit_contains(repository, ancestor, descendant, token):
raise ValueError(f"Unexpected GitHub comparison status: {status!r}")


def github_issue_exists(repository, issue, token):
if not token:
raise ValueError("A GitHub token is required to verify tracking issues")
request = urllib.request.Request(
f"https://api.github.com/repos/{repository}/issues/{issue}",
headers={
"Authorization": f"Bearer {token}",
"Accept": "application/vnd.github+json",
"User-Agent": "aspnetcore-test-quarantine",
},
)
for attempt in range(3):
try:
with urllib.request.urlopen(request, timeout=30) as response:
data = json.load(response)
return (
data.get("number") == issue
and data.get("url") == f"https://api.github.com/repos/{repository}/issues/{issue}"
and "pull_request" not in data
and data.get("state") in ("open", "closed")
)
except urllib.error.HTTPError as error:
if error.code == 404:
return False
if attempt == 2 or error.code not in (403, 429) and error.code < 500:
raise
except OSError:
if attempt == 2:
raise
time.sleep(2 * (attempt + 1))


def commit_contains(root, repository, ancestor, descendant, token):
if not ancestor or not descendant:
raise ValueError("Both ancestor and descendant commits are required")
Expand Down Expand Up @@ -3054,6 +3113,7 @@ def collect(
pr_files_provider=None,
commit_contains_provider=None,
history_ref="HEAD",
issue_exists_provider=None,
):
root = pathlib.Path(root)
token = os.environ.get("GH_TOKEN", "")
Expand All @@ -3069,6 +3129,9 @@ def collect(
token,
)
)
issue_exists_provider = issue_exists_provider or (
lambda issue: github_issue_exists(repository, issue, token)
)
source_index = build_source_index(root)
history_commit = git(root, "rev-parse", "--verify", history_ref)
history_order = first_parent_order(root, history_ref)
Expand All @@ -3080,6 +3143,7 @@ def collect(
receipts = {}
pr_files_cache = {}
ancestry_cache = {}
issue_cache = {}
project_history_cache = {}
assembly_history_cache = {}
method_history_cache = {}
Expand Down Expand Up @@ -3112,6 +3176,7 @@ def collect(
"eligible_failure_builds": [],
"case_b_eligible": False,
"case_b_issue": None,
"case_b_issue_verified": False,
"quarantine_operating_systems": None,
"evidence": None,
"reasons": reasons,
Expand Down Expand Up @@ -3386,7 +3451,14 @@ def collect(
if case_b:
receipt["status"] = "ineligible"
if included:
receipt["case_b_eligible"] = True
issue = receipt["case_b_issue"]
if issue not in issue_cache:
issue_cache[issue] = issue_exists_provider(issue) is True
receipt["case_b_issue_verified"] = issue_cache[issue]
if receipt["case_b_issue_verified"]:
receipt["case_b_eligible"] = True
else:
reasons.append("original-quarantine-issue-unverified")
else:
reasons.append("no-post-cutoff-failures")
continue
Expand Down
Loading
Loading