1# Build triggered on a rolling or batch basis on the master and release branches. They may take longer than the standard CI configurations.
2
3name: ITK.Coverage
4
5trigger:
6  batch: true
7  branches:
8    include:
9    - master
10    - release*
11pr: none
12
13variables:
14  ExternalDataVersion: 5.0rc01
15jobs:
16  - job: Linux
17    timeoutInMinutes: 0
18    cancelTimeoutInMinutes: 300
19    pool:
20      vmImage: 'Ubuntu-16.04'
21
22    steps:
23      - checkout: self
24        clean: true
25        fetchDepth: 5
26      - bash: |
27          set -x
28          if [ -n "$(System.PullRequest.SourceCommitId)" ]; then
29            git checkout $(System.PullRequest.SourceCommitId)
30          fi
31        displayName: 'Checkout pull request HEAD'
32      - bash: |
33          set -x
34          sudo apt-get update
35          sudo apt-get install -y python3-venv
36          sudo python3 -m pip install --upgrade setuptools
37          sudo python3 -m pip install scikit-ci-addons
38        displayName: 'Install dependencies'
39      - bash: |
40          set -x
41          git clone -b dashboard --single-branch https://github.com/InsightSoftwareConsortium/ITK.git ITK-dashboard
42
43          curl -L https://github.com/InsightSoftwareConsortium/ITK/releases/download/v$(ExternalDataVersion)/InsightData-$(ExternalDataVersion).tar.gz -O
44          cmake -E tar xfz InsightData-$(ExternalDataVersion).tar.gz
45          cmake -E rename InsightToolkit-$(ExternalDataVersion)/.ExternalData/MD5 $(Build.SourcesDirectory)/.ExternalData/MD5
46        workingDirectory: $(Agent.BuildDirectory)
47        displayName: 'Download dashboard script and testing data'
48      - bash: |
49          cat > dashboard.cmake << EOF
50          set(CTEST_BUILD_CONFIGURATION "Debug")
51          set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
52          set(CTEST_BUILD_FLAGS -j2)
53          set(CTEST_COVERAGE_COMMAND "/usr/bin/gcov")
54          set(BUILD_NAME_SUFFIX "-gcov")
55          set(dashboard_do_coverage 1)
56          set(dashboard_cache "
57            BUILD_TESTING:BOOL=ON
58            BUILD_SHARED_LIBS:BOOL=OFF
59            BUILD_EXAMPLES:BOOL=OFF
60            BUILD_DOCUMENTS:BOOL=OFF
61            ITK_WRAP_PYTHON:BOOL=OFF
62            CMAKE_CXX_FLAGS:STRING=-g -O0 -fprofile-arcs -ftest-coverage
63            CMAKE_C_FLAGS:STRING=-g -O0 -fprofile-arcs -ftest-coverage
64            CMAKE_EXE_LINKER_FLAGS:STRING=-g -O0 -fprofile-arcs -ftest-coverage
65          ")
66          include($(Agent.BuildDirectory)/ITK-dashboard/azure_dashboard.cmake)
67          EOF
68          cat dashboard.cmake
69        workingDirectory: $(Agent.BuildDirectory)/ITK-dashboard
70        displayName: 'Configure CTest script'
71      - bash: |
72          ctest -S $(Agent.BuildDirectory)/ITK-dashboard/dashboard.cmake -VV
73        displayName: 'Build and test with coverage'
74        env:
75          CTEST_OUTPUT_ON_FAILURE: 1
76          ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS: 2
77      - script: |
78          ci_addons ctest_junit_formatter $(Build.SourcesDirectory)-build > $(Agent.BuildDirectory)/JUnitTestResults.xml
79        condition: succeededOrFailed()
80        displayName: 'Format CTest output in JUnit format'
81
82      - task: PublishTestResults@2
83        inputs:
84          testResultsFiles: "$(Agent.BuildDirectory)/JUnitTestResults.xml"
85          testRunTitle: 'CTest $(Agent.OS)'
86        condition: succeededOrFailed()
87        displayName: 'Publish test results'
88