Skip to content

Commit 3b8d2d3

Browse files
refactor(test): use generic test actions
1 parent 853b0dd commit 3b8d2d3

6 files changed

Lines changed: 71 additions & 53 deletions

File tree

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
name: "Robot Test Check Labels"
2-
description: "Fails if test-robot-needed is present but test-robot-done is not."
1+
name: "Test Check Labels"
2+
description: "Fails if label-needed is present but label-done is not."
33

44
inputs:
5-
label-test-robot-needed:
6-
description: 'Label indicating the PR needs robot testing'
5+
label-needed:
6+
description: 'Label indicating the PR needs testing'
77
required: false
8-
default: 'test-robot-needed'
9-
label-test-robot-done:
10-
description: 'Label indicating the PR has been robot-tested'
8+
default: 'test-needed'
9+
label-done:
10+
description: 'Label indicating the PR has been tested'
1111
required: false
12-
default: 'test-robot-done'
12+
default: 'test-done'
13+
test-name:
14+
description: 'Name of the test type used in comments (e.g. Robot)'
15+
required: false
16+
default: 'Test'
1317
token:
1418
description: 'GitHub token or PAT used to post comments (defaults to github.token)'
1519
required: false
@@ -18,13 +22,14 @@ inputs:
1822
runs:
1923
using: "composite"
2024
steps:
21-
- name: Check robot test labels
25+
- name: Check test labels
2226
uses: actions/github-script@v7
2327
with:
2428
github-token: ${{ inputs.token || github.token }}
2529
script: |
26-
const labelNeeded = '${{ inputs.label-test-robot-needed }}';
27-
const labelDone = '${{ inputs.label-test-robot-done }}';
30+
const labelNeeded = '${{ inputs.label-needed }}';
31+
const labelDone = '${{ inputs.label-done }}';
32+
const testName = '${{ inputs.test-name }}';
2833
const { number: pr, head: { sha } } = context.payload.pull_request;
2934
const repo = context.repo;
3035
@@ -40,19 +45,19 @@ runs:
4045
const has = new Set(labels.map(l => l.name));
4146
4247
if (!has.has(labelNeeded)) {
43-
core.info(`\`${labelNeeded}\` not present. No robot testing required.`);
48+
core.info(`\`${labelNeeded}\` not present. No ${testName} testing required.`);
4449
return;
4550
}
4651
4752
if (has.has(labelDone)) {
48-
core.info(`\`${labelDone}\` present. Robot testing confirmed.`);
53+
core.info(`\`${labelDone}\` present. ${testName} testing confirmed.`);
4954
return;
5055
}
5156
5257
const shaLine = sha ? `\n\n**Commit:** \`${sha}\`` : '';
5358
await postComment(
54-
`### ❌ Robot Testing Required\n\n` +
55-
`\`${labelNeeded}\` is present but \`${labelDone}\` has not been added. This PR cannot be merged until robot testing is complete.${shaLine}\n\n` +
56-
`> [!IMPORTANT]\n> Add \`${labelDone}\` once robot testing is complete.`
59+
`### ❌ ${testName} Testing Required\n\n` +
60+
`\`${labelNeeded}\` is present but \`${labelDone}\` has not been added. This PR cannot be merged until ${testName} testing is complete.${shaLine}\n\n` +
61+
`> [!IMPORTANT]\n> Add \`${labelDone}\` once ${testName} testing is complete.`
5762
);
58-
core.setFailed(`\`${labelNeeded}\` is present but \`${labelDone}\` has not been added. Robot testing must be completed before merging.`);
63+
core.setFailed(`\`${labelNeeded}\` is present but \`${labelDone}\` has not been added. ${testName} testing must be completed before merging.`);

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
name: "Robot Test Label"
2-
description: "When the test-robot-done label is added, posts a comment confirming the robot test status."
1+
name: "Test Label"
2+
description: "When the label-done label is added, posts a comment confirming the test status."
33

