From babb654c819643677f9d7a4284003c418c301305 Mon Sep 17 00:00:00 2001 From: HyukjinKwon Date: Tue, 18 Aug 2020 19:35:15 +0900 Subject: [PATCH] [SPARK-32647][INFRA] Report SparkR test results with JUnit reporter ### What changes were proposed in this pull request? This PR proposes to generate JUnit XML test report in SparkR tests that can be leveraged in both Jenkins and GitHub Actions. **GitHub Actions** ![Screen Shot 2020-08-18 at 12 42 46 PM](https://user-images.githubusercontent.com/6477701/90467934-55b85b00-e150-11ea-863c-c8415e764ddb.png) **Jenkins** ![Screen Shot 2020-08-18 at 2 03 42 PM](https://user-images.githubusercontent.com/6477701/90472509-a5505400-e15b-11ea-9165-777ec9b96eaa.png) NOTE that while I am here, I am switching back the console reporter from "progress" to "summary". Currently non-ascii codes are broken in Jenkins console and switching it to "summary" can work around it. "summary" is the default format used in testthat 1.x. ### Why are the changes needed? To check the test failures more easily. ### Does this PR introduce _any_ user-facing change? No, dev-only ### How was this patch tested? It is tested in GitHub Actions at https://github.com/HyukjinKwon/spark/pull/23/checks?check_run_id=996586446 In case of Jenkins, https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/127525/testReport/ Closes #29456 from HyukjinKwon/sparkr-junit. Authored-by: HyukjinKwon Signed-off-by: HyukjinKwon --- R/pkg/tests/run-all.R | 9 ++++++--- appveyor.yml | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/R/pkg/tests/run-all.R b/R/pkg/tests/run-all.R index a46924a5d2..3043df0f12 100644 --- a/R/pkg/tests/run-all.R +++ b/R/pkg/tests/run-all.R @@ -61,15 +61,18 @@ if (identical(Sys.getenv("NOT_CRAN"), "true")) { set.seed(42) # TODO (SPARK-30663) To be removed once testthat 1.x is removed from all builds - if (grepl("^1\\..*", packageVersion("testthat"))) { + if (packageVersion("testthat")$major <= 1) { # testthat 1.x test_runner <- testthat:::run_tests reporter <- "summary" - } else { # testthat >= 2.0.0 test_runner <- testthat:::test_package_dir - reporter <- testthat::default_reporter() + dir.create("target/test-reports", showWarnings = FALSE) + reporter <- MultiReporter$new(list( + SummaryReporter$new(), + JunitReporter$new(file = "target/test-reports/test-results.xml") + )) } test_runner("SparkR", diff --git a/appveyor.yml b/appveyor.yml index 1fd91daae9..c40b23c834 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -41,8 +41,8 @@ cache: install: # Install maven and dependencies - ps: .\dev\appveyor-install-dependencies.ps1 - # Required package for R unit tests - - cmd: Rscript -e "install.packages(c('knitr', 'rmarkdown', 'testthat', 'e1071', 'survival', 'arrow'), repos='https://cloud.r-project.org/')" + # Required package for R unit tests. xml2 is required to use jUnit reporter in testthat. + - cmd: Rscript -e "install.packages(c('knitr', 'rmarkdown', 'testthat', 'e1071', 'survival', 'arrow', 'xml2'), repos='https://cloud.r-project.org/')" - cmd: Rscript -e "pkg_list <- as.data.frame(installed.packages()[,c(1, 3:4)]); pkg_list[is.na(pkg_list$Priority), 1:2, drop = FALSE]" build_script: