11name : coverage
2-
3- on :
2+ true :
43 push :
5- branches : [prerelease]
4+ branches :
5+ - prerelease
66 pull_request :
7- branches : [prerelease]
8-
7+ branches :
8+ - prerelease
99jobs :
1010 coverage-linux :
1111 strategy :
@@ -17,44 +17,48 @@ jobs:
1717 - arch : aarch64
1818 runner : ubuntu-24.04-arm
1919 runs-on : ${{ matrix.runner }}
20-
2120 steps :
2221 - uses : actions/checkout@v4
23-
2422 - name : Install dependencies
25- run : |
26- sudo apt-get update
23+ run : ' sudo apt-get update
24+
2725 sudo apt-get install -y lcov cmake build-essential
2826
27+ '
2928 - name : Configure
30- run : |
31- cmake -S . -B build -DENABLE_COVERAGE=ON
29+ run : ' cmake -S . -B build -DENABLE_COVERAGE=ON
3230
31+ '
3332 - name : Build
3433 run : cmake --build build
35-
3634 - name : Test
3735 run : ctest --test-dir build --output-on-failure
38-
3936 - name : Generate coverage report
40- run : |
41- lcov --capture --directory build --output-file coverage.info
42- lcov --ignore-errors unused --remove coverage.info '/usr/*' --output-file coverage.info
43- genhtml coverage.info --output-directory docs/coverage --title "yafl Code Coverage"
37+ run : ' lcov --capture --directory build --output-file coverage.info
38+
39+ lcov --ignore-errors unused --remove coverage.info '' /usr/*'' --output-file
40+ coverage.info
41+
42+ genhtml coverage.info --output-directory docs/coverage --title "yafl Code
43+ Coverage"
4444
45+ '
4546 - name : Generate coverage badge
46- run : |
47- chmod +x scripts/make_coverage_badge.sh
48- scripts/make_coverage_badge.sh docs/coverage_linux_${{ matrix.arch }}.svg coverage.info
47+ run : ' chmod +x scripts/make_coverage_badge.sh
4948
49+ scripts/make_coverage_badge.sh docs/coverage_linux_${{ matrix.arch }}.svg
50+ coverage.info
51+
52+ '
5053 - name : Upload Coverage Artifacts
5154 uses : actions/upload-artifact@v4
5255 with :
5356 name : coverage-linux-${{ matrix.arch }}
54- path : |
55- docs/coverage
57+ path : ' docs/coverage
58+
5659 docs/coverage_linux_${{ matrix.arch }}.svg
5760
61+ '
5862 coverage-windows :
5963 strategy :
6064 fail-fast : false
@@ -63,89 +67,64 @@ jobs:
6367 - arch : x86_64
6468 runner : windows-latest
6569 cmake_arch : x64
66- # Note: ARM64 Windows coverage skipped - OpenCppCoverage doesn't support ARM64 PE binaries
67- # ARM64 coverage is validated via Linux and macOS ARM64 coverage jobs
6870 runs-on : ${{ matrix.runner }}
6971 steps :
7072 - uses : actions/checkout@v4
71-
7273 - name : Install OpenCppCoverage
73- run : |
74- choco install opencppcoverage
75- echo "C:\Program Files (x86)\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
74+ run : ' choco install opencppcoverage
7675
77- - name : Configure
78- run : cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -A ${{ matrix.cmake_arch }}
76+ echo "C:\Program Files (x86)\OpenCppCoverage" | Out-File -FilePath $env:GITHUB_PATH
77+ -Encoding utf8 -Append
7978
79+ '
80+ - name : Configure
81+ run : cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -A ${{ matrix.cmake_arch
82+ }}
8083 - name : Build
8184 run : cmake --build build --config Debug
82-
8385 - name : Generate Coverage Report
84- run : |
85- # Find OpenCppCoverage installation
86- $opencppcoverage = Get-ChildItem -Path "C:\Program Files*" -Recurse -Filter "OpenCppCoverage.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
87- if (-not $opencppcoverage) {
88- Write-Error "OpenCppCoverage.exe not found"
89- exit 1
90- }
91- Write-Host "Using OpenCppCoverage from: $($opencppcoverage.FullName)"
92- & $opencppcoverage.FullName --sources "${{ github.workspace }}" --cover_children --export_type=html:build/coverage_report --export_type=cobertura:build/cobertura.xml -- ctest --test-dir build -C Debug --output-on-failure
86+ run : " # Find OpenCppCoverage installation\n $opencppcoverage = Get-ChildItem\
87+ \ -Path \" C:\\ Program Files*\" -Recurse -Filter \" OpenCppCoverage.exe\" \
88+ \ -ErrorAction SilentlyContinue | Select-Object -First 1\n if (-not $opencppcoverage)\
89+ \ {\n Write-Error \" OpenCppCoverage.exe not found\"\n exit 1\n }\n Write-Host\
90+ \ \" Using OpenCppCoverage from: $($opencppcoverage.FullName)\"\n & $opencppcoverage.FullName\
91+ \ --sources \" ${{ github.workspace }}\" --cover_children --export_type=html:build/coverage_report\
92+ \ --export_type=cobertura:build/cobertura.xml -- ctest --test-dir build\
93+ \ -C Debug --output-on-failure\n "
9394 shell : pwsh
94-
9595 - name : Generate Coverage Badge
9696 shell : powershell
97- run : |
98- if (-Not (Test-Path build/cobertura.xml)) { Write-Error "Cobertura XML not found"; exit 1 }
99- [xml]$xml = Get-Content build/cobertura.xml
100- $rate = $xml.coverage.'line-rate'
101- $percentage = [math]::Round([double]$rate * 100)
102-
103- if ($percentage -ge 90) { $color = "brightgreen" }
104- elseif ($percentage -ge 75) { $color = "yellow" }
105- else { $color = "red" }
106-
107- $svg = @"
108- <svg xmlns="http://www.w3.org/2000/svg" width="120" height="20">
109- <linearGradient id="b" x2="0" y2="100%">
110- <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
111- <stop offset="1" stop-opacity=".1"/>
112- </linearGradient>
113- <mask id="a">
114- <rect width="120" height="20" rx="3" fill="#fff"/>
115- </mask>
116- <g mask="url(#a)">
117- <rect width="70" height="20" fill="#555"/>
118- <rect x="70" width="50" height="20" fill="$color"/>
119- <rect width="120" height="20" fill="url(#b)"/>
120- </g>
121- <g fill="#fff" text-anchor="middle"
122- font-family="DejaVu Sans,Verdana,Geneva,sans-serif"
123- font-size="11">
124- <text x="35" y="14">coverage</text>
125- <text x="95" y="14">${percentage}%</text>
126- </g>
127- </svg>
128- "@
129-
130- New-Item -ItemType Directory -Force -Path docs
131- $badgePath = "docs/coverage_windows_${{ matrix.arch }}.svg"
132- Set-Content -Path $badgePath -Value $svg
133- if (Test-Path $badgePath) {
134- Write-Host "Badge created: $badgePath (${percentage}% coverage)"
135- Get-Content $badgePath | Select-Object -First 5
136- } else {
137- Write-Error "Failed to create badge file"
138- exit 1
139- }
140-
97+ run : " if (-Not (Test-Path build/cobertura.xml)) { Write-Error \" Cobertura\
98+ \ XML not found\" ; exit 1 }\n [xml]$xml = Get-Content build/cobertura.xml\n \
99+ $rate = $xml.coverage.'line-rate'\n $percentage = [math]::Round([double]$rate\
100+ \ * 100)\n\n if ($percentage -ge 90) { $color = \" brightgreen\" }\n elseif\
101+ \ ($percentage -ge 75) { $color = \" yellow\" }\n else { $color = \" red\" \
102+ \ }\n\n $svg = @\"\n <svg xmlns=\" http://www.w3.org/2000/svg\" width=\" 120\" \
103+ \ height=\" 20\" >\n <linearGradient id=\" b\" x2=\" 0\" y2=\" 100%\" >\n \
104+ \ <stop offset=\" 0\" stop-color=\" #bbb\" stop-opacity=\" .1\" />\n <stop\
105+ \ offset=\" 1\" stop-opacity=\" .1\" />\n </linearGradient>\n <mask id=\" \
106+ a\" >\n <rect width=\" 120\" height=\" 20\" rx=\" 3\" fill=\" #fff\" />\n \
107+ \ </mask>\n <g mask=\" url(#a)\" >\n <rect width=\" 70\" height=\" 20\" \
108+ \ fill=\" #555\" />\n <rect x=\" 70\" width=\" 50\" height=\" 20\" fill=\" \
109+ $color\" />\n <rect width=\" 120\" height=\" 20\" fill=\" url(#b)\" />\n \
110+ \ </g>\n <g fill=\" #fff\" text-anchor=\" middle\"\n font-family=\" DejaVu\
111+ \ Sans,Verdana,Geneva,sans-serif\"\n font-size=\" 11\" >\n <text x=\" \
112+ 35\" y=\" 14\" >coverage</text>\n <text x=\" 95\" y=\" 14\" >${percentage}%</text>\n \
113+ \ </g>\n </svg>\n\" @\n\n New-Item -ItemType Directory -Force -Path docs\n \
114+ $badgePath = \" docs/coverage_windows_${{ matrix.arch }}.svg\"\n Set-Content\
115+ \ -Path $badgePath -Value $svg\n if (Test-Path $badgePath) {\n Write-Host\
116+ \ \" Badge created: $badgePath (${percentage}% coverage)\"\n Get-Content\
117+ \ $badgePath | Select-Object -First 5\n } else {\n Write-Error \" Failed\
118+ \ to create badge file\"\n exit 1\n }\n "
141119 - name : Upload Coverage Report
142120 uses : actions/upload-artifact@v4
143121 with :
144122 name : coverage-windows-${{ matrix.arch }}
145- path : |
146- build/coverage_report
123+ path : ' build/coverage_report
124+
147125 docs/coverage_windows_${{ matrix.arch }}.svg
148126
127+ '
149128 coverage-macos :
150129 strategy :
151130 fail-fast : false
@@ -160,78 +139,82 @@ jobs:
160139 runs-on : ${{ matrix.runner }}
161140 steps :
162141 - uses : actions/checkout@v4
163-
164142 - name : Install dependencies
165143 run : brew install lcov
166-
167144 - name : Configure
168- run : |
169- cmake -S . -B build \
170- -DENABLE_COVERAGE=ON \
171- -DCMAKE_BUILD_TYPE=Debug \
172- -DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_arch }}
173-
145+ run : " cmake -S . -B build \\\n -DENABLE_COVERAGE=ON \\\n -DCMAKE_BUILD_TYPE=Debug\
146+ \ \\\n -DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_arch }}\n "
174147 - name : Build
175148 run : cmake --build build
176-
177149 - name : Test
178150 run : ctest --test-dir build --output-on-failure
179-
180151 - name : Create gcov wrapper
181- run : |
182- cat > /usr/local/bin/llvm-gcov << 'EOF'
152+ run : ' cat > /usr/local/bin/llvm-gcov << '' EOF ''
153+
183154 #!/bin/bash
155+
184156 exec xcrun llvm-cov gcov "$@"
157+
185158 EOF
159+
186160 chmod +x /usr/local/bin/llvm-gcov
187161
162+ '
188163 - name : Generate Coverage Report
189- run : |
190- lcov --gcov-tool llvm-gcov --capture --directory build --output-file coverage.info
191- lcov --gcov-tool llvm-gcov --ignore-errors unused --remove coverage.info '/usr/*' --output-file coverage.info
192- genhtml coverage.info --output-directory docs/coverage --title "yafl Code Coverage"
164+ run : ' lcov --gcov-tool llvm-gcov --capture --directory build --output-file
165+ coverage.info
166+
167+ lcov --gcov-tool llvm-gcov --ignore-errors unused --remove coverage.info
168+ '' /usr/*'' --output-file coverage.info
193169
170+ genhtml coverage.info --output-directory docs/coverage --title "yafl Code
171+ Coverage"
172+
173+ '
194174 - name : Generate Coverage Badge
195- run : |
196- chmod +x scripts/make_coverage_badge.sh
197- scripts/make_coverage_badge.sh docs/coverage_macos_${{ matrix.arch }}.svg coverage.info
175+ run : ' chmod +x scripts/make_coverage_badge.sh
176+
177+ scripts/make_coverage_badge.sh docs/coverage_macos_${{ matrix.arch }}.svg
178+ coverage.info
198179
180+ '
199181 - name : Upload Coverage Report
200182 uses : actions/upload-artifact@v4
201183 with :
202184 name : coverage-macos-${{ matrix.arch }}
203- path : |
204- docs/coverage
185+ path : ' docs/coverage
186+
205187 docs/coverage_macos_${{ matrix.arch }}.svg
206188
189+ '
207190 commit-badges :
208- needs : [coverage-linux, coverage-macos, coverage-windows]
191+ needs :
192+ - coverage-linux
193+ - coverage-macos
194+ - coverage-windows
209195 runs-on : ubuntu-latest
210196 if : always() && github.event_name == 'push' && github.ref == 'refs/heads/prerelease'
211197 steps :
212198 - uses : actions/checkout@v4
213-
214199 - name : Download all artifacts
215200 uses : actions/download-artifact@v4
216201 with :
217202 path : artifacts
218-
219203 - name : Move badges
220- run : |
221- mkdir -p docs
204+ run : ' mkdir -p docs
205+
222206 find artifacts -name "coverage_*.svg" -exec cp {} docs/ \;
223207
208+ '
224209 - name : Create GitHub Pages configuration
225- run : |
226- touch docs/.nojekyll
210+ run : ' touch docs/.nojekyll
227211
212+ '
228213 - name : Commit and push coverage badges
229- run : |
230- git config user.name "GitHub Actions"
231- git config user.email "actions@github.com"
232- git add docs/coverage_*.svg docs/.nojekyll
233- if git diff --quiet --cached; then
234- echo "No coverage badge changes to commit"
235- else
236- git commit -m "Update code coverage badges [skip ci]" && git push origin prerelease
237- fi
214+ run : " git config user.name \" GitHub Actions\"\n git config user.email \" actions@github.com\" \
215+ \n git add docs/coverage_*.svg docs/.nojekyll\n if git diff --quiet --cached;\
216+ \ then\n echo \" No coverage badge changes to commit\"\n else\n git commit\
217+ \ -m \" Update code coverage badges [skip ci]\" && git push origin prerelease\n \
218+ fi\n "
219+ env :
220+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 : ' true'
0 commit comments