Skip to content

Commit

Permalink
Merge pull request #1579 from orichters/develop
Browse files Browse the repository at this point in the history
use newest gms in github action; fail on codeCheck warning; test that no line starts with ****
  • Loading branch information
orichters authored Feb 27, 2024
2 parents eb46563 + 56c343e commit af3eee7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/test-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@ jobs:

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
extra-repositories: https://rse.pik-potsdam.de/r/packages/

- name: Install R dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
packages: gms

extra-packages: |
any::gms
# piam packages also available on CRAN (madrat, magclass, citation,
# gms, goxygen, GDPuc) will usually have an outdated binary version
# available; by using extra-packages we get the newest version

- name: codeCheck
run: null <- gms::codeCheck(strict=TRUE)
shell: Rscript {0}

- name: fileSizeCheck
run: source(".github/workflows/size-check")
shell: Rscript {0}
19 changes: 18 additions & 1 deletion tests/testthat/test_99-codeCheck.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,24 @@ test_that("GAMS code follows the coding etiquette", {
# have to run this via localSystem2 so that it uses the renv, where gms
# is actually installed.
skipIfPreviousFailed()
output <- localSystem2("Rscript", c("-e", "'invisible(gms::codeCheck(strict=TRUE))'"))
codecheckcode <- "'invisible(gms::codeCheck(strict=TRUE)); if (! is.null(warnings())) stop(warnings())'"
output <- localSystem2("Rscript", c("-e", codecheckcode))
printIfFailed(output)
expectSuccessStatus(output)
})

test_that("No four asterisks in code", {
notavailable <- Sys.which("grep") == ""
if (notavailable) {
skip("'grep' not available, please check yourself whether code starts with four asterisks.")
} else {
files <- paste0("../../", c("*.gms", "core/*.gms", "modules/*.gms", "modules/*/*.gms", "modules/*/*/*.gms"))
grepcode <- paste("grep", "'^\\*\\*\\*\\*'", paste(files, collapse = " "))
starlines <- suppressWarnings(system(grepcode, intern = TRUE))
if (length(starlines) > 0) {
warning("The following lines start with four asterisks, reserved for GAMS error messages.\n",
paste(starlines, collapse = "\n"))
}
expect_true(length(starlines) == 0)
}
})

0 comments on commit af3eee7

Please sign in to comment.