forked from angr/angr
-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (185 loc) · 7.15 KB
/
coverage.yml
File metadata and controls
193 lines (185 loc) · 7.15 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Test with coverage
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
env:
SKIP_SLOW_TESTS: 1
RUSTFLAGS: "-C instrument-coverage -C codegen-units=1 -C link-dead-code"
LLVM_PROFILE_FILE: "%p-%m.profraw"
CFLAGS: "--coverage -O0 -g"
LDFLAGS: "--coverage -g"
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
- uses: astral-sh/setup-uv@ed21f2f24f8dd64503750218de024bcf64c7250a # v6
with:
python-version: "3.10"
- name: Restore test durations cache
uses: actions/cache/restore@v4
with:
path: test_durations.json
key: cov-test-durations-${{ github.sha }}
restore-keys: cov-test-durations-
- name: Build
run: uv sync -v -p 3.10 --all-groups
- name: Archive environment
run: tar -cpf /tmp/env.tzst --absolute-names --zstd $PWD $UV_CACHE_DIR $UV_PYTHON_INSTALL_DIR
- name: Upload environment artifact
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v4
with:
name: env
path: /tmp/env.tzst
if-no-files-found: error
compression-level: 0
test:
needs: [build]
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
runner_id: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
steps:
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
name: env
path: .
- name: Extract environment
run: |
tar -xpf $PWD/env.tzst -C /
rm env.tzst
- name: Download test binaries
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4
with:
repository: angr/binaries
path: binaries
- name: Relocate binaries directory
run: mv binaries ..
- name: Run tests
run: |
source .venv/bin/activate
pytest -vv \
-n auto --splits 10 --group ${{ matrix.runner_id }} --splitting-algorithm=least_duration \
--cov=angr --cov=tests --cov-report=xml \
--junitxml=junit.xml -o junit_family=legacy \
--store-durations --clean-durations --durations-path=test_durations.json \
|| [[ $? -lt 2 ]] # Accept success and test failures, fail on infrastructure problems (exit codes >1)
gcovr -r native --print-summary --xml-pretty -o coverage-native.xml
- name: Check for results
run: |
[[ -e junit.xml && -e coverage.xml && -e coverage-native.xml && -e test_durations.json ]]
- name: Upload results artifact
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: results-${{ matrix.runner_id }}
if-no-files-found: error
path: |
./junit.xml
./coverage.xml
./coverage-native.xml
./test_durations.json
./*.profraw
test_rust:
name: Test Rust packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1
- uses: taiki-e/install-action@cf46383a970594553a83cc6140075ef6a7f54dee # v2
with:
tool: cargo-llvm-cov
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v5
with:
python-version: "3.10"
- name: Run tests
run: |
cargo test --release
cargo llvm-cov --lcov --output-path lcov.info
- name: Upload results artifact
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: results-rust
if-no-files-found: error
path: lcov.info
report:
name: Report
runs-on: ubuntu-latest
permissions:
id-token: write
checks: write
needs: [test, test_rust]
steps:
- name: Download environment
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
name: env
path: .
- name: Extract environment
run: |
tar -xpf $PWD/env.tzst -C /
rm env.tzst
- name: Download results
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
pattern: "results-*"
path: results
- name: Combine Rust coverage
run: |
find results
# XXX: Workaround slow `Processing triggers for man-db...`
echo 'set man-db/auto-update false' | sudo debconf-communicate
sudo dpkg-reconfigure man-db
sudo apt-get install -qq llvm-20 llvm-20-tools
echo "Merging coverage..."
llvm-profdata-20 merge -sparse $(find . -name '*.profraw') -o default.profdata
echo "Generating report..."
llvm-cov-20 report ./angr/rustylib*.so -instr-profile=default.profdata --sources $(find native -name "*.rs")
llvm-cov-20 export ./angr/rustylib*.so -instr-profile=default.profdata --sources $(find native -name "*.rs") --format=lcov > lcov-py.info
- name: Collect results
id: files
run: |
coverage=$(find . -type f \( -name 'coverage*.xml' -o -name 'lcov*.info' \) | paste -sd, -)
echo "coverage=$coverage" >> "$GITHUB_OUTPUT"
junit=$(find . -type f -name 'junit.xml' | paste -sd, -)
echo "junit=$junit" >> "$GITHUB_OUTPUT"
- name: Upload test coverage to Codecov
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5
with:
use_oidc: true
fail_ci_if_error: true
verbose: true
files: ${{ steps.files.outputs.coverage }}
- name: Upload test results to Codecov
uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1
with:
use_oidc: true
fail_ci_if_error: true
verbose: true
files: ${{ steps.files.outputs.junit }}
- name: Combine test durations
run: jq -Ss 'add' results/**/test_durations.json > test_durations.json
- name: Upload combined test durations artifact
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: test_durations
path: ./test_durations.json
if-no-files-found: error
- name: Update test durations cache
uses: actions/cache/save@v4
with:
path: test_durations.json
key: cov-test-durations-${{ github.sha }}
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@34d7c956a59aed1bfebf31df77b8de55db9bbaaf # v2
with:
files: "results/**/junit.xml"
action_fail_on_inconclusive: true
comment_mode: off # codecov already leaves a comment, and more details
# from this action can be found in the check it creates.