Skip to content

Commit

Permalink
reverted ci
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy authored Jan 20, 2024
1 parent fc62a60 commit 76e35ec
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 21 deletions.
74 changes: 57 additions & 17 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_target:
types:
- opened
- synchronize
pull_request:
types:
- opened
Expand Down Expand Up @@ -36,27 +32,71 @@ 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')
score_diff=$(python -c "print(f'{${new_score} - ${current_score}:.04f}')")
echo "new_score=${new_score}" >> $GITHUB_OUTPUT
echo "current_score=${current_score}" >> $GITHUB_OUTPUT
echo "score_diff=${score_diff}" >> $GITHUB_OUTPUT
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
- name: Post comment
uses: actions/github-script@v7
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 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 }} ${(score_diff >= 0) ? "🟢" : "🔴"}
| | Old | New |
|--------|-----|-----|
| Commit | ${{ github.event.pull_request.base.sha }} | ${{ github.event.pull_request.head.sha }} |
| Score | ${old_score}% | ${new_score}% (${score_diff}) |
const diff_score = ${{ steps.get_coverage.outputs.diff_score }};
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 for ${process.env.COMMIT}
* Diff Commit: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
* Current vs New Coverage Score: ${process.env.SCORE_OLD}% / ${process.env.SCORE_NEW}%
* Difference: ${process.env.SCORE_DIFF} ${(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(", ")}
`;
try {
const { owner, repo, number } = context.issue;
await github.rest.issues.createComment({ owner, repo, issue_number: number, body: comment });
if(docs_changes > 0) {
await github.rest.issues.addLabels({
owner: owner,
repo: repo,
issue_number: number,
labels: ['documentation']
});
}
if(tests_changes > 0) {
await github.rest.issues.addLabels({
owner: owner,
repo: repo,
issue_number: number,
labels: ['automation/ci']
});
}
} catch (err) { console.log(err); }
8 changes: 4 additions & 4 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v5.0.0
- uses: actions/setup-python@v3
with:
python-version: "3.8"
python-version: "3.11"
- uses: pre-commit/action@v3.0.0

docs_link_check:
Expand All @@ -23,9 +23,9 @@ jobs:
contents: read
steps:
- name: checkout
uses: actions/checkout@v4
uses: actions/checkout@v2
- name: Check links
uses: lycheeverse/lychee-action@v1.9.1
uses: lycheeverse/lychee-action@v1.4.1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
Expand Down

0 comments on commit 76e35ec

Please sign in to comment.