-
Notifications
You must be signed in to change notification settings - Fork 0
282 lines (234 loc) · 9.19 KB
/
Copy pathpr-validation.yml
File metadata and controls
282 lines (234 loc) · 9.19 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
name: PR Validation
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "**.rs"
- "**/Cargo.toml"
- "**/Cargo.lock"
- ".github/workflows/pr-validation.yml"
permissions:
contents: read
pull-requests: write
issues: write
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
changes:
name: Detect Changes
runs-on: [self-hosted, linux, x64, light]
outputs:
validation: ${{ steps.filter.outputs.validation }}
core: ${{ steps.filter.outputs.core }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
validation:
- 'mcp-external-validation/**'
core:
- 'mcp-protocol/**'
- 'mcp-server/**'
- 'mcp-transport/**'
quick-validation:
name: Quick PR Validation
runs-on: [self-hosted, linux, x64, rust-cpu]
needs: changes
steps:
- name: Checkout PR
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@1.88
with:
components: rustfmt, clippy
- name: Log environment info
run: |
echo "Rust toolchain information:"
rustup show
echo "Rust version: $(rustc --version)"
echo "Cargo version: $(cargo --version)"
echo "Clippy version: $(cargo clippy --version)"
echo "Rustfmt version: $(cargo fmt --version)"
- name: Free up disk space
# Only needed on github-hosted; smithy redirects TMPDIR to a 500G volume.
if: runner.environment == 'github-hosted'
run: |
# Remove unnecessary tools and files to free up ~10GB
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
df -h
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-pr-quick-1.88-${{ hashFiles('**/Cargo.lock', 'rust-toolchain.toml') }}
restore-keys: |
${{ runner.os }}-cargo-pr-quick-1.88-
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clean procedural macro artifacts
run: |
# Clean procedural macro artifacts to prevent version conflicts
cargo clean -p pulseengine-mcp-macros
- name: Run clippy
run: |
# Use release mode to reduce disk usage (32GB debug vs ~2GB release)
cargo clippy --all-features --all-targets --release -- -D warnings
- name: Run tests
run: |
# Use release mode to reduce disk usage while testing everything
cargo test --all-features --release --verbose
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Clean previous coverage artifacts
run: |
# Remove previous coverage data but keep compiled dependencies
cargo llvm-cov clean --workspace
df -h
- name: Generate coverage report
run: |
cargo llvm-cov test --all-features --workspace --lcov --output-path lcov.info
cargo llvm-cov report --summary-only > coverage-summary.txt
COVERAGE=$(grep -oP '\d+\.\d+(?=%)' coverage-summary.txt | head -1)
echo "Coverage: $COVERAGE%"
- name: Check documentation
run: |
# Build docs for all packages
cargo doc --all-features --no-deps
- name: Cleanup cache before saving
run: |
echo "📊 Disk usage before cleanup:"
du -sh target || true
# Remove coverage-specific artifacts
rm -rf target/llvm-cov-target
rm -rf target/debug/.fingerprint/*-llvm-cov*
rm -rf target/*/debug/coverage*
# Remove test binaries (large and rebuilt every time)
find target -type f -name '*-????????????????' -executable -delete 2>/dev/null || true
# Remove incremental compilation data
rm -rf target/debug/incremental
rm -rf target/release/incremental
echo "📊 Disk usage after cleanup:"
du -sh target || true
validation-specific-tests:
name: Validation Framework Tests
runs-on: [self-hosted, linux, x64, rust-cpu]
needs: changes
if: needs.changes.outputs.validation == 'true'
steps:
- name: Checkout PR
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@1.88
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Python dependencies
run: |
pip install mcp aiohttp websockets pytest
- name: Run validation framework tests
run: |
# Use release mode to reduce disk usage
cargo test --package pulseengine-mcp-external-validation --all-features --release
- name: Run property tests
run: |
# Use release mode to reduce disk usage
cargo test --package pulseengine-mcp-external-validation --features proptest --release -- proptest --test-threads=1
- name: Test CLI tools
run: |
cargo build --package pulseengine-mcp-external-validation --bins
./target/debug/mcp-validate --help
./target/debug/mcp-compliance-report --help
compatibility-check:
name: Compatibility Check
runs-on: [self-hosted, linux, x64, rust-cpu]
needs: changes
if: needs.changes.outputs.core == 'true'
steps:
- name: Checkout PR
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@1.88
- name: Test validation tool CLI
run: |
# Test that the validation tools have correct CLI interfaces
cargo run --bin mcp-validate -- --help
cargo run --bin mcp-compliance-report -- --help
echo "✅ Validation tools CLI interfaces are correct"
# TODO: Add actual server validation once we have a proper HTTP test server
# - name: Run compatibility validation
# run: |
# cargo run --bin mcp-validate -- --server-url http://localhost:3000 --quick
pr-report:
name: Generate PR Report
runs-on: [self-hosted, linux, x64, light]
needs: [quick-validation, validation-specific-tests, compatibility-check]
if: always()
steps:
- name: Checkout PR
uses: actions/checkout@v4
- name: Create PR comment
uses: actions/github-script@v7
with:
script: |
const quickValidation = '${{ needs.quick-validation.result }}';
const validationTests = '${{ needs.validation-specific-tests.result }}';
const compatibilityCheck = '${{ needs.compatibility-check.result }}';
let comment = '## PR Validation Results\n\n';
// Quick validation
comment += `### Quick Validation: ${quickValidation === 'success' ? '✅' : '❌'}\n`;
comment += '- Format check\n';
comment += '- Clippy lints\n';
comment += '- Unit tests\n';
comment += '- Documentation\n\n';
// Validation framework tests
if (validationTests !== 'skipped') {
comment += `### Validation Framework: ${validationTests === 'success' ? '✅' : '❌'}\n`;
comment += '- Framework tests\n';
comment += '- Property-based tests\n';
comment += '- CLI tools\n\n';
}
// Compatibility check
if (compatibilityCheck !== 'skipped') {
comment += `### Compatibility Check: ${compatibilityCheck === 'success' ? '✅' : '❌'}\n`;
comment += '- Protocol compliance\n';
comment += '- Server compatibility\n\n';
}
// Summary
const allPassed = quickValidation === 'success' &&
(validationTests === 'success' || validationTests === 'skipped') &&
(compatibilityCheck === 'success' || compatibilityCheck === 'skipped');
comment += `### Summary: ${allPassed ? '✅ All checks passed' : '❌ Some checks failed'}\n`;
// Find existing comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' && comment.body.includes('PR Validation Results')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: comment
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: comment
});
}