Skip to content

Commit

Permalink
Merge pull request #93 from dklein-pik/master
Browse files Browse the repository at this point in the history
Add testthat result to bot message. Keep testthat log file longterm in tests folder.
  • Loading branch information
dklein-pik authored Mar 5, 2024
2 parents 7479bd8 + 9b4612d commit 4bea29e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '3560940'
ValidationKey: '3581447'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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: 'modelstats: Run Analysis Tools'
version: 0.18.0
date-released: '2024-03-01'
version: 0.18.1
date-released: '2024-03-05'
abstract: A collection of tools to analyze model runs.
authors:
- family-names: Giannousakis
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: modelstats
Type: Package
Title: Run Analysis Tools
Version: 0.18.0
Date: 2024-03-01
Version: 0.18.1
Date: 2024-03-05
Authors@R: c(
person("Anastasis", "Giannousakis", email = "[email protected]", role = c("aut","cre")),
person("Oliver", "Richters", role = "aut")
Expand Down
28 changes: 16 additions & 12 deletions R/modeltests.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ startRuns <- function(test, model, mydir, gitPath, user) {
withr::with_dir("magpie", {
system(paste0(gitPath, " reset --hard origin/develop && ", gitPath, " pull"))
})
# 2. rename old test-full.log
system("mv test-full.log test-full-previous.log")
# 3. execute test
# 2. execute test
system("make test-full-slurm")

} else if (model == "MAgPIE") {
Expand Down Expand Up @@ -371,16 +369,22 @@ evaluateRuns <- function(model, mydir, gitPath, compScen, email, mattermostToken
}

# Evaluate result of tests/testthat
logStatus <- NULL
try(logStatus <- readLines("../test-full.log", warn = FALSE))
if (is.null(logStatus)) {
testthatResult <- "Could not check for the results of TESTTHAT, test-full.log not found"
} else if (! any(grep("FAIL", logStatus))) {
testthatResult <- "`make test-full` did not run properly. Check test-full.log"
} else if (any(grep("FAIL 1", logStatus))) {
testthatResult <- "Some tests FAIL in `make test-full`. Check test-full.log"
currentName <- "../test-full.log"
dateTag <- format(file.info(currentName)$mtime, "%Y-%m-%d")
if (is.na(dateTag)) {
testthatResult <- "Could not check for the results of `make test-full`, test-full.log not found"
} else {
# "make test-full reports all tests PASS"
logStatus <- readLines(currentName, warn = FALSE)
logStatus <- tail(grep("\\[ FAIL", logStatus, value = TRUE))
newName <- paste0("tests/test-full-", dateTag, ".log")
file.rename(from = currentName, to = paste0("../", newName))
if (!isTRUE(grepl("FAIL", logStatus))) {
testthatResult <- paste("`make test-full` did not run properly. Check", newName)
} else if (!isTRUE(grepl("FAIL 0", logStatus) & grepl("WARN 0", logStatus))) {
testthatResult <- paste0("Not all tests pass in `make test-full`: ", logStatus ,". Check ", newName)
} else {
testthatResult <- paste("All tests pass in `make test-full`:", logStatus)
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Run Analysis Tools

R package **modelstats**, version **0.18.0**
R package **modelstats**, version **0.18.1**

[![CRAN status](https://www.r-pkg.org/badges/version/modelstats)](https://cran.r-project.org/package=modelstats) [![R build status](https://github.com/pik-piam/modelstats/workflows/check/badge.svg)](https://github.com/pik-piam/modelstats/actions) [![codecov](https://codecov.io/gh/pik-piam/modelstats/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/modelstats) [![r-universe](https://pik-piam.r-universe.dev/badges/modelstats)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -47,7 +47,7 @@ In case of questions / problems please contact Anastasis Giannousakis <giannou@p

To cite package **modelstats** in publications use:

Giannousakis A, Richters O (2024). _modelstats: Run Analysis Tools_. R package version 0.18.0, <https://github.com/pik-piam/modelstats>.
Giannousakis A, Richters O (2024). _modelstats: Run Analysis Tools_. R package version 0.18.1, <https://github.com/pik-piam/modelstats>.

A BibTeX entry for LaTeX users is

Expand All @@ -56,7 +56,7 @@ A BibTeX entry for LaTeX users is
title = {modelstats: Run Analysis Tools},
author = {Anastasis Giannousakis and Oliver Richters},
year = {2024},
note = {R package version 0.18.0},
note = {R package version 0.18.1},
url = {https://github.com/pik-piam/modelstats},
}
```

0 comments on commit 4bea29e

Please sign in to comment.