@@ -42,12 +42,12 @@ resources:
4242 endpoint : datashield-testing
4343 name : datashield/testStatus
4444 ref : master
45-
45+
4646 - repository : datashield-infrastructureRepo
4747 type : github
4848 endpoint : datashield-testing
49- name : datashield /datashield-infrastructure
50- ref : v6.1-dev
49+ name : StuartWheater /datashield-infrastructure
50+ ref : v6.1-dev_dsdanger
5151
5252
5353# ########################################################################################
@@ -123,15 +123,19 @@ jobs:
123123 # Install R and all the dependencies dsBaseClient requires.
124124 # If previous steps have failed then don't run.
125125 - bash : |
126-
126+
127127 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
128128 sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran40/"
129129 sudo apt-get update
130-
130+
131131 sudo apt-get install -qq libxml2-dev libcurl4-openssl-dev libssl-dev libgsl-dev r-base -y
132132 sudo R -q -e "install.packages(c('devtools','metafor','fields','covr'), dependencies=TRUE, repos='https://cloud.r-project.org')"
133133 sudo R -q -e "install.packages(c('DSI','DSOpal','DSLite'), dependencies=TRUE, repos='https://cloud.r-project.org')"
134- sudo R -q -e "install.packages(c('e1071'), dependencies=TRUE, repos='https://cloud.r-project.org')"
134+
135+ sudo R -q -e "install.packages(c('DescTools','e1071'), dependencies=TRUE, repos='https://cloud.r-project.org')"
136+
137+ # XML grep for coverage report merging
138+ sudo apt-get install -qq xml-twig-tools -y
135139
136140 displayName: 'Install all dependencies for dsBaseClient'
137141 condition: succeeded()
@@ -158,10 +162,10 @@ jobs:
158162 echo "Run devtools::document() locally then commit again."
159163 exit 1
160164 else
161- echo "Documentation up to date."
162- exit 0
165+ echo "Documentation up to date."
166+ exit 0
163167 fi
164-
168+
165169 workingDirectory: $(Pipeline.Workspace)/dsBaseClient
166170 displayName: 'Check manual updated before being committed'
167171 condition: succeeded()
@@ -173,7 +177,7 @@ jobs:
173177 # If previous steps have failed then don't run.
174178 # If this step fails still mark as failed, but don't stop the rest of the steps running.
175179 - bash : |
176-
180+
177181 R -q -e "library('devtools'); devtools::check(args = c('--no-examples'))" | tee azure-pipelines_check.Rout
178182 grep --quiet "^0 errors" azure-pipelines_check.Rout && grep --quiet " 0 warnings" azure-pipelines_check.Rout && grep --quiet " 0 notes" azure-pipelines_check.Rout
179183
@@ -187,7 +191,7 @@ jobs:
187191 # Install dsBase. This uses the datashield-infrastructure repo (and its dependencies) to do the install with puppet.
188192 # If previous steps have failed then don't run.
189193 - bash : |
190-
194+
191195 # Set up puppet and r10k
192196 wget -nv https://apt.puppetlabs.com/puppet5-release-xenial.deb
193197 sudo dpkg -i puppet5-release-xenial.deb
@@ -197,11 +201,11 @@ jobs:
197201
198202 sudo apt-get install puppet-agent -y
199203 sudo /opt/puppetlabs/puppet/bin/gem install r10k
200-
204+
201205 pushd puppet/environments/datashield_azurepipelines
202206 sudo /opt/puppetlabs/puppet/bin/r10k puppetfile install
203207 popd
204-
208+
205209 sudo /opt/puppetlabs/bin/puppet apply $(Pipeline.Workspace)/dsBaseClient/azure-pipelines_site.pp --environment datashield_azurepipelines --environmentpath puppet/environments
206210
207211 workingDirectory: $(Pipeline.Workspace)/datashield-infrastructure
@@ -217,62 +221,152 @@ jobs:
217221 # TODO: Tidy up variable names - use timestamps here.
218222 # TODO: Why is DSLite needed for this to run?!
219223 - bash : |
220-
224+
221225 # There is an issue with the way we are using packages. The wrapped up test command
222226 # below fails in a way that implies that it is not installed. I cannot figure out
223227 # why this is case. As a work around we can run some of the functions below. My
224228 # best guess is that there is an implicit build or similar that happens. Although
225229 # I cannot replicate that directly with build etc directly.
226-
230+
227231 # None of the below make the tests run
228232 #sudo R -e 'devtools::reload(".")'
229233 #sudo R -e 'library(dsBaseClient)'
230234 #sudo R -e 'devtools::check_built()'
231235 #sudo R --verbose -e 'devtools::build()'
232-
236+
233237 # Any of the below makes the tests work.
234238 #sudo R --verbose -e 'devtools::test()'
235239 #sudo R --verbose -e 'devtools::install()'
236240 sudo R --verbose -e 'devtools::check()'
237-
241+
238242 pwd
239243 mkdir $(Pipeline.Workspace)/logs
240244
241245 # run the coverage tool and output to coveragelist.csv
242246 # testthat::testpackage uses a MultiReporter, comprised of a ProgressReporter and JunitReporter
243247 # R output and messages are redirected by sink() to test_console_output.txt
244248 # junit reporter output is to test_results.xml
249+ #
250+ # "_-|arg-|smk-|datachk-|disc-|math-|expt-|expt_smk-"
245251 sudo R -q -e '
246252 library(covr);
253+ dsbase.res <- covr::package_coverage(
254+ type = c("none"),
255+ code = c(
256+ '"'"'
257+ library(testthat);
258+ output_file <- file("test_console_output_dsbase.txt");
259+ sink(output_file);
260+ sink(output_file, type = "message");
261+ library(testthat);
262+ junit_rep <- JunitReporter$new(file = "test_results_dsbase.xml");
263+ progress_rep <- ProgressReporter$new(max_failures = 999999);
264+ multi_rep <- MultiReporter$new(reporters = list(progress_rep, junit_rep));
265+ testthat::test_package("$(projectName)", filter = "_-", reporter = multi_rep, stop_on_failure = FALSE)
266+ '"'"'
267+ )
268+ );
269+ base::saveRDS(dsbase.res, "test_results_dsbase.rds")'
270+
271+ # display the test console output
272+ cat test_console_output_dsbase.txt
273+
274+ grep --quiet "Failed: 0" test_console_output_dsbase.txt
275+
276+ workingDirectory: $(Pipeline.Workspace)/dsBaseClient
277+ displayName: 'Code coverage and JUnit report output, with dsBase'
278+ condition: succeeded()
279+
280+
281+ #####################################################################################
282+ # Install dsDanger on server
283+ # If previous steps have failed then don't run
284+ - bash : |
285+
286+ sudo /opt/puppetlabs/bin/puppet apply $(Pipeline.Workspace)/dsBaseClient/azure-pipelines_site-dsdanger.pp --environment datashield_azurepipelines --environmentpath puppet/environments
287+
288+ workingDirectory: $(Pipeline.Workspace)/datashield-infrastructure
289+ displayName: 'Install dsDanger DataSHIELD package on server'
290+ condition: succeeded()
291+
292+
293+ #####################################################################################
294+ # Install dsDangerClient.
295+ # If previous steps have failed then don't run
296+ - bash : |
297+
298+ sudo R -q -e 'devtools::install()'
299+ sudo R -q -e "library('devtools'); devtools::install_github(repo='datashield/dsDangerClient', ref='v6.1-dev', dependencies = TRUE)"
300+
301+ workingDirectory: $(Pipeline.Workspace)/dsBaseClient
302+ displayName: 'Install dsDangerClient DataSHIELD package'
303+ condition: succeeded()
304+
305+
306+ #####################################################################################
307+ # Essentially run devtools::test() on the checked out code. This is wrapped up with
308+ # code coverage. The actual command is vary convoluted as it had to do some things
309+ # which are not default behaviour: output the results to a JUnit xml file, not stop
310+ # when a small number of errors have happened, run through the code coverage tool.
311+ # TODO: Tidy up variable names - use timestamps here.
312+ - bash : |
313+
314+ # See, 'Code coverage and JUnit report output' for issues with the approach and improvement needed.
315+ sudo R --verbose -e 'devtools::check()'
316+
317+ pwd
318+ mkdir $(Pipeline.Workspace)/logs
319+
320+ # run the coverage tool and output to coveragelist.csv
321+ # testthat::testpackage uses a MultiReporter, comprised of a ProgressReporter and JunitReporter
322+ # R output and messages are redirected by sink() to test_console_output.txt
323+ # junit reporter output is to test_results.xml
324+ sudo R -q -e '
325+ library(covr);
326+ dsdanger.res <- covr::package_coverage(
327+ type = c("none"),
328+ code = c(
329+ '"'"'
330+ library(testthat);
331+ output_file <- file("test_console_output_dsdanger.txt");
332+ sink(output_file);
333+ sink(output_file, type = "message");
334+ library(testthat);
335+ junit_rep <- JunitReporter$new(file = "test_results_dsdanger.xml");
336+ progress_rep <- ProgressReporter$new(max_failures = 999999);
337+ multi_rep <- MultiReporter$new(reporters = list(progress_rep, junit_rep));
338+ testthat::test_package("$(projectName)", filter = "smk_dgr-",reporter = multi_rep, stop_on_failure = FALSE)
339+ '"'"'
340+ )
341+ );
342+ base::saveRDS(dsdanger.res, "test_results_dsdanger.rds")'
343+
344+ # Merge coverage results
345+ cat test_results_dsbase.txt test_results_dsdanger.txt > $(Pipeline.Workspace)/logs/test_console_output.txt
346+ xml_grep --pretty_print indented --wrap "testsuites" --descr "" --cond "testsuite" test_results_dsbase.xml test_results_dsdanger.xml > test_results.xml
347+
348+ # Create 'coveragelist.csv'
349+ sudo R -q -e '
350+ library(covr);
351+ dsbase.res <- base::readRDS("test_results_dsbase.rds")
352+ dsdanger.res <- base::readRDS("test_results_dsdanger.rds")
247353 write.csv(
248- coverage_to_list(
249- covr::package_coverage(
250- type = c("none"),
251- code = c(
252- '"'"'library(testthat);
253- output_file <- file("test_console_output.txt");
254- sink(output_file);
255- sink(output_file, type = "message");
256- library(testthat);
257- junit_rep <- JunitReporter$new(file = "test_results.xml");
258- progress_rep <- ProgressReporter$new(max_failures = 999999);
259- multi_rep <- MultiReporter$new(reporters = list(progress_rep, junit_rep));
260- testthat::test_package("$(projectName)", filter = "$(test_filter)",reporter = multi_rep, stop_on_failure = FALSE)'"'"')
261- )
262- ),
263- "coveragelist.csv"
264- )'
265-
354+ coverage_to_list(
355+ c(dsbase.res, dsdanger.res)
356+ "coveragelist.csv"
357+ )
358+ )'
359+
266360 # display the test console output
267- cat test_console_output.txt
361+ cat test_console_output_dsdanger.txt
362+
268363 mv coveragelist.csv $(Pipeline.Workspace)/logs
269364 mv test_results.xml $(Pipeline.Workspace)/logs
270- mv test_console_output.txt $(Pipeline.Workspace)/logs
271-
272- grep --quiet "Failed: 0" $(Pipeline.Workspace)/logs/test_console_output.txt
365+
366+ grep --quiet "Failed: 0" test_console_output_dsdanger.txt
273367
274368 workingDirectory: $(Pipeline.Workspace)/dsBaseClient
275- displayName: 'Code coverage and JUnit report output'
369+ displayName: 'Code coverage and JUnit report output, with dsBase and dsDanger '
276370 condition: succeeded()
277371
278372
@@ -281,7 +375,7 @@ jobs:
281375 # echo them so finding bugs should be easier.
282376 # This should run even if previous steps have failed.
283377 - bash : |
284-
378+
285379 # Strip out when error and failure = 0 and count the number of times it does not.
286380 issue_count=$(sed 's/failures="0" errors="0"//' test_results.xml | grep --count errors=)
287381 echo "Number of testsuites with issues: "$issue_count
0 commit comments