|
1 | 1 | 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] |
4 | 4 | jobs: |
5 | 5 | Run-Tests: |
6 | 6 | runs-on: ubuntu-latest |
7 | 7 | 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 }}." |
9 | 9 | - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" |
10 | 10 | - 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 |
12 | 12 | 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 |
13 | 26 | - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." |
14 | 27 | - 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 |
19 | 28 | - name: 🧰 Install tools |
20 | 29 | run: | |
21 | 30 | 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 |
23 | 33 | - name: 🏗️ Build the stuff |
24 | 34 | 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 |
26 | 42 | - name: 🧫 Run tests |
27 | 43 | 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 |
28 | 47 | 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 | + |
| 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 |
29 | 72 | - run: echo "🍏 This job's status is ${{ job.status }}." |
0 commit comments