Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
a1ed8bd
added covr2gh github action workflow
dragosmg Jul 8, 2026
817ef4a
cards is under pharmaverse now
dragosmg Jul 8, 2026
84fd99a
Merge branch 'main' into 623-coverage-pr-comment
dragosmg Jul 8, 2026
5399e62
solved `TEMP_row` note
dragosmg Jul 8, 2026
9849927
solved R CMD check note about `type`
dragosmg Jul 8, 2026
f05a9a1
solved R CMD check note about `var`
dragosmg Jul 8, 2026
79acbf3
undo formatting
dragosmg Jul 8, 2026
0188c5c
undo formatting
dragosmg Jul 8, 2026
3c11691
undo
dragosmg Jul 8, 2026
141d46e
undo
dragosmg Jul 8, 2026
668c70b
undo
dragosmg Jul 8, 2026
fbcdacf
undo
dragosmg Jul 8, 2026
2bb3913
undo
dragosmg Jul 8, 2026
2da4b99
undo
dragosmg Jul 8, 2026
bf12a81
undo
dragosmg Jul 8, 2026
1d036bb
undo
dragosmg Jul 8, 2026
69500f9
undo
dragosmg Jul 8, 2026
1c2b8fa
undo
dragosmg Jul 8, 2026
1479418
undo
dragosmg Jul 8, 2026
53d8d0b
undo
dragosmg Jul 8, 2026
6f95e90
undo
dragosmg Jul 8, 2026
5fc5af4
undo
dragosmg Jul 8, 2026
721d91c
undo
dragosmg Jul 8, 2026
a376c63
undo
dragosmg Jul 8, 2026
029cf63
undo
dragosmg Jul 8, 2026
9920118
undo
dragosmg Jul 8, 2026
4837672
undo
dragosmg Jul 8, 2026
9f84341
undo
dragosmg Jul 8, 2026
2250414
undo
dragosmg Jul 8, 2026
4a7bfdf
undo
dragosmg Jul 8, 2026
c8e52e1
undo
dragosmg Jul 8, 2026
055c237
undo
dragosmg Jul 8, 2026
7810b59
undo
dragosmg Jul 8, 2026
75a7570
undo
dragosmg Jul 8, 2026
7e0005f
undo
dragosmg Jul 8, 2026
e5e7ac0
undo
dragosmg Jul 8, 2026
d4985e8
undo
dragosmg Jul 8, 2026
827650a
undo
dragosmg Jul 8, 2026
390e4c1
undo
dragosmg Jul 8, 2026
0e978b0
undo
dragosmg Jul 8, 2026
ef54d01
undo
dragosmg Jul 8, 2026
fca6876
undo
dragosmg Jul 8, 2026
4cc886e
undo
dragosmg Jul 8, 2026
8b12ce3
undo
dragosmg Jul 8, 2026
7e9af06
undo
dragosmg Jul 8, 2026
66764be
undo
dragosmg Jul 8, 2026
15efcf3
undo
dragosmg Jul 8, 2026
3501e94
undo
dragosmg Jul 8, 2026
221ea01
undo
dragosmg Jul 8, 2026
95644e1
undo
dragosmg Jul 8, 2026
0fa7d41
undo
dragosmg Jul 8, 2026
201ca80
undo
dragosmg Jul 8, 2026
4f76484
undo
dragosmg Jul 8, 2026
82482ac
undo
dragosmg Jul 8, 2026
2e0c7d9
undo
dragosmg Jul 8, 2026
fa826d4
undo
dragosmg Jul 8, 2026
be448f2
undo
dragosmg Jul 8, 2026
fce3d1e
undo
dragosmg Jul 9, 2026
07b98fc
undo
dragosmg Jul 9, 2026
c3b5dd5
undo
dragosmg Jul 9, 2026
2c3b022
undo
dragosmg Jul 9, 2026
e429b0f
undo
dragosmg Jul 9, 2026
6220f34
undo
dragosmg Jul 9, 2026
1145920
undo
dragosmg Jul 9, 2026
68f1ef0
undo
dragosmg Jul 9, 2026
cd2e120
undo
dragosmg Jul 9, 2026
b5b9346
undo
dragosmg Jul 9, 2026
438aa76
undo
dragosmg Jul 9, 2026
9e4d223
undo
dragosmg Jul 9, 2026
b5182c9
undo
dragosmg Jul 9, 2026
83ea888
undo
dragosmg Jul 9, 2026
858ad7b
undo
dragosmg Jul 9, 2026
d3f8c5c
undo
dragosmg Jul 9, 2026
b2fd174
undo
dragosmg Jul 9, 2026
1a8d2d5
undo
dragosmg Jul 9, 2026
d69b644
undo
dragosmg Jul 9, 2026
7bf0a18
undo
dragosmg Jul 9, 2026
329ccbd
undo
dragosmg Jul 9, 2026
cc88cc0
undo
dragosmg Jul 9, 2026
34778a1
undo
dragosmg Jul 9, 2026
bc9b33f
undo
dragosmg Jul 9, 2026
dc68cd0
undo
dragosmg Jul 9, 2026
103e823
undo
dragosmg Jul 9, 2026
8a28602
undo
dragosmg Jul 9, 2026
21d1eae
undo
dragosmg Jul 9, 2026
2079fee
undo
dragosmg Jul 9, 2026
acd8110
undo
dragosmg Jul 9, 2026
ebe0b8f
undo
dragosmg Jul 9, 2026
4dcaa4e
undo
dragosmg Jul 9, 2026
1f72443
undo
dragosmg Jul 9, 2026
852f4e2
undo
dragosmg Jul 9, 2026
82c53ba
undo
dragosmg Jul 9, 2026
26e4bd6
undo
dragosmg Jul 9, 2026
dd10edd
undo
dragosmg Jul 9, 2026
29f7ca9
undo
dragosmg Jul 9, 2026
93f22dc
undo
dragosmg Jul 9, 2026
caa1b92
Merge branch 'main' into 623-coverage-pr-comment
alanahjonas95 Jul 13, 2026
a64439d
post a new comment (and delete the existing one)
dragosmg Jul 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 161 additions & 0 deletions .github/workflows/covr2gh.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Coverage summary 🦺

