Skip to content

Commit c1b383f

Browse files
committed
GitHub tests: Add coverage report
1 parent c297368 commit c1b383f

File tree

1 file changed

+53
-10
lines changed

1 file changed

+53
-10
lines changed

.github/workflows/debian.yml

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,72 @@
11
name: 🍥GitHub Action Debian
2-
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
3-
on: [push]
2+
run-name: ${{ github.event_name }} GitHub Action triggered by ${{ github.actor }} 🚀
3+
on: [pull_request]
44
jobs:
55
Run-Tests:
66
runs-on: ubuntu-latest
77
steps:
8-
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
8+
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event ${{ github.head_ref }} to ${{ github.base_ref }}."
99
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
1010
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
11-
- name: Check out repository code
11+
- name: 📨 Check out repository code
1212
uses: actions/checkout@v4
13+
with:
14+
path: current
15+
- name: 🏚︎ Check out the base branch
16+
uses: actions/checkout@v4
17+
with:
18+
path: base
19+
ref: ${{ github.base_ref }}
20+
- name: 🌨️ checkout lcov
21+
uses: actions/checkout@v4
22+
with:
23+
path: lcov
24+
ref: v2.0
25+
repository: linux-test-project/lcov
1326
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
1427
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
15-
- name: 🧐 List files in the repository
16-
run: |
17-
cd ${{ github.workspace }}
18-
ls
1928
- name: 🧰 Install tools
2029
run: |
2130
sudo apt-get update
22-
sudo apt-get install libtest-cmd-perl
31+
sudo apt-get install libtest-cmd-perl librrd-dev valgrind sed \
32+
libcapture-tiny-perl libdatetime-perl libdevel-cover-perl libdigest-md5-perl libfile-spec-perl libjson-xs-perl libmodule-load-conditional-perl libscalar-list-utils-perl libtime-hires-perl
2333
- name: 🏗️ Build the stuff
2434
run: |
25-
make
35+
cd ${{ github.workspace }}/lcov
36+
make PREFIX=${{ github.workspace }}/lcov-install install
37+
for dir in base current ; do
38+
cd ${{ github.workspace }}/$dir
39+
sed -i -e s/[.]ao\\\>/.lo/g lib/test/Module.mk # Need only one kind of object in all binaries for gcov
40+
CFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS=-lgcov make PROG_EXTRA=sensord BUILD_STATIC_LIB=0
41+
done
2642
- name: 🧫 Run tests
2743
run: |
44+
for dir in base current ; do
45+
cd ${{ github.workspace }}/$dir
46+
${{ github.workspace }}/lcov-install/bin/lcov --capture --initial --branch-coverage --base $(pwd) --no-external --directory . --output-file coverage0.info
2847
make check
48+
done
49+
- name: 🌨️ Calculate coverage
50+
run: |
51+
for dir in base current ; do
52+
cd ${{ github.workspace }}/$dir
53+
${{ github.workspace }}/lcov-install/bin/lcov --capture --branch-coverage --base $(pwd) --no-external --directory . --output-file coverage1.info
54+
${{ github.workspace }}/lcov-install/bin/lcov --branch-coverage --substitute 's#'$dir'/##g' --add-tracefile coverage0.info --add-tracefile coverage1.info --output-file coverage.info
55+
${{ github.workspace }}/lcov-install/bin/lcov --list coverage.info
56+
cp ${{ github.workspace }}/$dir/coverage.info ${{ github.workspace }}/coverage-$dir.info
57+
done
58+
59+
- name: ⬆ Upload coverage
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: Coverage report
63+
path: ${{ github.workspace }}/current/coverage.info
64+
- name: 🏔️ generate coverage report
65+
uses: romeovs/[email protected]
66+
with:
67+
lcov-file: "${{ github.workspace }}/coverage-current.info"
68+
lcov-base: "${{ github.workspace }}/coverage-base.info"
69+
github-token: "${{ secrets.token }}"
70+
delete-old-comments: true
71+
update-comment: true
2972
- run: echo "🍏 This job's status is ${{ job.status }}."

0 commit comments

Comments
 (0)