Last active
June 27, 2017 13:40
-
-
Save rmflight/9911d79db70ee6fafc3dbc17e1c27da9 to your computer and use it in GitHub Desktop.
gitlab-ci-failing-r-tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testit: | |
script: | |
- R CMD INSTALL . | |
- Rscript run_tests.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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