Skip to content

Commit

Permalink
[CI] Add forbidden words checks to coverage action (#991)
Browse files Browse the repository at this point in the history
Add forbidden words checks to coverage.yml action to ensure some patterns are never found in gef.py
  • Loading branch information
therealdreg committed Aug 16, 2023
1 parent d27efd3 commit 371f273
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,28 @@ jobs:
echo "diff_score=${diff_score}" >> $GITHUB_OUTPUT
echo "include_tests=${include_tests}" >> $GITHUB_OUTPUT
echo "include_docs=${include_docs}" >> $GITHUB_OUTPUT
WORDS=("pycharm" "debugpy" "ptvsd" "breakpoint" "pdb")
WORDS_FOUND=""
for word in "${WORDS[@]}"; do
if git diff ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} -- "gef.py" | grep "^+" | grep -q "$word"; then
WORDS_FOUND+="'$word' "
fi
done
echo "words_found=${WORDS_FOUND}" >> $GITHUB_OUTPUT
- uses: actions/github-script@v6
env:
COMMIT: ${{ steps.get_coverage.outputs.commit }}
SCORE_OLD: ${{ steps.get_coverage.outputs.current_coverage_score }}
SCORE_NEW: ${{ steps.get_coverage.outputs.new_coverage_score }}
SCORE_DIFF: ${{ steps.get_coverage.outputs.diff_score }}
WORDS_FOUND: ${{ steps.get_coverage.outputs.words_found }}
with:
script: |
const tests_changes = ${{ steps.get_coverage.outputs.include_tests }};
const docs_changes = ${{ steps.get_coverage.outputs.include_docs }};
const forbiddenWordsString = process.env.WORDS_FOUND || '';
const forbidden_words = forbiddenWordsString.split(" ").filter(word => word.trim() !== '');
const comment = `## 🤖 Coverage Update
* Commit: ${process.env.COMMIT}
Expand All @@ -58,7 +69,7 @@ jobs:
To this point, this PR:
* ${(tests_changes == 0) ? "**does not** include" : "includes"} changes to tests
* ${(docs_changes == 0) ? "**does not** include" : "includes"} changes to documentation
* ${(forbidden_words.length === 0 || forbidden_words[0] === '') ? "**does not** include forbidden words" : "includes the forbidden words:" + forbidden_words.join(", ")}
`;
const { owner, repo, number } = context.issue;
Expand Down

0 comments on commit 371f273

Please sign in to comment.