Skip to content

Commit 8bfe21e

Browse files
authored
Create empty code-coverage branch and allow custom commit message (#318)
* Create empty `code-coverage` branch and allow custom commit message Use `--orphan` instead of using the current branchs content and history. Set the commit title in an environment variable and only amend commits with that title to allow for custom commits. * Add explaining comments for coverage commit overwrite * Always amend last commit of coverage branch Avoids people treating this branch as permanent in any way.
1 parent 5512491 commit 8bfe21e

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

.github/workflows/code-coverage.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#
22
# Copyright (c) 2026 Sam Darwin
3+
# Copyright (c) 2026 Alexander Grund
34
#
45
# Distributed under the Boost Software License, Version 1.0. (See accompanying
56
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -28,6 +29,8 @@ on:
2829
env:
2930
GIT_FETCH_JOBS: 8
3031
NET_RETRY_COUNT: 5
32+
# Commit title of the automatically created commits
33+
GCOVR_COMMIT_MSG: "Update coverage data"
3134

3235
jobs:
3336
build:
@@ -62,7 +65,8 @@ jobs:
6265
echo "The code-coverage branch exists. Continuing."
6366
else
6467
echo "The code-coverage branch does not exist. Creating it."
65-
git checkout -b code-coverage
68+
git switch --orphan code-coverage
69+
git commit --allow-empty -m "$GCOVR_COMMIT_MSG"
6670
git push origin code-coverage
6771
git checkout $GITHUB_REF_NAME
6872
fi
@@ -111,5 +115,5 @@ jobs:
111115
cp gh_pages_dir/develop/index.html gh_pages_dir/master/index.html
112116
cd gh_pages_dir
113117
git add .
114-
git commit --amend -m code-coverage
118+
git commit --amend -m "$GCOVR_COMMIT_MSG"
115119
git push -f origin code-coverage

docs/code-coverage.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Copy the file `.github/workflows/code-coverage.yml` from boost-ci into your Boos
1111

1212
Run the workflow at least once, which can be done [manually](https://docs.github.com/actions/how-tos/manage-workflow-runs/manually-run-a-workflow).
1313
This will create a branch called "code-coverage" to store reports.
14+
On this branch a single commit will be created and updated (amended) with every run of the workflow to reduce the size of the repository.
15+
Hence it is not intended for other commits as the last one will always be changed.
1416

1517
Next, enable GitHub Pages. Go to https://github.com/ORGANIZATION/REPO/settings/pages and enable the new branch.
1618

0 commit comments

Comments
 (0)