Merge pull request #163 from ndsev/release/2.0.0 #86
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Code Coverage | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| coverage: | |
| runs-on: ubuntu-latest | |
| container: ghcr.io/klebert-engineering/manylinux-cpp17-py3.11-x86_64:2025.1 | |
| env: | |
| ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Install coverage tools | |
| run: | | |
| pip install gcovr "h2>=4.1,<5" | |
| gcovr --version | |
| - name: Configure with coverage enabled | |
| run: | | |
| python3 -m venv venv && . ./venv/bin/activate | |
| pip install -U setuptools wheel pip "h2>=4.1,<5" | |
| mkdir build && cd build | |
| cmake -DCMAKE_BUILD_TYPE=Debug \ | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | |
| -DZSWAG_ENABLE_TESTING=ON \ | |
| -DZSWAG_ENABLE_COVERAGE=ON \ | |
| -DZSWAG_BUILD_WHEELS=OFF \ | |
| -DZSWAG_KEYCHAIN_SUPPORT=OFF .. | |
| - name: Build | |
| working-directory: build | |
| run: | | |
| . ../venv/bin/activate | |
| cmake --build . | |
| - name: Test | |
| working-directory: build | |
| run: | | |
| . ../venv/bin/activate | |
| ctest -C Debug --verbose --no-tests=error | |
| - name: Generate Coverage Reports | |
| run: | | |
| mkdir -p coverage | |
| gcovr \ | |
| --root . \ | |
| --filter 'libs/httpcl/(src|include)/.*' \ | |
| --filter 'libs/zswagcl/(src|include)/.*' \ | |
| --gcov-ignore-parse-errors=negative_hits.warn_once_per_file \ | |
| --html-details coverage/coverage.html | |
| gcovr \ | |
| --root . \ | |
| --filter 'libs/httpcl/(src|include)/.*' \ | |
| --filter 'libs/zswagcl/(src|include)/.*' \ | |
| --gcov-ignore-parse-errors=negative_hits.warn_once_per_file \ | |
| --cobertura coverage.xml \ | |
| --html coverage.html | |
| - name: Publish Coverage HTML | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-html-report | |
| path: coverage | |
| retention-days: 30 | |
| - name: Code Coverage Report | |
| uses: irongut/CodeCoverageSummary@v1.3.0 | |
| with: | |
| filename: coverage.xml | |
| badge: false | |
| fail_below_min: true | |
| format: markdown | |
| hide_branch_rate: false | |
| hide_complexity: true | |
| indicators: true | |
| output: both | |
| thresholds: '65 80' | |
| - name: Add Coverage PR Comment | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| if: github.event_name == 'pull_request' | |
| with: | |
| recreate: true | |
| path: code-coverage-results.md | |
| # ---------------------------------------------------------------------- | |
| # Publish HTML report to GitHub Pages (main pushes only). | |
| # Java coverage is deployed alongside by jzswag.yml under /java/; this | |
| # workflow writes /cpp/ + the root landing index.html. Both jobs use | |
| # peaceiris/actions-gh-pages with keep_files=true so they coexist. | |
| # ---------------------------------------------------------------------- | |
| - name: Stage C++ report for GitHub Pages | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| run: | | |
| mkdir -p site/cpp | |
| cp -r coverage/* site/cpp/ | |
| # gcovr writes its entry point as coverage.html; an index.html | |
| # redirect lets https://ndsev.github.io/zswag/cpp/ land on the report. | |
| cat > site/cpp/index.html <<'EOF' | |
| <!DOCTYPE html><meta http-equiv="refresh" content="0;url=coverage.html"> | |
| EOF | |
| # Root landing page linking to both language reports. | |
| cat > site/index.html <<'EOF' | |
| <!DOCTYPE html> | |
| <title>zswag coverage</title> | |
| <style>body{font-family:system-ui,sans-serif;max-width:40rem;margin:3rem auto;padding:0 1rem;line-height:1.5}</style> | |
| <h1>zswag coverage reports</h1> | |
| <ul> | |
| <li><a href="cpp/">C++</a> β httpcl + zswagcl (gcovr)</li> | |
| <li><a href="java/">Java</a> β jzswag-api / shared / jvm / android (JaCoCo)</li> | |
| </ul> | |
| <p>Aggregated coverage is also tracked on <a href="https://codecov.io/gh/ndsev/zswag">Codecov</a>.</p> | |
| EOF | |
| - name: Deploy to GitHub Pages | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: site | |
| keep_files: true |