-
Notifications
You must be signed in to change notification settings - Fork 3
103 lines (87 loc) · 3.11 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Test & Coverage
on:
pull_request:
permissions: # Job-level permissions configuration starts here
contents: write # 'write' access to repository contents
pull-requests: write # 'write' access to pull requests
jobs:
check:
name: Rust project
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Cache Cargo's directories
uses: actions/cache@v4
with:
save-always: true
key: coverage-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
path: |
./target
~/.cargo
~/.cargo/registry
~/.cargo/git
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
- name: Run cargo-tarpaulin
run: |
cargo tarpaulin -l --out Html | tail -n 1 | grep -o '[^+][0-9]\+\.[0-9]\+%' > coverage_total_pecent.txt |
AVG_COVERAGE=$(cat coverage_total_pecent.txt) |
echo "COVERAGE=$AVG_COVERAGE" >> $GITHUB_ENV
- name: Checkout target repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
repository: myyrakle/html_reports
ref: master
path: ./html_reports
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
- name: Copy coverage report
run: |
random_report_name=$(date +%s) |
echo "REPORT_NAME=$random_report_name" >> $GITHUB_ENV |
cp ./tarpaulin-report.html ./html_reports/$random_report_name.html |
cd ./html_reports
- name: Init
run: |
git init |
git branch master |
git switch master |
echo "init success"
- name: Add
run: |
git add . |
echo "add success"
- name: Configure git
run: |
git config --local user.email "[email protected]" |
git config --local user.name "myyrakle"
- name: Commit
run: |
git commit -m "Add report" |
echo "commit success"
# - name: Prepair Push
# run: |
# echo "GITHUB_TOKEN=${{ secrets.GH_TOKEN }}" >> $GITHUB_ENV
# git push -f https://myyrakle:${{ secrets.REPORTS_GH_TOKEN }}@github.com/myyrakle/html_reports master
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_TOKEN }}
repository: myyrakle/html_reports
force: true
ref: master
- name: Add comment to PR
uses: thollander/actions-comment-pull-request@v1
with:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
message: |
✅ **Total Coverage**: ${{ env.COVERAGE }} |
![🔗 Coverage View](https://myyrakle.github.io/html_reports/${{ env.REPORT_NAME }})