Skip to content

Commit 9f8d9d0

Browse files
committed
Add coverage workflow and badge
1 parent 592e948 commit 9f8d9d0

File tree

2 files changed

+125
-3
lines changed

2 files changed

+125
-3
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#
2+
# Copyright (c) 2026 Sam Darwin
3+
# Copyright (c) 2026 Alexander Grund
4+
#
5+
# Distributed under the Boost Software License, Version 1.0. (See accompanying
6+
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7+
#
8+
9+
# Instructions
10+
#
11+
# After running this workflow successfully, go to https://github.com/ORGANIZATION/REPO/settings/pages
12+
# and enable github pages on the code-coverage branch.
13+
# The pages will be hosted at https://ORGANIZATION.github.io/REPO
14+
#
15+
16+
name: Code Coverage
17+
18+
on:
19+
push:
20+
branches:
21+
- master
22+
- develop
23+
paths:
24+
- 'src/**'
25+
- 'include/**'
26+
- '.github/workflows/code-coverage.yml'
27+
workflow_dispatch:
28+
29+
env:
30+
GIT_FETCH_JOBS: 8
31+
NET_RETRY_COUNT: 5
32+
# Commit title of the automatically created commits
33+
GCOVR_COMMIT_MSG: "Update coverage data"
34+
# Should branch coverage be reported? Default to no.
35+
BOOST_BRANCH_COVERAGE: 0
36+
37+
jobs:
38+
build:
39+
defaults:
40+
run:
41+
shell: bash
42+
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
include:
47+
- runs-on: "ubuntu-24.04"
48+
name: Coverage
49+
cxxstd: "20"
50+
gcovr_script: './ci-automation/scripts/lcov-jenkins-gcc-13.sh --only-gcovr'
51+
52+
name: ${{ matrix.name }}
53+
runs-on: ${{ matrix.runs-on }}
54+
timeout-minutes: 120
55+
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v6
59+
60+
- name: Check for code-coverage Branch
61+
run: |
62+
set -xe
63+
git config --global user.name cppalliance-bot
64+
git config --global user.email cppalliance-bot@example.com
65+
git fetch origin
66+
if git branch -r | grep origin/code-coverage; then
67+
echo "The code-coverage branch exists. Continuing."
68+
else
69+
echo "The code-coverage branch does not exist. Creating it."
70+
git switch --orphan code-coverage
71+
git commit --allow-empty -m "$GCOVR_COMMIT_MSG"
72+
git push origin code-coverage
73+
git checkout $GITHUB_REF_NAME
74+
fi
75+
76+
- name: Install Python
77+
uses: actions/setup-python@v6
78+
with:
79+
python-version: '3.13'
80+
81+
- name: Install Python packages
82+
run: pip install gcovr
83+
84+
- name: Checkout ci-automation
85+
uses: actions/checkout@v6
86+
with:
87+
repository: cppalliance/ci-automation
88+
path: ci-automation
89+
90+
- name: Build and run tests & collect coverage data
91+
run: |
92+
set -xe
93+
ls -al
94+
export ORGANIZATION=${GITHUB_REPOSITORY_OWNER}
95+
export REPONAME=$(basename ${GITHUB_REPOSITORY})
96+
export B2_CXXSTD=${{matrix.cxxstd}}
97+
${{matrix.gcovr_script}}
98+
99+
- name: Checkout GitHub pages branch
100+
uses: actions/checkout@v6
101+
with:
102+
ref: code-coverage
103+
path: gh_pages_dir
104+
105+
- name: Copy gcovr results
106+
run: |
107+
set -xe
108+
pwd
109+
ls -al
110+
touch gh_pages_dir/.nojekyll # Prevent GH pages from treating these files as Jekyll pages.
111+
mkdir -p gh_pages_dir/develop
112+
mkdir -p gh_pages_dir/master
113+
rm -rf "gh_pages_dir/${GITHUB_REF_NAME}/gcovr"
114+
cp -rp gcovr gh_pages_dir/${GITHUB_REF_NAME}/
115+
echo -e "<html>\n<head>\n</head>\n<body>\n<a href=develop/index.html>develop</a><br>\n<a href=master/index.html>master</a><br>\n</body>\n</html>\n" > gh_pages_dir/index.html
116+
# In the future: echo -e "<html>\n<head>\n</head>\n<body>\n<a href=gcovr/index.html>gcovr</a><br>\n</body>\n</html>\n" > gh_pages_dir/develop/index.html
117+
echo -e "<html>\n<head>\n<meta http-equiv=\"refresh\" content=\"0; url=./gcovr/index.html\">\n</head>\n<body>\n</body>\n</html>\n" > gh_pages_dir/develop/index.html
118+
cp gh_pages_dir/develop/index.html gh_pages_dir/master/index.html
119+
cd gh_pages_dir
120+
git add .
121+
git commit --amend -m "$GCOVR_COMMIT_MSG"
122+
git push -f origin code-coverage

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[![Boost.HTTP](doc/modules/ROOT/images/repo-logo.png)](http://master.http.cpp.al/)
22

3-
| | Docs | GitHub Actions | Drone | Codecov |
3+
| | Docs | GitHub Actions | Drone | Code Coverage |
44
|---|---|---|---|---|
5-
| [`master`](https://github.com/cppalliance/http/tree/master) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](https://master.http.cpp.al/) | [![CI](https://github.com/cppalliance/http/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/cppalliance/http/actions/workflows/ci.yml?query=branch%3Amaster) | [![Build Status](https://drone.cpp.al/api/badges/cppalliance/http/status.svg?ref=refs/heads/master)](https://drone.cpp.al/cppalliance/http/branches) | [![codecov](https://codecov.io/gh/cppalliance/http/branch/master/graph/badge.svg)](https://app.codecov.io/gh/cppalliance/http/tree/master) |
6-
| [`develop`](https://github.com/cppalliance/http/tree/develop) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](https://develop.http.cpp.al/) | [![CI](https://github.com/cppalliance/http/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/cppalliance/http/actions/workflows/ci.yml?query=branch%3Adevelop) | [![Build Status](https://drone.cpp.al/api/badges/cppalliance/http/status.svg?ref=refs/heads/develop)](https://drone.cpp.al/cppalliance/http/branches) | [![codecov](https://codecov.io/gh/cppalliance/http/branch/develop/graph/badge.svg)](https://app.codecov.io/gh/cppalliance/http/tree/develop) |
5+
| [`master`](https://github.com/cppalliance/http/tree/master) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](https://master.http.cpp.al/) | [![CI](https://github.com/cppalliance/http/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/cppalliance/http/actions/workflows/ci.yml?query=branch%3Amaster) | [![Build Status](https://drone.cpp.al/api/badges/cppalliance/http/status.svg?ref=refs/heads/master)](https://drone.cpp.al/cppalliance/http/branches) | [![Lines](https://cppalliance.org/http/master/gcovr/badges/coverage-lines.svg)](https://cppalliance.org/http/master/gcovr/index.html) |
6+
| [`develop`](https://github.com/cppalliance/http/tree/develop) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](https://develop.http.cpp.al/) | [![CI](https://github.com/cppalliance/http/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/cppalliance/http/actions/workflows/ci.yml?query=branch%3Adevelop) | [![Build Status](https://drone.cpp.al/api/badges/cppalliance/http/status.svg?ref=refs/heads/develop)](https://drone.cpp.al/cppalliance/http/branches) | [![Lines](https://cppalliance.org/http/develop/gcovr/badges/coverage-lines.svg)](https://cppalliance.org/http/develop/gcovr/index.html) |
77

88
## Boost.HTTP
99

0 commit comments

Comments
 (0)