mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-09-30 13:32:39 +07:00
GitHub tests: Add coverage report
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
name: 🏔️ Display coverage data
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [🍥GitHub Action Debian]
|
||||
types: [completed]
|
||||
|
||||
jobs:
|
||||
Display-Coverage:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: ⏬ Download artifact
|
||||
uses: actions/github-script@v9
|
||||
with:
|
||||
github-token: ${{ secrets.TOKEN }}
|
||||
script: |
|
||||
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
run_id: context.payload.workflow_run.id,
|
||||
});
|
||||
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
|
||||
return artifact.name == "Coverage report"
|
||||
})[0];
|
||||
let download = await github.rest.actions.downloadArtifact({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
artifact_id: matchArtifact.id,
|
||||
archive_format: 'zip',
|
||||
});
|
||||
let fs = require('fs');
|
||||
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/coverage-report.zip`, Buffer.from(download.data));
|
||||
- name: 🏺 Unzip artifact
|
||||
run: unzip coverage-report.zip -d lcov
|
||||
- name: 🏔️ Generate coverage report
|
||||
uses: hramrach/lcov-reporter-action@master
|
||||
with:
|
||||
github-token: ${{ secrets.TOKEN }}
|
||||
lcov-file: "lcov/coverage-current.info"
|
||||
lcov-base: "lcov/coverage-base.info"
|
||||
event: "lcov/event"
|
||||
delete-old-comments: true
|
||||
update-comment: true
|
||||
@@ -1,29 +1,64 @@
|
||||
name: 🍥GitHub Action Debian
|
||||
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
|
||||
on: [push]
|
||||
run-name: ${{ github.event_name }} GitHub Action triggered by ${{ github.actor }} 🎬
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
Run-Tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
|
||||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
|
||||
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
|
||||
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||
- name: 🧐 List files in the repository
|
||||
run: |
|
||||
cd ${{ github.workspace }}
|
||||
ls
|
||||
- name: 📨 Check out repository code
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
path: current
|
||||
- name: 🏚︎ Check out the base branch
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
path: base
|
||||
ref: ${{ github.base_ref }}
|
||||
- name: ≣⃛ checkout lcov
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
path: lcov
|
||||
ref: v2.0
|
||||
repository: linux-test-project/lcov
|
||||
- name: 🧰 Install tools
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install libtest-cmd-perl
|
||||
- name: 🏗️ Build the stuff
|
||||
sudo apt-get install libtest-cmd-perl librrd-dev valgrind sed \
|
||||
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
|
||||
- name: 🏗️ Build code
|
||||
run: |
|
||||
make
|
||||
cd ${{ github.workspace }}/lcov
|
||||
make PREFIX=${{ github.workspace }}/lcov-install install
|
||||
for dir in base current ; do
|
||||
cd ${{ github.workspace }}/$dir
|
||||
sed -i -e s/[.]ao\\\>/.lo/g lib/test/Module.mk # Need only one kind of object in all binaries for gcov
|
||||
CFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS=-lgcov make PROG_EXTRA=sensord BUILD_STATIC_LIB=0
|
||||
done
|
||||
- name: 🧫 Run tests
|
||||
run: |
|
||||
for dir in base current ; do
|
||||
cd ${{ github.workspace }}/$dir
|
||||
${{ github.workspace }}/lcov-install/bin/lcov --capture --initial --branch-coverage --base $(pwd) --no-external --directory . --output-file coverage0.info
|
||||
make check
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
done
|
||||
- name: 🌨️ Calculate coverage
|
||||
run: |
|
||||
for dir in base current ; do
|
||||
cd ${{ github.workspace }}/$dir
|
||||
${{ github.workspace }}/lcov-install/bin/lcov --capture --branch-coverage --base $(pwd) --no-external --directory . --output-file coverage1.info
|
||||
${{ github.workspace }}/lcov-install/bin/lcov --branch-coverage --substitute 's#'$dir'/##g' --add-tracefile coverage0.info --add-tracefile coverage1.info --output-file coverage.info
|
||||
${{ github.workspace }}/lcov-install/bin/lcov --list coverage.info
|
||||
cp ${{ github.workspace }}/$dir/coverage.info ${{ github.workspace }}/coverage-$dir.info
|
||||
done
|
||||
PR_NUMBER="${{ github.event.pull_request.number }}"
|
||||
cp ${{ github.event_path }} ${{ github.workspace }}/event
|
||||
cat ${{ github.workspace }}/event
|
||||
|
||||
- name: ⏫ Upload coverage data
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: Coverage report
|
||||
path: |
|
||||
${{ github.workspace }}/coverage-current.info
|
||||
${{ github.workspace }}/coverage-base.info
|
||||
${{ github.workspace }}/event
|
||||
|
||||
Reference in New Issue
Block a user