ThinkR-open / golem

A Framework for Building Robust Shiny Apps
https://thinkr-open.github.io/golem/
Other
885 stars 130 forks source link

feature: use codecov badge depending on the current git branch #1087

Closed ilyaZar closed 4 months ago

ilyaZar commented 11 months ago

Fix #1086

This PR implements a changing codecov status badge dependening on the current git-branch of the {golem} projects.

README.Rmd is altered to programmatically retrieve the current git branch and alter links to point to the correct coverage results from https://about.codecov.io/ for the svg-images and webpages.

VincentGuyader commented 11 months ago

hi,

dont thinks It will works because we never push directly to master branch. the readme.md file will come from another branch, no ?

ilyaZar commented 11 months ago

hi,

@VincentGuyader hmm tricky.

I think it should work because the CI rebuilds README.Rmd which generates README.md on any branch.

e.g. on the current dev the codecov is 84% as generated via covr::package_covereage() whereas on the current master it is 69% and we see this in the "About"-readme section.

If this is the case, then the README.md is branch dependent. And then the only thing which is tricky is the CI finding the git branch via system("git symbolic-ref --short HEAD", intern = TRUE).

EDIT:

Maybe just try? I can fix any mistakes, it would be great to have different codecov-badges for dev and master really.

Do you mean the CI is not triggered when you merge from dev to master but rather you copy the file README.md (which comes from dev) directly in a merge?

VincentGuyader commented 11 months ago

Actually, I was only talking about the GitHub homepage... I hadn't thought that you were referring to pkgdown, etc... so it's not that straightforward, let's try to find a way to have both?

It would indeed be cool to have different coverage based on the branch.

ilyaZar commented 11 months ago

@VincentGuyader so breaking up the problem

  1. regarding the standard github page I tried the commit 51113f0c6abd4432a7409563cf7ee0195fb40243

    • I just pushed a workflow that rebuilds the README.md from README.Rmd
    • it's taken from r-libs/actions/examples/render-rmarkdown.yaml with some modifications to only render the README.Rmd
    • it is probably not using the correct git configs i.e. there is to fill correctly:
        git config --local user.name "$GITHUB_ACTOR"
        git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"

      at the bottom of the *.yaml

  2. regarding pkgdown: maybe it gets an automatic update from that as well but I have not had the time to look into this file yet

ColinFay commented 4 months ago

Let's try and merge it to an intermediate branch

ColinFay commented 4 months ago

I can confirm that it works, merging to dev soon

ColinFay commented 4 months ago

Now in dev https://github.com/ThinkR-open/golem/pull/1133