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
17 changes: 15 additions & 2 deletions .github/workflows/trainer-rank-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ jobs:
with:
script: |
const pull = context.payload.pull_request;
const identity = [
pull?.head?.repo?.full_name,
pull?.head?.ref,
pull?.head?.sha,
pull?.base?.sha,
];
if (!identity.every(value =>
typeof value === 'string' && value.length > 0
)) {
core.warning('Prior GPU validation identity is incomplete.');
return;
}
const runs = await github.rest.actions.listWorkflowRuns({
...context.repo,
workflow_id: 'trainer-rank-gpu.yml',
Expand All @@ -48,9 +60,10 @@ jobs:
});
const candidates = runs.data.workflow_runs.filter(run =>
run.id !== context.runId &&
run.head_repository?.full_name === pull.head.repo.full_name &&
run.head_branch === pull.head.ref &&
run.head_sha === pull.head.sha &&
run.path === '.github/workflows/trainer-rank-gpu.yml' &&
(run.pull_requests ?? []).some(previous => previous.number === pull.number)
run.path === '.github/workflows/trainer-rank-gpu.yml'
).slice(0, 10);
for (const run of candidates) {
const jobs = await github.rest.actions.listJobsForWorkflowRun({
Expand Down
33 changes: 33 additions & 0 deletions tests/unit/test_trainer_rank_gpu_workflow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from pathlib import Path


def test_ready_for_review_reuse_has_stable_source_provenance() -> None:
workflow = (
Path(__file__).parents[2] / ".github/workflows/trainer-rank-gpu.yml"
).read_text()

assert "github.event.action == 'ready_for_review'" in workflow
assert "pull?.head?.repo?.full_name" in workflow
assert "pull?.head?.ref" in workflow
assert "pull?.head?.sha" in workflow
assert "pull?.base?.sha" in workflow
assert "identity.every(value =>" in workflow
assert "typeof value === 'string' && value.length > 0" in workflow
assert "run.head_repository?.full_name === pull.head.repo.full_name" in workflow
assert "run.head_branch === pull.head.ref" in workflow
assert "run.head_sha === pull.head.sha" in workflow
assert "run.path === '.github/workflows/trainer-rank-gpu.yml'" in workflow
assert "run.pull_requests" not in workflow


def test_ready_for_review_reuse_requires_exact_base_artifact_and_gpu_job() -> None:
workflow = (
Path(__file__).parents[2] / ".github/workflows/trainer-rank-gpu.yml"
).read_text()

assert "job.name === 'Run on 2x H200' && job.conclusion === 'success'" in workflow
assert "!artifact.expired" in workflow
assert (
"`trainer-rank-result-${run.id}-${run.run_attempt}-${pull.base.sha}`"
in workflow
)
Loading