-
Notifications
You must be signed in to change notification settings - Fork 64
37 lines (33 loc) · 1.2 KB
/
tests_check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: Check for Tests in PR
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
check-for-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check for changes in test directory
id: check-tests
run: |
git status --porcelain > changed_files.txt
if grep -qE "^[AM]\s+test/" changed_files.txt; then
echo "Tests found in the PR"
echo "tests_present=true" >> $GITHUB_OUTPUT
else
echo "No tests found in the PR"
echo "tests_present=false" >> $GITHUB_OUTPUT
fi
- name: Comment on PR if tests are missing
if: steps.check-tests.outputs.tests_present == 'false'
uses: actions/[email protected]
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'It appears that this PR does not include any tests. It is recommended to add tests, especially for critical changes, to ensure code quality and prevent regressions.'
})