on:
push:
branches:
- main
pull_request:

# multiple workflows might try to write to covr2gh-storage at the same time
concurrency:
group: ${{ github.workflow }}-covr2gh-storage
cancel-in-progress: false # don't cancel, but queue jobs

permissions:
pull-requests: write # for commenting on PR
contents: write # for adding badges to the covr2gh-storage branch

jobs:
covr2gh:
name: Coverage & badge 🦺🎖️
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
BADGE_BRANCH: ${{ github.head_ref || github.ref_name }}
steps:
- name: Checkout repo 📥
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.head_ref || github.ref_name }}

- name: Setup R 🏗️
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Setup R dependencies 📦
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
any::covr
dragosmg/covr2gh
needs: coverage

- name: Head coverage & badge 🎩🎖️
run: |
temp_path <- normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/")

head_cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(temp_path, "package_head")
)

saveRDS(head_cov, file.path(temp_path, "head_cov.RDS"))

badge <- head_cov |>
covr::percent_coverage() |>
covr2gh::generate_badge()

writeLines(badge, file.path(temp_path, "coverage_badge.svg"))
shell: Rscript {0}

- name: Configure git identity 🪪
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Actions"

- name: Storage branch (worktree) 🌳
if: github.event.pull_request.head.repo.fork == false || github.event_name != 'pull_request'
run: |
ORIGINAL_REF="$(git rev-parse --abbrev-ref HEAD)"

# Attach or create storage branch
git fetch origin covr2gh-storage || true

if git show-ref --verify --quiet refs/remotes/origin/covr2gh-storage; then
git worktree add storage covr2gh-storage
else
git checkout --orphan covr2gh-storage
git reset --hard

mkdir -p badges
touch badges/.gitkeep
git add badges/.gitkeep

echo "# Coverage badges" > README.md
git add README.md
git commit -m "Initialize covr2gh-storage branch"
git push origin covr2gh-storage

git checkout "$ORIGINAL_REF"
git worktree add storage covr2gh-storage
fi

cd storage

# Commit badge
mkdir -p "badges/$BADGE_BRANCH"
cp "$RUNNER_TEMP/coverage_badge.svg" "badges/$BADGE_BRANCH/coverage_badge.svg"
git add badges
git commit -m "Add/Update badge for $BADGE_BRANCH ($GITHUB_SHA)" || true
git push origin covr2gh-storage || true
shell: bash

- name: Attach base branch worktree (PR only) 🌳
if: github.event_name == 'pull_request'
run: |
git fetch origin "${{ github.base_ref }}"
git worktree add base "${{ github.base_ref }}"

- name: Calculate base coverage (PR only) 🧱
if: github.event_name == 'pull_request'
working-directory: base
run: |
temp_path <- normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/")

base_cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(temp_path, "package_base")
)

saveRDS(base_cov, file.path(temp_path, "base_cov.RDS"))
shell: Rscript {0}

- name: Post coverage comment (PR only) ✍️💬
if: github.event_name == 'pull_request'
run: |
temp_path <- normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/")
head_cov <- readRDS(file.path(temp_path, "head_cov.RDS"))
base_cov <- readRDS(file.path(temp_path, "base_cov.RDS"))

comment <- covr2gh::compose_comment(
head_coverage = head_cov,
base_coverage = base_cov,
repo = "${{ github.repository }}",
pr_number = ${{ github.event.pull_request.number }}
)

covr2gh::post_comment(
comment,
repo = "${{ github.repository }}",
pr_number = ${{ github.event.pull_request.number }},
update = FALSE
)

writeLines(comment, file.path(temp_path, "comment.md"))
shell: Rscript {0}

- name: Cleanup worktrees 🌳✨
if: always()
run: |
git worktree remove storage --force || true
git worktree remove base --force || true
git worktree prune || true

- name: Job summary 📋
if: github.event_name == 'pull_request'
run: |
cat "$RUNNER_TEMP/comment.md" >> $GITHUB_STEP_SUMMARY
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Suggests:
survival,
testthat (>= 3.0.0),
withr
Remotes:
pharmaverse/cards
Config/testthat/edition: 3
Encoding: UTF-8
Language: en-GB
Expand Down
Loading