Skip to content

Commit

Permalink
reverted coverage to a working state
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Jan 19, 2024
1 parent 22b3682 commit b671014
Showing 1 changed file with 15 additions and 43 deletions.
58 changes: 15 additions & 43 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: CI Coverage for PR

on:
pull_request:
types:
- opened
- synchronize
pull_request_target:
types:
- opened
Expand All @@ -24,8 +20,7 @@ jobs:
sudo apt-get -qq install -y gdb-multiarch python3-dev python3-pip python3-wheel python3-setuptools git cmake gcc g++ pkg-config libglib2.0-dev gdbserver qemu-user curl
sudo python3 -m pip install --upgrade pip --quiet
- name: Run test coverage
id: coverage
continue-on-error: true
id: get_coverage
env:
ALLOWED_MARGIN: 0.01
MIN_COVERAGE: 70
Expand All @@ -37,48 +32,25 @@ jobs:
current_score=$(curl --silent https://hugsy.github.io/gef/coverage/gef_py.html | grep pc_cov | sed 's?.*<span class="pc_cov">\([^%]*\)%</span>?\1?g')
bash scripts/generate-coverage-docs.sh
new_score=$(cat docs/coverage/gef_py.html | grep pc_cov | sed 's?.*<span class="pc_cov">\([^%]*\)%</span>?\1?g')
diff_score=$(python -c "print(${new_score} - ${current_score})")
commit=${{ github.event.pull_request.head.sha }}
include_tests=$((git diff ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} --compact-summary | egrep --count '^ tests/') || echo 0)
include_docs=$((git diff ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} --compact-summary | egrep --count '^ docs/') || echo 0)
echo "commit=${commit}" >> $GITHUB_OUTPUT
echo "new_coverage_score=${new_score}" >> $GITHUB_OUTPUT
echo "current_coverage_score=${current_score}" >> $GITHUB_OUTPUT
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
score_diff=$(python -c "print(${new_score} - ${current_score})")
echo "new_score=${new_score}" >> $GITHUB_OUTPUT
echo "current_score=${current_score}" >> $GITHUB_OUTPUT
echo "score_diff=${score_diff}" >> $GITHUB_OUTPUT
post_comment:
runs-on: ubuntu-latest
needs: coverage
if: success()
steps:
- uses: actions/github-script@v7
- name: Post comment
uses: actions/github-script@v7
env:
COMMIT:
with:
script: |
const diff_score = ${{ needs.coverage.outputs.diff_score }};
const tests_changes = ${{ needs.coverage.outputs.include_tests }};
const docs_changes = ${{ needs.coverage.outputs.include_docs }};
const forbiddenWordsString = "${{ needs.coverage.outputs.words_found }}" || '';
const forbidden_words = forbiddenWordsString.split(" ").filter(word => word.trim() !== '');
const comment = `## 🤖 Coverage update for ${{ needs.coverage.outputs.commit }}
const old_score = ${{ steps.get_coverage.outputs.current_score }};
const new_score = ${{ steps.get_coverage.outputs.new_score }};
const score_diff = ${{ steps.get_coverage.outputs.score_diff }};
const comment = `## 🤖 Coverage update for ${{ github.event.pull_request.head.sha }}
* Diff Commit: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
* Current vs New Coverage Score: ${score_old}% / ${score_new}%
* Difference: ${diff_score} ${(diff_score >= 0) ? "🟢" : "🔴"}
To this point, this PR:
* ${(tests_changes > 0) ? "includes" : "**does not** include" } changes to tests
* ${(docs_changes > 0) ? "includes" : "**does not** include" } changes to documentation
* ${(forbidden_words.length === 0 || forbidden_words[0] === '') ? "does not include forbidden words" : "**includes** the forbidden words:" + forbidden_words.join(", ")}
* Current vs New Coverage Score: ${old_score}% / ${new_score}%
* Difference: ${score_diff} ${(score_diff >= 0) ? "🟢" : "🔴"}
`;
try {
Expand Down

0 comments on commit b671014

Please sign in to comment.