From 1d0da590a5f7465777c5093c646259a1f3a18442 Mon Sep 17 00:00:00 2001 From: Patrick R Date: Tue, 26 Aug 2025 11:08:35 +0200 Subject: [PATCH] Fixes coverage reporting and limits it to main branches only --- .buildlibrary | 2 +- .github/workflows/check.yaml | 24 +++++++++++++++++++++++- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- README.md | 8 ++++---- inst/extdata/check.yaml | 24 +++++++++++++++++++++++- 6 files changed, 55 insertions(+), 11 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 39e045b..c20fd69 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '10495100' +ValidationKey: '10569520' AutocreateReadme: yes AutocreateCITATION: yes AcceptedWarnings: diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 89c8e53..e7ef0c4 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -60,9 +60,31 @@ jobs: lucode2::check(runLinter = FALSE) - name: Test coverage + if: ${{ github.event_name != 'pull_request' }} shell: Rscript {0} run: | nonDummyTests <- setdiff(list.files("./tests/testthat/"), c("test-dummy.R", "_snaps")) - if(length(nonDummyTests) > 0 && !lucode2:::loadBuildLibraryConfig()[["skipCoverage"]]) covr::codecov(quiet = FALSE) + if(length(nonDummyTests) > 0 && !lucode2:::loadBuildLibraryConfig()[["skipCoverage"]]) { + coverage <- covr::package_coverage(quiet = FALSE) + # The following function might be unnecessary if r-lib/covr#616 gets merged + to_simple_codecov <- function(coverage) { + fullLineCoverage <- covr:::per_line(coverage) + data <- Map(function(fileCoverage) { + resultCoverage <- lapply(fileCoverage$coverage, jsonlite::unbox) + names(resultCoverage) <- seq_along(resultCoverage) + return(resultCoverage) + }, fullLineCoverage) + return(jsonlite::toJSON(list("coverage" = data), na = "null")) + } + writeLines(to_simple_codecov(coverage), "simple-codecov.json") + } env: NOT_CRAN: "true" + + - uses: codecov/codecov-action@v4 + if: ${{ github.event_name != 'pull_request' }} + with: + file: ./simple-codecov.json + plugin: noop + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/CITATION.cff b/CITATION.cff index 07c1e75..18ef5d3 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,8 +2,8 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'lucode2: Code Manipulation and Analysis Tools' -version: 0.51.7 -date-released: '2025-07-31' +version: 0.52.0 +date-released: '2025-08-26' abstract: A collection of tools which allow to manipulate and analyze code. authors: - family-names: Dietrich diff --git a/DESCRIPTION b/DESCRIPTION index 0dfa04a..037004a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: lucode2 Title: Code Manipulation and Analysis Tools -Version: 0.51.7 -Date: 2025-07-31 +Version: 0.52.0 +Date: 2025-08-26 Authors@R: c( person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = c("aut", "cre"), comment = c(affiliation = "Potsdam Institute for Climate Impact Research", ORCID = "0000-0002-4309-6431")), diff --git a/README.md b/README.md index 5e6e0fe..657628d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Code Manipulation and Analysis Tools -R package **lucode2**, version **0.51.7** +R package **lucode2**, version **0.52.0** [![CRAN status](https://www.r-pkg.org/badges/version/lucode2)](https://cran.r-project.org/package=lucode2) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4389418.svg)](https://doi.org/10.5281/zenodo.4389418) [![R build status](https://github.com/pik-piam/lucode2/workflows/check/badge.svg)](https://github.com/pik-piam/lucode2/actions) [![codecov](https://codecov.io/gh/pik-piam/lucode2/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/lucode2) [![r-universe](https://pik-piam.r-universe.dev/badges/lucode2)](https://pik-piam.r-universe.dev/builds) @@ -39,7 +39,7 @@ In case of questions / problems please contact Jan Philipp Dietrich , Version: 0.51.7, . +Dietrich J, Sauer P, Klein D, Giannousakis A, Bonsch M, Bodirsky B, Baumstark L, Richters O, Pflüger M (2025). "lucode2: Code Manipulation and Analysis Tools." doi:10.5281/zenodo.4389418 , Version: 0.52.0, . A BibTeX entry for LaTeX users is @@ -48,9 +48,9 @@ A BibTeX entry for LaTeX users is title = {lucode2: Code Manipulation and Analysis Tools}, author = {Jan Philipp Dietrich and Pascal Sauer and David Klein and Anastasis Giannousakis and Markus Bonsch and Benjamin Leon Bodirsky and Lavinia Baumstark and Oliver Richters and Mika Pflüger}, doi = {10.5281/zenodo.4389418}, - date = {2025-07-31}, + date = {2025-08-26}, year = {2025}, url = {https://github.com/pik-piam/lucode2}, - note = {Version: 0.51.7}, + note = {Version: 0.52.0}, } ``` diff --git a/inst/extdata/check.yaml b/inst/extdata/check.yaml index 89c8e53..e7ef0c4 100644 --- a/inst/extdata/check.yaml +++ b/inst/extdata/check.yaml @@ -60,9 +60,31 @@ jobs: lucode2::check(runLinter = FALSE) - name: Test coverage + if: ${{ github.event_name != 'pull_request' }} shell: Rscript {0} run: | nonDummyTests <- setdiff(list.files("./tests/testthat/"), c("test-dummy.R", "_snaps")) - if(length(nonDummyTests) > 0 && !lucode2:::loadBuildLibraryConfig()[["skipCoverage"]]) covr::codecov(quiet = FALSE) + if(length(nonDummyTests) > 0 && !lucode2:::loadBuildLibraryConfig()[["skipCoverage"]]) { + coverage <- covr::package_coverage(quiet = FALSE) + # The following function might be unnecessary if r-lib/covr#616 gets merged + to_simple_codecov <- function(coverage) { + fullLineCoverage <- covr:::per_line(coverage) + data <- Map(function(fileCoverage) { + resultCoverage <- lapply(fileCoverage$coverage, jsonlite::unbox) + names(resultCoverage) <- seq_along(resultCoverage) + return(resultCoverage) + }, fullLineCoverage) + return(jsonlite::toJSON(list("coverage" = data), na = "null")) + } + writeLines(to_simple_codecov(coverage), "simple-codecov.json") + } env: NOT_CRAN: "true" + + - uses: codecov/codecov-action@v4 + if: ${{ github.event_name != 'pull_request' }} + with: + file: ./simple-codecov.json + plugin: noop + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }}