Skip to content

Commit c44f868

Browse files
committed
feat(CI): Added check for manual tests checkbox
- Added GitHub Workflow that checks wether a user has performed a manual test.
1 parent 9587aa3 commit c44f868

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Note: Before submitting a pull request, please open an issue for discussion if y
77
## Checklist
88
- [ ] I have followed [Sample Guidelines from AUTHORING_GUIDE.MD](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md)
99
- [ ] README is updated to include [all relevant information](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md#readme-file)
10-
- [ ] **Tests** pass: `nox -s py-3.9` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md#test-environment-setup))
10+
- [ ] **Tests** pass: `nox -s py-3.10` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md#test-environment-setup))
1111
- [ ] **Lint** pass: `nox -s lint` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md#test-environment-setup))
1212
- [ ] These samples need a new **API enabled** in testing projects to pass (let us know which ones)
1313
- [ ] These samples need a new/updated **env vars** in testing projects set to pass (let us know which ones)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "CI: Check Manual Test Completion"
2+
on:
3+
pull_request:
4+
types: [opened, edited, synchronize]
5+
jobs:
6+
check-task:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Verify tests checkbox is ticked
10+
uses: actions/github-script@v7
11+
with:
12+
script: |
13+
const prBody = context.payload.pull_request.body;
14+
15+
if (!prBody) {
16+
core.setFailed("PR description is empty. Please use the PR template and check the required boxes.");
17+
return;
18+
}
19+
20+
// Regex checks for a markdown checkbox followed by 'nox -s py-3.'
21+
// [ x ] or [x] means checked. [ ] means unchecked.
22+
const checkedRegex = /- \[[xX]\] .*nox -s py-3\.\d+/;
23+
const includesTargetText = prBody.includes("nox -s py-3.");
24+
25+
if (!includesTargetText) {
26+
core.setFailed("The required test verification line seems to be missing from the PR description.");
27+
return;
28+
}
29+
30+
if (checkedRegex.test(prBody)) {
31+
console.log("Success: The test execution checkbox has been marked!");
32+
} else {
33+
core.setFailed("You must run the tests and check the 'nox -s py-3.9' box before this PR can be merged.");
34+
}

0 commit comments

Comments
 (0)