Repository navigation
82 lines (68 loc) · 2.64 KB
/
Copy pathcontract-tests.yml
File metadata and controls
82 lines (68 loc) · 2.64 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
name: Contract Integration Tests
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
contract-tests:
name: Mocked Stellar SDK Contract Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: '9.0.0'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run contract integration tests with coverage
run: pnpm exec vitest run __tests__/contract --reporter=verbose --coverage
env:
CI: true
- name: Enforce 90% coverage on contract layer
run: |
node -e "
const fs = require('fs');
try {
const cov = JSON.parse(fs.readFileSync('./coverage/coverage-summary.json', 'utf8'));
const files = Object.keys(cov).filter(k => k.includes('utils/soroban') || k.includes('utils/contract-stats') || k.includes('utils/governance') || k.includes('lib/contract'));
if (files.length === 0) {
console.error('ERROR: No contract layer files found in coverage report');
console.error('Expected to find files matching: utils/soroban, utils/contract-stats, utils/governance, or lib/contract');
process.exit(1);
}
console.log('Files counted toward coverage threshold:');
files.forEach(f => console.log(' ' + f));
console.log('');
const lines = files.reduce((acc, f) => {
acc.total += cov[f].lines.total;
acc.covered += cov[f].lines.covered;
return acc;
}, { total: 0, covered: 0 });
const coverage = Math.round((lines.covered / lines.total) * 100);
console.log('Contract layer coverage: ' + coverage + '%');
if (coverage < 90) {
console.error('FAIL: Coverage ' + coverage + '% is below the 90% threshold');
process.exit(1);
}
} catch(e) {
console.error('ERROR: Failed to read or parse coverage report');
console.error(e.message);
process.exit(1);
}
"
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: contract-coverage
path: coverage/
retention-days: 14