Skip to content

Commit f780f9f

Browse files
feat(ci): add test gating
1 parent 33da296 commit f780f9f

4 files changed

Lines changed: 41 additions & 1 deletion

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# General: "needs-robot-testing" and "robot-tested" should be the default values of two inputs.
2+
# 1. It should check if "needs-robot-testing" label is present.
3+
# 2. It should check if "robot-tested" label is present.
4+
# 3. If "needs-robot-testing" is present and "robot-tested" is not present, it should fail with an error message saying "PR needs robot testing but is not marked as robot-tested."
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# General: "robot-tested" should be the default value of an input.
2+
# 1. It should check if "robot-tested" label is present.
3+
# 2. If present, it should add a comment saying "PR is marked as robot-tested.". it should also include the commit sha, (only if available), it was marked for.
4+
# 3.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# General: "needs-robot-testing" and "robot-tested" should be the default values of two inputs.
2+
# 1. It should check if "needs-robot-testing" label is present.
3+
# 2. It should check if "robot-tested" label is present.
4+
# 3. If present, it should remove the label.
5+
# 4. If removed, it should add a comment saying the label is removed and also include the commit sha, (only if available), it was removed for. If "needs-robot-testing" was not present, it should also include a warning that the label was removed without "needs-robot-testing" being present.

.github/workflows/pull-request.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: PR
22

33
on:
44
pull_request:
5-
types: [opened, synchronize, reopened]
5+
types: [opened, synchronize, reopened, labeled]
66

77
concurrency:
88
group: ${{ github.workflow }}-${{ github.ref }}
@@ -12,7 +12,34 @@ permissions:
1212
contents: read
1313
packages: write
1414

15+
env:
16+
LABEL_ROBOT_TEST_NEEDED: needs-robot-testing
17+
LABEL_ROBOT_TESTED: robot-tested
18+
1519
jobs:
20+
test-label:
21+
if: github.event.label.name == env.LABEL_ROBOT_TESTED
22+
name: Test Label
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Test Label Added
26+
uses: ./.github/actions/test-unlabel
27+
with:
28+
label-robot-tested: ${{ env.LABEL_ROBOT_TESTED }}
29+
30+
test-unlabel:
31+
if: github.event.action == 'synchronize'
32+
name: Test Unlabel
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Remove Test Label
36+
uses: ./.github/actions/test-label
37+
with:
38+
label-robot-tested: ${{ env.LABEL_ROBOT_TESTED }}
39+
label-robot-test-needed: ${{ env.LABEL_ROBOT_TEST_NEEDED }}
40+
1641
build:
42+
needs: test-remove-labels
43+
if: always() && github.event.action != 'labeled'
1744
name: Job
1845
uses: ./.github/workflows/build.yaml

0 commit comments

Comments
 (0)