-
Notifications
You must be signed in to change notification settings - Fork 4
112 lines (96 loc) · 3.82 KB
/
llvm-cov.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
104
105
106
107
108
109
110
111
112
---
name: llvm-cov
# Controls when the action will run.
on:
pull_request:
permissions: read-all
jobs:
produce-coverage-info:
outputs:
uncovered_lines: ${{ steps.coverage.outputs.uncovered_lines }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Set-Up
run: |
# https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt#option-1-install-with-one-command
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
- name: Install protobuf
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure rustc version
run: |
RUSTC_VERSION=$(grep channel rust-toolchain.toml | tail -n1 | tr -d " " | cut -f2 -d'"')
echo "RUSTC_VERSION=$RUSTC_VERSION" >> "$GITHUB_ENV"
- name: Install Rust toolchain
uses: gluwa/toolchain@dev
with:
toolchain: ${{ env.RUSTC_VERSION }}
components: llvm-tools-preview
target: wasm32-unknown-unknown
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
- name: Install cargo-llvm-cov
uses: taiki-e/[email protected]
with:
tool: cargo-llvm-cov
- name: Run tests
id: coverage
run: |
PR_NUMBER=$(echo "$GITHUB_REF" | sed "s|refs/pull/||" | sed "s|/merge||")
DESTINATION_PATH="creditcoin3/PR-$PR_NUMBER"
export DESTINATION_PATH
echo "**For full LLVM coverage report [click here](https://staticsitellvmhtml.z13.web.core.windows.net/$DESTINATION_PATH/html/)!**" > uncovered-lines.log
cargo llvm-cov --features=runtime-benchmarks \
--workspace --html --show-missing-lines --hide-instantiations \
--ignore-filename-regex "(tests.rs|mock.rs)"
UNCOVERED_LINES=$(sed "s|$(pwd)|.|" uncovered-lines.log)
# workaround the fact that GitHub Actions doesn't support multi-line output
# https://trstringer.com/github-actions-multiline-strings/
UNCOVERED_LINES="${UNCOVERED_LINES//'%'/'%25'}"
UNCOVERED_LINES="${UNCOVERED_LINES//$'\n'/'%0A'}"
UNCOVERED_LINES="${UNCOVERED_LINES//$'\r'/'%0D'}"
echo "uncovered_lines=$UNCOVERED_LINES" >> "$GITHUB_OUTPUT"
- name: Azure login
if: env.GITHUB_TOKEN
env:
GITHUB_TOKEN: ${{ secrets.CREDITCOIN_GITHUB_API_TOKEN }}
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
allow-no-subscriptions: true
- name: Upload coverage report to Azure Storage
if: env.GITHUB_TOKEN
env:
GITHUB_TOKEN: ${{ secrets.CREDITCOIN_GITHUB_API_TOKEN }}
run: |
AZURE_STORAGE_KEY=${{ secrets.LLVM_AZURE_STORAGE_KEY }}
export AZURE_STORAGE_KEY
PR_NUMBER=$(echo "$GITHUB_REF" | sed "s|refs/pull/||" | sed "s|/merge||")
DESTINATION_PATH="creditcoin3/PR-$PR_NUMBER"
export DESTINATION_PATH
az storage blob upload-batch --account-name staticsitellvmhtml --auth-mode key -d "\$web" --destination-path "$DESTINATION_PATH" --overwrite -s ./target/llvm-cov
- name: Upload coverage report as artifact
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: target/llvm-cov/html/
upload-coverage-info:
needs:
- produce-coverage-info
runs-on: ubuntu-24.04
permissions:
pull-requests: write
steps:
- name: Post comment to PR
if: env.GITHUB_TOKEN
uses: mshick/add-pr-comment@v2
env:
GITHUB_TOKEN: ${{ secrets.CREDITCOIN_GITHUB_API_TOKEN }}
with:
message: ${{ needs.produce-coverage-info.outputs.uncovered_lines }}
allow-repeats: false