-
Notifications
You must be signed in to change notification settings - Fork 5
140 lines (112 loc) · 3.88 KB
/
checks.yml
File metadata and controls
140 lines (112 loc) · 3.88 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
name: checks
on:
push:
branches:
- main
pull_request: {}
workflow_dispatch: {}
concurrency:
group: checks-${{ github.ref }}
cancel-in-progress: true
jobs:
Tests:
runs-on: ubuntu-latest
container:
image: ghcr.io/nodlecode/devcontainer-rollup
options: --user root
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: yarn
- name: Spell Check
run: yarn spellcheck
- name: Lint
run: yarn lint
- name: Run tests
run: forge test
Coverage:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.base_ref == 'main'
container:
image: ghcr.io/nodlecode/devcontainer-rollup
options: --user root
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: yarn
- name: Run coverage
run: forge coverage --match-path "test/{Swarm*,ServiceProvider,FleetIdentity}*.t.sol" --ir-minimum --report lcov --report-file coverage.lcov
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.lcov
retention-days: 30
- name: Install lcov
run: apt-get update && apt-get install -y lcov
- name: Report coverage to PR
uses: zgosalvez/github-actions-report-lcov@v4
with:
coverage-files: coverage.lcov
github-token: ${{ secrets.GITHUB_TOKEN }}
update-comment: true
working-directory: ./
- name: Check line coverage threshold
run: |
# Extract line coverage from lcov report for src/swarms/ contracts only
# Parse lcov format: find swarm file sections and sum their LF/LH values
LINES_FOUND=$(awk '
/^SF:.*src\/swarms\// { in_swarm = 1 }
/^end_of_record/ { in_swarm = 0 }
in_swarm && /^LF:/ { sum += substr($0, 4) }
END { print sum+0 }
' coverage.lcov)
LINES_HIT=$(awk '
/^SF:.*src\/swarms\// { in_swarm = 1 }
/^end_of_record/ { in_swarm = 0 }
in_swarm && /^LH:/ { sum += substr($0, 4) }
END { print sum+0 }
' coverage.lcov)
if [ "$LINES_FOUND" -eq 0 ]; then
echo "Error: No lines found in coverage report for src/swarms/"
exit 1
fi
COVERAGE=$(awk "BEGIN {printf \"%.2f\", ($LINES_HIT / $LINES_FOUND) * 100}")
echo "Swarms line coverage: $COVERAGE% ($LINES_HIT / $LINES_FOUND lines)"
# Check if coverage is below 95%
THRESHOLD=95
if awk "BEGIN {exit !($COVERAGE < $THRESHOLD)}"; then
echo "Error: Line coverage ($COVERAGE%) is below the required threshold ($THRESHOLD%)"
exit 1
fi
echo "Coverage check passed: $COVERAGE% >= $THRESHOLD%"
Specification-PDF:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.base_ref == 'main'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install npm dependencies
working-directory: src/swarms/doc/spec
run: npm install --no-save @mermaid-js/mermaid-cli md-to-pdf
- name: Install Puppeteer browser
run: npx puppeteer browsers install chrome
- name: Build specification PDF
working-directory: src/swarms/doc/spec
run: bash build.sh
- name: Upload specification PDF
uses: actions/upload-artifact@v4
with:
name: swarm-specification
path: src/swarms/doc/spec/swarm-specification.pdf
retention-days: 30