-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (76 loc) · 3.01 KB
/
Copy pathtest.yml
File metadata and controls
77 lines (76 loc) · 3.01 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: "Build and Test"
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v10
with:
name: github-public
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: >
git config --global url."https://github.com/".insteadOf ssh://git@github.com/
- run: export NIXPKGS_ALLOW_UNFREE=1 && nix-build -E 'with (import (fetchTarball "https://github.com/goromal/anixpkgs/archive/refs/heads/master.tar.gz") {}); signals-cpp.override { pkg-src = lib.cleanSource ./.; }'
code-cov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v10
with:
name: github-public
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build, test, and generate coverage HTML report
run: |
mkdir build && cd build
nix-shell ../.github/_nixshell --run "cmake .. -DCMAKE_BUILD_TYPE=Debug && make unit-tests"
nix-shell ../.github/_nixshell --run "lcov --capture --directory . --output-file coverage.info && \
lcov --remove coverage.info '/usr/*' '*/test/*' --output-file coverage.info.cleaned && \
genhtml --branch-coverage --ignore-errors source --output-directory coverage_report coverage.info.cleaned"
- name: Upload coverage report artifact
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: build/coverage_report
- name: Post PR comment with coverage artifact (optional)
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const artifactUrl = `https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}`;
const comment = `
### 🧪 Code Coverage Report
The code coverage report has been generated for this PR.
➡️ [View coverage artifact](${artifactUrl})
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
- name: Copy coverage report into docs/
run: |
mkdir -p docs/coverage
cp -r build/coverage_report/* docs/coverage/
- name: Commit coverage report to docs/
if: github.ref == 'refs/heads/master'
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@github.com"
git add docs/coverage
git commit -m "Update coverage report [skip ci]" || echo "No changes to commit"
git push