-
Notifications
You must be signed in to change notification settings - Fork 10
213 lines (201 loc) · 7.37 KB
/
rust.yml
File metadata and controls
213 lines (201 loc) · 7.37 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
on:
push:
branches:
- master
- 'v**-dev'
pull_request:
name: Continuous integration
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
spv_tests:
name: SPV Components Tests
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-22.04-arm
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Test dash-spv crate (capture log)
id: spvtest
shell: bash
run: |
set +e
set -o pipefail
cargo test -p dash-spv --all-features 2>&1 | tee spv_test.log
status=${PIPESTATUS[0]}
echo "status=$status" >> "$GITHUB_OUTPUT"
if grep -qE 'SIGSEGV|signal: 11' spv_test.log; then
echo "segv=true" >> "$GITHUB_OUTPUT"
else
echo "segv=false" >> "$GITHUB_OUTPUT"
fi
# Always continue; follow-up steps decide based on outputs
exit 0
- name: Upload dash-spv test log
if: always()
uses: actions/upload-artifact@v4
with:
name: dash-spv-test-log
path: spv_test.log
- name: Scan for segfault culprit (dash-spv)
id: segvscan
if: ${{ steps.spvtest.outputs.segv == 'true' }}
shell: bash
run: |
set +e
echo "Detected SIGSEGV in parallel run; scanning tests sequentially..."
# List all tests for the crate
mapfile -t TESTS < <(cargo test -p dash-spv --all-features -- --list | sed -n 's/^\(.*\) ... .*/\1/p')
echo "Found ${#TESTS[@]} tests"
: > segv_scan.log
SEGV_TESTS=()
# Retry isolation up to 3 times to catch flaky crashes
for attempt in 1 2 3; do
echo "=== Isolation attempt $attempt/3 ===" | tee -a segv_scan.log
FOUND_THIS_ATTEMPT=()
for t in "${TESTS[@]}"; do
echo "--- Running $t (single-threaded) ---" | tee -a segv_scan.log
# Run test in isolation, single-threaded to improve determinism
cargo test -p dash-spv --all-features -- --nocapture --test-threads=1 "$t" 2>&1 | tee -a segv_scan.log
rc=${PIPESTATUS[0]}
if [ "$rc" -ne 0 ]; then
if tail -n 200 segv_scan.log | grep -qE 'SIGSEGV|signal: 11'; then
FOUND_THIS_ATTEMPT+=("$t")
SEGV_TESTS+=("$t")
fi
fi
done
if [ ${#FOUND_THIS_ATTEMPT[@]} -gt 0 ]; then
echo "Attempt $attempt found segfaulting tests: ${FOUND_THIS_ATTEMPT[*]}" | tee -a segv_scan.log
break
else
echo "Attempt $attempt found no segfaulting tests" | tee -a segv_scan.log
fi
done
if [ ${#SEGV_TESTS[@]} -eq 0 ]; then
echo "No consistent segfaulting tests found after 3 attempts" | tee -a segv_scan.log
fi
# De-duplicate the list for output
if [ ${#SEGV_TESTS[@]} -gt 0 ]; then
mapfile -t SEGV_UNIQ < <(printf "%s\n" "${SEGV_TESTS[@]}" | awk 'NF' | sort -u)
else
SEGV_UNIQ=()
fi
printf "%s\n" "Segfaulting tests detected: ${SEGV_UNIQ[*]-none}" | tee -a segv_scan.log
# Write outputs for later steps
{
echo 'segv_tests<<EOF'
printf "%s\n" "${SEGV_UNIQ[@]}"
echo 'EOF'
} >> "$GITHUB_OUTPUT"
# Save scan log
echo "scan_log=segv_scan.log" >> "$GITHUB_OUTPUT"
- name: Upload segv scan log
if: ${{ steps.spvtest.outputs.segv == 'true' }}
uses: actions/upload-artifact@v4
with:
name: dash-spv-segv-scan-log
path: segv_scan.log
- name: Comment segfault summary on PR
if: ${{ github.event_name == 'pull_request' && steps.spvtest.outputs.segv == 'true' }}
uses: actions/github-script@v7
with:
script: |
const tests = `${{ steps.segvscan.outputs.segv_tests }}`.trim();
const lines = tests ? tests.split(/\r?\n/).filter(Boolean) : [];
const body = lines.length
? `⚠️ SPV tests hit a SIGSEGV. Candidates (single-threaded isolation):\n\n${lines.map(t => `- ${t}`).join('\n')}`
: `⚠️ SPV tests hit a SIGSEGV, but single-test isolation found no consistent culprit. See artifacts for logs.`;
const issue_number = context.payload.pull_request.number;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number,
body,
});
- name: Fail job if initial tests failed
if: ${{ steps.spvtest.outputs.status != '0' }}
run: |
echo "Initial dash-spv tests failed with status ${{ steps.spvtest.outputs.status }}" >&2
exit 1
- name: Test dash-spv-ffi crate
run: cargo test -p dash-spv-ffi --all-features
key_wallet_tests:
name: Key Wallet Components Tests
runs-on: ubuntu-22.04-arm
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Test key-wallet crate
run: cargo test -p key-wallet --all-features
- name: Test key-wallet-manager crate
run: cargo test -p key-wallet-manager --all-features
- name: Test key-wallet-ffi crate
run: cargo test -p key-wallet-ffi --all-features
core_components_tests:
name: Core Components Tests
runs-on: ubuntu-22.04-arm
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Test dashcore crate
run: cargo test -p dashcore --all-features
- name: Test dashcore_hashes crate
run: cargo test -p dashcore_hashes --all-features
- name: Test dash-network crate
run: cargo test -p dash-network --all-features
- name: Test internals crate
run: cargo test -p dashcore-private --all-features
- name: Run script-based tests
run: ./contrib/test.sh
rpc_tests:
name: RPC Tests
runs-on: ubuntu-22.04-arm
strategy:
matrix:
include:
- rust: stable
env:
PIN_VERSIONS: true
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Running test script
env: ${{ matrix.env }}
run: ./contrib/test.sh
integrations_tests:
name: Integration Tests
if: ${{ false }} # Temporarily disabled
runs-on: ubuntu-22.04-arm
strategy:
matrix:
rust: [stable]
dashversion: ["22.1.3"]
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Running test script
env:
DASHVERSION: ${{ matrix.dashversion }}
run: ./contrib/test-rpc.sh