Skip to content

Instantly share code, notes, and snippets.

@rmflight
Last active June 27, 2017 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmflight/9911d79db70ee6fafc3dbc17e1c27da9 to your computer and use it in GitHub Desktop.
Save rmflight/9911d79db70ee6fafc3dbc17e1c27da9 to your computer and use it in GitHub Desktop.
gitlab-ci-failing-r-tests
testit:
script:
- R CMD INSTALL .
- Rscript run_tests.R
# running `Rscript -e "devtools::test()"` does NOT return
# an error code that will make gitlab-ci say the run failed
# R CMD check will, but then you have all the noise from
# check that may not be useful in the early stages of a package
# or analysis. This provides a method to capture that tests
# failed, and notify the CI runner to give the right status.
#
# capture results of running the test
test_res <- as.data.frame(devtools::test())
if (sum(test_res$error) > 0) {
stop_code <- 1
} else if (sum(test_res$failed) > 0) {
stop_code <- 1
} else if (sum(test_res$warning) > 0) {
stop_code <- 1
} else {
stop_code <- 0
}
q('no', stop_code, FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment