-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (60 loc) · 2.13 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: Coverage & Uploading reports
on:
push:
branches: ["main"]
paths:
- "src/**"
- "Cargo*"
- ".github/workflows/coverage.yml"
pull_request:
branches: ["main"]
types: [ready_for_review, opened, reopened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
coverage:
permissions:
pull-requests: write
if: github.event.pull_request.draft == false
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-cargo-
- name: Set up toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
components: llvm-tools
- name: Install cargo--llvm-cov
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-llvm-cov
- name: Run tests and get coverage
run: cargo llvm-cov --json > new-report.json
- name: Prepare and send the coverage to the server
id: coverage
run: |
sed -i '1s#^#{ "git": "'$(git remote get-url origin)'", "branch": "'$(git branch --show-current)'", "json_report": #' new-report.json
echo '}' >> new-report.json
json_report=$(curl -X PUT \
-H "Content-type: application/json" \
-H "x-api-key: ${{ secrets.API_KEY }}" \
-d "@new-report.json" \
https://llvm-cov-host.greefine.fr/report)
echo "json_report=$json_report" >> "$GITHUB_OUTPUT"
- name: Comment PR with report result
uses: thollander/actions-comment-pull-request@v2
with:
message: |
__Code coverage result:__ **base**=${{ fromJson(steps.coverage.outputs.json_report).base }}, **difference**=${{ fromJson(steps.coverage.outputs.json_report).diff }}
comment_tag: execution