44
inputs:
5-
label-test-robot-needed:
6-
description: 'Label indicating the PR needs robot testing'
5+
label-needed:
6+
description: 'Label indicating the PR needs testing'
77
required: false
8-
default: 'test-robot-needed'
9-
label-test-robot-done:
10-
description: 'Label indicating the PR has been robot-tested'
8+
default: 'test-needed'
9+
label-done:
10+
description: 'Label indicating the PR has been tested'
1111
required: false
12-
default: 'test-robot-done'
12+
default: 'test-done'
13+
test-name:
14+
description: 'Name of the test type used in comments (e.g. Robot)'
15+
required: false
16+
default: 'Test'
1317
token:
1418
description: 'GitHub token or PAT used to post comments (defaults to github.token)'
1519
required: false
@@ -23,8 +27,9 @@ runs:
2327
with:
2428
github-token: ${{ inputs.token || github.token }}
2529
script: |
26-
const labelDone = '${{ inputs.label-test-robot-done }}';
27-
const labelNeeded = '${{ inputs.label-test-robot-needed }}';
30+
const labelDone = '${{ inputs.label-done }}';
31+
const labelNeeded = '${{ inputs.label-needed }}';
32+
const testName = '${{ inputs.test-name }}';
2833
const { number: pr, head: { sha } } = context.payload.pull_request;
2934
const repo = context.repo;
3035
@@ -44,9 +49,9 @@ runs:
4449
if (has.has(labelNeeded)) {
4550
core.warning(`\`${labelDone}\` not found. \`${labelNeeded}\` is present but testing is not confirmed.`);
4651
await postComment(
47-
`### ⚠️ Robot Testing Incomplete\n\n` +
52+
`### ⚠️ ${testName} Testing Incomplete\n\n` +
4853
`\`${labelNeeded}\` is present but \`${labelDone}\` has not been added yet.${shaLine}\n\n` +
49-
`> [!WARNING]\n> Add \`${labelDone}\` once robot testing is complete.`
54+
`> [!WARNING]\n> Add \`${labelDone}\` once ${testName} testing is complete.`
5055
);
5156
} else {
5257
core.info(`\`${labelDone}\` not present. Nothing to do.`);
@@ -56,6 +61,6 @@ runs:
5661
5762
core.info(`\`${labelDone}\` found. Posting confirmation comment.`);
5863
await postComment(
59-
`### ✅ Robot Test Complete\n\n` +
60-
`\`${labelDone}\` has been added. Robot testing has been confirmed for this PR.${shaLine}`
64+
`### ✅ ${testName} Complete\n\n` +
65+
`\`${labelDone}\` has been added. ${testName} testing has been confirmed for this PR.${shaLine}`
6166
);

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
name: "Robot Test Unlabel"
2-
description: "On new commits, removes the test-robot-done label if present and posts a comment."
1+
name: "Test Unlabel"
2+
description: "On new commits, removes the label-done label if present and posts a comment."
33

44
inputs:
5-
label-test-robot-needed:
6-
description: 'Label indicating the PR needs robot testing'
5+
label-needed:
6+
description: 'Label indicating the PR needs testing'
77
required: false
8-
default: 'test-robot-needed'
9-
label-test-robot-done:
10-
description: 'Label indicating the PR has been robot-tested'
8+
default: 'test-needed'
9+
label-done:
10+
description: 'Label indicating the PR has been tested'
1111
required: false
12-
default: 'test-robot-done'
12+
default: 'test-done'
13+
test-name:
14+
description: 'Name of the test type used in comments (e.g. Robot)'
15+
required: false
16+
default: 'Test'
1317
token:
1418
description: 'GitHub token or PAT used to remove labels and post comments (defaults to github.token)'
1519
required: false
@@ -23,8 +27,9 @@ runs:
2327
with:
2428
github-token: ${{ inputs.token || github.token }}
2529
script: |
26-
const labelDone = '${{ inputs.label-test-robot-done }}';
27-
const labelNeeded = '${{ inputs.label-test-robot-needed }}';
30+
const labelDone = '${{ inputs.label-done }}';
31+
const labelNeeded = '${{ inputs.label-needed }}';
32+
const testName = '${{ inputs.test-name }}';
2833
const { number: pr, head: { sha } } = context.payload.pull_request;
2934
const repo = context.repo;
3035
@@ -49,10 +54,10 @@ runs:
4954
5055
const shaLine = sha ? `\n\n**Commit:** \`${sha}\`` : '';
5156
const warning = !has.has(labelNeeded)
52-
? `\n\n> [!WARNING]\n> \`${labelDone}\` was removed but \`${labelNeeded}\` was not present. This PR may not be queued for robot testing.`
57+
? `\n\n> [!WARNING]\n> \`${labelDone}\` was removed but \`${labelNeeded}\` was not present. This PR may not be queued for ${testName} testing.`
5358
: '';
5459
5560
await postComment(
56-
`### 🔄 Robot Test Label Removed\n\n` +
57-
`New commits were pushed. \`${labelDone}\` has been removed and robot testing must be repeated.${shaLine}${warning}`
61+
`### 🔄 ${testName} Label Removed\n\n` +
62+
`New commits were pushed. \`${labelDone}\` has been removed and ${testName} testing must be repeated.${shaLine}${warning}`
5863
);

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ jobs:
3131
- uses: actions/checkout@v4
3232

3333
- name: Robot Test Check
34-
uses: ./.github/actions/test-robot-check
34+
uses: ./.github/actions/test/check
3535
with:
36-
label-test-robot-done: ${{ inputs.label-test-robot-done }}
37-
label-test-robot-needed: ${{ inputs.label-test-robot-needed }}
36+
label-done: ${{ inputs.label-test-robot-done }}
37+
label-needed: ${{ inputs.label-test-robot-needed }}
38+
test-name: Robot
3839
token: ${{ secrets.token }}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ jobs:
3333
- uses: actions/checkout@v4
3434

3535
- name: Robot Test Label
36-
uses: ./.github/actions/test-robot-label
36+
uses: ./.github/actions/test/label
3737
with:
38-
label-test-robot-done: ${{ inputs.label-test-robot-done }}
39-
label-test-robot-needed: ${{ inputs.label-test-robot-needed }}
38+
label-done: ${{ inputs.label-test-robot-done }}
39+
label-needed: ${{ inputs.label-test-robot-needed }}
40+
test-name: Robot
4041
token: ${{ secrets.token }}
4142

4243
- name: Rerun pull-request workflow

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ jobs:
3131
- uses: actions/checkout@v4
3232

3333
- name: Robot Test Unlabel
34-
uses: ./.github/actions/test-robot-unlabel
34+
uses: ./.github/actions/test/unlabel
3535
with:
36-
label-test-robot-done: ${{ inputs.label-test-robot-done }}
37-
label-test-robot-needed: ${{ inputs.label-test-robot-needed }}
36+
label-done: ${{ inputs.label-test-robot-done }}
37+
label-needed: ${{ inputs.label-test-robot-needed }}
38+
test-name: Robot
3839
token: ${{ secrets.token }}

0 commit comments

Comments
 (0)