Skip to content

Commit

Permalink
Add a missing tests check and update CONTRIBUTING.md (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
TahaTesser authored Aug 19, 2024
1 parent b7e83da commit 9fd6a72
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .github/workflows/tests_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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. However, if this PR is only updating samples or documentation, feel free to skip adding tests and disregard this comment.'
})
7 changes: 6 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ To get started with contributing, please follow the steps below:
```bash
melos analyze
```
9. Create a pull request.
9. Make sure all existing tests pass and add new tests for the changes you made.
Execute the following command to run the tests.
```bash
melos test
```
10. Create a pull request.
2 changes: 2 additions & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ scripts:
exec: dart analyze .
format:
exec: dart format --set-exit-if-changed .
test:
exec: flutter test

0 comments on commit 9fd6a72

Please sign in to comment.