@@ -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,18 @@ 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')"
134134
135+ # XML grep for coverage report merging
136+ sudo apt-get install -qq xml-twig-tools -y
137+
135138 displayName: 'Install all dependencies for dsBaseClient'
136139 condition: succeeded()
137140
@@ -157,10 +160,10 @@ jobs:
157160 echo "Run devtools::document() locally then commit again."
158161 exit 1
159162 else
160- echo "Documentation up to date."
161- exit 0
163+ echo "Documentation up to date."
164+ exit 0
162165 fi
163-
166+
164167 workingDirectory: $(Pipeline.Workspace)/dsBaseClient
165168 displayName: 'Check manual updated before being committed'
166169 condition: succeeded()
@@ -172,7 +175,7 @@ jobs:
172175 # If previous steps have failed then don't run.
173176 # If this step fails still mark as failed, but don't stop the rest of the steps running.
174177 - bash : |
175-
178+
176179 R -q -e "library('devtools'); devtools::check(args = c('--no-examples'))" | tee azure-pipelines_check.Rout
177180 grep --quiet "^0 errors" azure-pipelines_check.Rout && grep --quiet " 0 warnings" azure-pipelines_check.Rout && grep --quiet " 0 notes" azure-pipelines_check.Rout
178181
@@ -186,7 +189,7 @@ jobs:
186189 # Install dsBase. This uses the datashield-infrastructure repo (and its dependencies) to do the install with puppet.
187190 # If previous steps have failed then don't run.
188191 - bash : |
189-
192+
190193 # Set up puppet and r10k
191194 wget -nv https://apt.puppetlabs.com/puppet5-release-xenial.deb
192195 sudo dpkg -i puppet5-release-xenial.deb
@@ -196,11 +199,11 @@ jobs:
196199
197200 sudo apt-get install puppet-agent -y
198201 sudo /opt/puppetlabs/puppet/bin/gem install r10k
199-
202+
200203 pushd puppet/environments/datashield_azurepipelines
201204 sudo /opt/puppetlabs/puppet/bin/r10k puppetfile install
202205 popd
203-
206+
204207 sudo /opt/puppetlabs/bin/puppet apply $(Pipeline.Workspace)/dsBaseClient/azure-pipelines_site.pp --environment datashield_azurepipelines --environmentpath puppet/environments
205208
206209 workingDirectory: $(Pipeline.Workspace)/datashield-infrastructure
@@ -216,24 +219,99 @@ jobs:
216219 # TODO: Tidy up variable names - use timestamps here.
217220 # TODO: Why is DSLite needed for this to run?!
218221 - bash : |
219-
222+
220223 # There is an issue with the way we are using packages. The wrapped up test command
221224 # below fails in a way that implies that it is not installed. I cannot figure out
222225 # why this is case. As a work around we can run some of the functions below. My
223226 # best guess is that there is an implicit build or similar that happens. Although
224227 # I cannot replicate that directly with build etc directly.
225-
228+
226229 # None of the below make the tests run
227230 #sudo R -e 'devtools::reload(".")'
228231 #sudo R -e 'library(dsBaseClient)'
229232 #sudo R -e 'devtools::check_built()'
230233 #sudo R --verbose -e 'devtools::build()'
231-
234+
232235 # Any of the below makes the tests work.
233236 #sudo R --verbose -e 'devtools::test()'
234237 #sudo R --verbose -e 'devtools::install()'
235238 sudo R --verbose -e 'devtools::check()'
236-
239+
240+ pwd
241+ mkdir $(Pipeline.Workspace)/logs
242+
243+ # run the coverage tool and output to coveragelist.csv
244+ # testthat::testpackage uses a MultiReporter, comprised of a ProgressReporter and JunitReporter
245+ # R output and messages are redirected by sink() to test_console_output.txt
246+ # junit reporter output is to test_results.xml
247+ #
248+ # "_-|arg-|smk-|datachk-|disc-|math-|expt-|expt_smk-"
249+ sudo R -q -e '
250+ library(covr);
251+ dsbase.res <- covr::package_coverage(
252+ type = c("none"),
253+ code = c(
254+ '"'"'
255+ library(testthat);
256+ output_file <- file("test_console_output_dsbase.txt");
257+ sink(output_file);
258+ sink(output_file, type = "message");
259+ library(testthat);
260+ junit_rep <- JunitReporter$new(file = "test_results_dsbase.xml");
261+ progress_rep <- ProgressReporter$new(max_failures = 999999);
262+ multi_rep <- MultiReporter$new(reporters = list(progress_rep, junit_rep));
263+ testthat::test_package("$(projectName)", filter = "_-", reporter = multi_rep, stop_on_failure = FALSE)
264+ '"'"'
265+ )
266+ );
267+ base::saveRDS(dsbase.res, "test_results_dsbase.rds")'
268+
269+ # display the test console output
270+ cat test_console_output_dsbase.txt
271+
272+ grep --quiet "Failed: 0" test_console_output_dsbase.txt
273+
274+ workingDirectory: $(Pipeline.Workspace)/dsBaseClient
275+ displayName: 'Code coverage and JUnit report output, with dsBase'
276+ condition: succeeded()
277+
278+
279+ #####################################################################################
280+ # Install dsDanger on server
281+ # If previous steps have failed then don't run
282+ - bash : |
283+
284+ sudo /opt/puppetlabs/bin/puppet apply $(Pipeline.Workspace)/dsBaseClient/azure-pipelines_site-dsdanger.pp --environment datashield_azurepipelines --environmentpath puppet/environments
285+
286+ workingDirectory: $(Pipeline.Workspace)/datashield-infrastructure
287+ displayName: 'Install dsDanger DataSHIELD package on server'
288+ condition: succeeded()
289+
290+
291+ #####################################################################################
292+ # Install dsDangerClient.
293+ # If previous steps have failed then don't run
294+ - bash : |
295+
296+ sudo R -q -e 'devtools::install()'
297+ sudo R -q -e "library('devtools'); devtools::install_github(repo='datashield/dsDangerClient', ref='v6.1-dev', dependencies = TRUE)"
298+
299+ workingDirectory: $(Pipeline.Workspace)/dsBaseClient
300+ displayName: 'Install dsDangerClient DataSHIELD package'
301+ condition: succeeded()
302+
303+
304+ #####################################################################################
305+ # Essentially run devtools::test() on the checked out code. This is wrapped up with
306+ # code coverage. The actual command is vary convoluted as it had to do some things
307+ # which are not default behaviour: output the results to a JUnit xml file, not stop
308+ # when a small number of errors have happened, run through the code coverage tool.
309+ # TODO: Tidy up variable names - use timestamps here.
310+ - bash : |
311+
312+ # See, 'Code coverage and JUnit report output' for issues with the approach and improvement needed.
313+ sudo R --verbose -e 'devtools::check()'
314+
237315 pwd
238316 mkdir $(Pipeline.Workspace)/logs
239317
@@ -243,35 +321,50 @@ jobs:
243321 # junit reporter output is to test_results.xml
244322 sudo R -q -e '
245323 library(covr);
324+ dsdanger.res <- covr::package_coverage(
325+ type = c("none"),
326+ code = c(
327+ '"'"'
328+ library(testthat);
329+ output_file <- file("test_console_output_dsdanger.txt");
330+ sink(output_file);
331+ sink(output_file, type = "message");
332+ library(testthat);
333+ junit_rep <- JunitReporter$new(file = "test_results_dsdanger.xml");
334+ progress_rep <- ProgressReporter$new(max_failures = 999999);
335+ multi_rep <- MultiReporter$new(reporters = list(progress_rep, junit_rep));
336+ testthat::test_package("$(projectName)", filter = "smk_dgr-",reporter = multi_rep, stop_on_failure = FALSE)
337+ '"'"'
338+ )
339+ );
340+ base::saveRDS(dsdanger.res, "test_results_dsdanger.rds")'
341+
342+ # Merge coverage results
343+ cat test_results_dsbase.txt test_results_dsdanger.txt > $(Pipeline.Workspace)/logs/test_console_output.txt
344+ xml_grep --pretty_print indented --wrap "testsuites" --descr "" --cond "testsuite" test_results_dsbase.xml test_results_dsdanger.xml > test_results.xml
345+
346+ # Create 'coveragelist.csv'
347+ sudo R -q -e '
348+ library(covr);
349+ dsbase.res <- base::readRDS("test_results_dsbase.rds")
350+ dsdanger.res <- base::readRDS("test_results_dsdanger.rds")
246351 write.csv(
247- coverage_to_list(
248- covr::package_coverage(
249- type = c("none"),
250- code = c(
251- '"'"'library(testthat);
252- output_file <- file("test_console_output.txt");
253- sink(output_file);
254- sink(output_file, type = "message");
255- library(testthat);
256- junit_rep <- JunitReporter$new(file = "test_results.xml");
257- progress_rep <- ProgressReporter$new(max_failures = 999999);
258- multi_rep <- MultiReporter$new(reporters = list(progress_rep, junit_rep));
259- testthat::test_package("$(projectName)", filter = "$(test_filter)",reporter = multi_rep, stop_on_failure = FALSE)'"'"')
260- )
261- ),
262- "coveragelist.csv"
263- )'
264-
352+ coverage_to_list(
353+ c(dsbase.res, dsdanger.res)
354+ "coveragelist.csv"
355+ )
356+ )'
357+
265358 # display the test console output
266- cat test_console_output.txt
359+ cat test_console_output_dsdanger.txt
360+
267361 mv coveragelist.csv $(Pipeline.Workspace)/logs
268362 mv test_results.xml $(Pipeline.Workspace)/logs
269- mv test_console_output.txt $(Pipeline.Workspace)/logs
270-
271- grep --quiet "Failed: 0" $(Pipeline.Workspace)/logs/test_console_output.txt
363+
364+ grep --quiet "Failed: 0" test_console_output_dsdanger.txt
272365
273366 workingDirectory: $(Pipeline.Workspace)/dsBaseClient
274- displayName: 'Code coverage and JUnit report output'
367+ displayName: 'Code coverage and JUnit report output, with dsBase and dsDanger '
275368 condition: succeeded()
276369
277370
@@ -280,7 +373,7 @@ jobs:
280373 # echo them so finding bugs should be easier.
281374 # This should run even if previous steps have failed.
282375 - bash : |
283-
376+
284377 # Strip out when error and failure = 0 and count the number of times it does not.
285378 issue_count=$(sed 's/failures="0" errors="0"//' test_results.xml | grep --count errors=)
286379 echo "Number of testsuites with issues: "$issue_count
0 commit comments