Skip to content

Commit 1961c38

Browse files
wipush
1 parent 40b6d50 commit 1961c38

5 files changed

Lines changed: 56 additions & 17 deletions

File tree

.github/actions/test-robot-check/action.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,48 @@ inputs:
1010
description: 'Label indicating the PR has been robot-tested'
1111
required: false
1212
default: 'test-robot-done'
13+
token:
14+
description: 'GitHub token or PAT used to post comments (defaults to github.token)'
15+
required: false
16+
default: ''
1317

1418
runs:
1519
using: "composite"
1620
steps:
1721
- name: Check robot test labels
1822
uses: actions/github-script@v7
1923
with:
24+
github-token: ${{ inputs.token || github.token }}
2025
script: |
2126
const labelNeeded = '${{ inputs.label-test-robot-needed }}';
2227
const labelDone = '${{ inputs.label-test-robot-done }}';
2328
const pr = context.payload.pull_request.number;
29+
const sha = context.payload.pull_request.head.sha;
2430
2531
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
2632
...context.repo,
2733
issue_number: pr,
2834
});
2935
const labelNames = new Set(currentLabels.map(l => l.name));
3036
31-
if (labelNames.has(labelNeeded) && !labelNames.has(labelDone)) {
32-
core.setFailed(
33-
`PR requires robot testing but is missing the expected label.\n` +
34-
` Expected label : \`${labelDone}\`\n` +
35-
` Reason : \`${labelNeeded}\` is present — robot testing must be completed and the PR marked with \`${labelDone}\` before merging.`
36-
);
37+
if (!labelNames.has(labelNeeded)) {
38+
core.info(`\`${labelNeeded}\` not present — no robot testing required.`);
39+
return;
40+
}
41+
42+
if (labelNames.has(labelDone)) {
43+
core.info(`\`${labelDone}\` present — robot testing confirmed.`);
44+
return;
3745
}
46+
47+
const shaLine = sha ? `\n\n**Commit:** \`${sha}\`` : '';
48+
await github.rest.issues.createComment({
49+
...context.repo,
50+
issue_number: pr,
51+
body:
52+
`### ❌ Robot Testing Required\n\n` +
53+
`\`${labelNeeded}\` is present but \`${labelDone}\` has not been added — this PR cannot be merged until robot testing is complete.${shaLine}\n\n` +
54+
`> [!IMPORTANT]\n` +
55+
`> Add \`${labelDone}\` once robot testing is complete.`,
56+
});
57+
core.setFailed(`\`${labelNeeded}\` is present but \`${labelDone}\` has not been added — robot testing must be completed before merging.`);

.github/actions/test-robot-label/action.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,31 @@ runs:
3434
});
3535
const labelNames = new Set(currentLabels.map(l => l.name));
3636
37+
const shaLine = sha ? `\n\n**Commit:** \`${sha}\`` : '';
38+
3739
if (!labelNames.has(labelDone)) {
3840
if (labelNames.has(labelNeeded)) {
39-
const shaLine = sha ? `\n**Commit:** \`${sha}\`` : '';
41+
core.warning(`\`${labelDone}\` not found — \`${labelNeeded}\` is present but testing is not confirmed.`);
4042
await github.rest.issues.createComment({
4143
...context.repo,
4244
issue_number: pr,
4345
body:
4446
`### ⚠️ Robot Testing Incomplete\n\n` +
45-
`\`${labelNeeded}\` is present but \`${labelDone}\` has not been added — ` +
46-
`this PR has not been confirmed as robot-tested.${shaLine}`,
47+
`\`${labelNeeded}\` is present but \`${labelDone}\` has not been added yet.${shaLine}\n\n` +
48+
`> [!WARNING]\n` +
49+
`> Add \`${labelDone}\` once robot testing is complete.`,
4750
});
4851
} else {
49-
core.info(`Label \`${labelDone}\` not found — nothing to do.`);
52+
core.info(`\`${labelDone}\` not present — nothing to do.`);
5053
}
5154
return;
5255
}
5356
54-
const shaLine = sha ? `\n**Commit:** \`${sha}\`` : '';
57+
core.info(`\`${labelDone}\` found — posting confirmation comment.`);
5558
await github.rest.issues.createComment({
5659
...context.repo,
5760
issue_number: pr,
5861
body:
5962
`### ✅ Robot Test Complete\n\n` +
60-
`This PR has been marked \`${labelDone}\`, confirming robot testing has passed.${shaLine}`,
63+
`\`${labelDone}\` has been added — robot testing has been confirmed for this PR.${shaLine}`,
6164
});

.github/actions/test-robot-unlabel/action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ runs:
3535
const labelNames = new Set(currentLabels.map(l => l.name));
3636
3737
if (!labelNames.has(labelDone)) {
38-
core.info(`Label \`${labelDone}\` not present — nothing to do.`);
38+
core.info(`\`${labelDone}\` not present — nothing to do.`);
3939
return;
4040
}
4141
@@ -44,18 +44,18 @@ runs:
4444
issue_number: pr,
4545
name: labelDone,
4646
});
47+
core.info(`\`${labelDone}\` removed.`);
4748
48-
const shaLine = sha ? `\n**Commit:** \`${sha}\`` : '';
49+
const shaLine = sha ? `\n\n**Commit:** \`${sha}\`` : '';
4950
const warning = !labelNames.has(labelNeeded)
5051
? `\n\n> [!WARNING]\n` +
51-
`> \`${labelDone}\` was removed but \`${labelNeeded}\` was not present — ` +
52-
`this PR may not be queued for robot testing.`
52+
`> \`${labelDone}\` was removed but \`${labelNeeded}\` was not present — this PR may not be queued for robot testing.`
5353
: '';
5454
5555
await github.rest.issues.createComment({
5656
...context.repo,
5757
issue_number: pr,
5858
body:
5959
`### 🔄 Robot Test Label Removed\n\n` +
60-
`\`${labelDone}\` has been removed due to new commits pushed to this PR.${shaLine}${warning}`,
60+
`New commits were pushed — \`${labelDone}\` has been removed and robot testing must be repeated.${shaLine}${warning}`,
6161
});

.github/workflows/pull-request-label.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,13 @@ jobs:
1919
uses: ./.github/workflows/test-robot-label.yml
2020
with:
2121
label-test-robot-done: test-robot-done
22+
label-test-robot-needed: test-robot-needed
23+
24+
test-robot-check:
25+
needs: test-robot-label
26+
if: always() && needs.test-robot-label.result != 'failure'
27+
name: Job
28+
uses: ./.github/workflows/test-robot-check.yml
29+
with:
30+
label-test-robot-done: test-robot-done
31+
label-test-robot-needed: test-robot-needed

.github/workflows/test-robot-label.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
type: string
99
required: false
1010
default: 'test-robot-done'
11+
label-test-robot-needed:
12+
description: 'Label name indicating the PR needs robot testing'
13+
type: string
14+
required: false
15+
default: 'test-robot-needed'
1116

1217
permissions:
1318
contents: read
@@ -26,3 +31,4 @@ jobs:
2631
uses: ./.github/actions/test-robot-label
2732
with:
2833
label-test-robot-done: ${{ inputs.label-test-robot-done }}
34+
label-test-robot-needed: ${{ inputs.label-test-robot-needed }}

0 commit comments

Comments
 (0)