-
-
Notifications
You must be signed in to change notification settings - Fork 741
63 lines (58 loc) · 2.62 KB
/
coverage.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: CI Coverage for PR
on:
pull_request_target:
types:
- opened
- synchronize
pull_request:
types:
- opened
- synchronize
jobs:
coverage:
env:
PY_VER: ''
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
run: |
sudo apt-get -qq update
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-static qemu-user curl
sudo python3 -m pip install --upgrade pip --quiet
- name: Run test coverage
id: get_coverage
env:
ALLOWED_MARGIN: 0.01
MIN_COVERAGE: 70
run: |
echo PY_VER=`gdb -q -nx -ex "pi print('.'.join(map(str, sys.version_info[:2])))" -ex quit` >> $GITHUB_ENV
echo GEF_CI_NB_CPU=`grep -c ^processor /proc/cpuinfo` >> $GITHUB_ENV
echo GEF_CI_ARCH=`uname --processor` >> $GITHUB_ENV
python${{ env.PY_VER }} -m pip install --user --upgrade -r tests/requirements.txt -r docs/requirements.txt --quiet
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')
make -C tests/binaries
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
- name: Post comment
uses: actions/github-script@v7
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}) |
`;
try {
const { owner, repo, number } = context.issue;
await github.rest.issues.createComment({ owner, repo, issue_number: number, body: comment });
} catch (err) { console.log(err); }