Debian Codegraph @

.azure/templates/build-test.yml

raw
1 #
2 # Copyright(c) 2021 to 2022 ZettaScale Technology and others
3 #
4 # This program and the accompanying materials are made available under the
5 # terms of the Eclipse Public License v. 2.0 which is available at
6 # http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
7 # v. 1.0 which is available at
8 # http://www.eclipse.org/org/documents/edl-v10.php.
9 #
10 # SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
11 #
12
13 #
14 # Template with basic build and test instructions to be included by pipelines.
15 #
16
17 steps:
18 - task: UsePythonVersion@0
19 inputs:
20 versionSpec: '3.8'
21 name: install_python
22 # Set defaults from steps to share them among pipelines
23 - bash: |
24 [[ -n "${ARCH}" ]] || \
25 echo "###vso[task.setvariable variable=arch;]x86_64"
26 [[ -n "${BUILD_TYPE}" ]] || \
27 echo "###vso[task.setvariable variable=build_type;]Debug"
28 name: setup
29 - bash: |
30 echo "###vso[task.setvariable variable=pip_cache;]${HOME}/.cache/pip"
31 echo "###vso[task.setvariable variable=PATH;]$(python3 -m site --user-base)/bin:${PATH}"
32 echo "###vso[task.setvariable variable=build_tool_options;]-j 4"
33 sudo apt install -y clang clang-tools clang-tidy
34 condition: eq(variables['Agent.OS'], 'Linux')
35 name: setup_linux
36 - bash: |
37 set -e -x
38 sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
39 echo "###vso[task.setvariable variable=pip_cache;]${HOME}/Library/Caches/pip"
40 echo "###vso[task.setvariable variable=PATH;]$(python3 -m site --user-base)/bin:${PATH}"
41 echo "###vso[task.setvariable variable=build_tool_options;]-j 4"
42 condition: eq(variables['Agent.OS'], 'Darwin')
43 name: setup_macos
44 # Use PowerShell rather than Bash to ensure Windows-style paths
45 - pwsh: |
46 $python_bin = python -m site --user-base
47 Write-Host "###vso[task.setvariable variable=pip_cache;]${env:LOCALAPPDATA}\\pip\\Cache"
48 Write-Host "###vso[task.setvariable variable=PATH;]$python_bin\\bin;${env:PATH}"
49 # Visual Studio is most likely used on Windows agents
50 if (${env:GENERATOR} -match "2019" -and -not ${env:PLATFORM}) {
51 # Make sure platform matches arch if not specified
52 if (${env:ARCH} -match "arm*") {
53 Write-Host "###vso[task.setvariable variable=platform;]ARM"
54 } elseif (${env:ARCH} -eq "x86") {
55 Write-Host "###vso[task.setvariable variable=platform;]Win32"
56 } else {
57 Write-Host "###vso[task.setvariable variable=platform;]x64"
58 }
59 }
60 if (${env:GENERATOR} -match "Visual Studio") {
61 Write-Host "###vso[task.setvariable variable=build_tool_options;]-nologo -verbosity:minimal -maxcpucount:4 -p:CL_MPCount=4"
62 } else {
63 Write-Host "###vso[task.setvariable variable=build_tool_options;]-j 4"
64 }
65 condition: eq(variables['Agent.OS'], 'Windows_NT')
66 name: setup_windows
67 - task: Cache@2
68 inputs:
69 key: pip | 2 | $(Agent.OS)
70 path: $(pip_cache)
71 name: cache_pip
72 - bash: |
73 set -e -x
74 python -m pip install pip wheel setuptools --user --upgrade
75 python -m pip install pre-commit --user --upgrade
76 pre-commit run --all-files
77 name: run_pre_commit
78 - bash: |
79 python -m pip install gcovr==5.0 --user --upgrade
80 name: install_gcovr
81 - bash: |
82 set -e -x
83 sudo apt install libacl1-dev libncurses5-dev pkg-config
84 git clone --depth 1 \
85 --branch "${ICEORYX_BRANCH:-release_2.0}" \
86 "${ICEORYX_REPOSITORY:-https://github.com/eclipse-iceoryx/iceoryx.git}" \
87 iceoryx
88 mkdir iceoryx/build
89 cd iceoryx/build
90 [[ "${AGENT_OS}" == 'Darwin' ]] && BUILD_TOOL_OPTIONS="-j 4"
91 cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
92 -DCMAKE_BUILD_SHARED_LIBS=on \
93 -DCMAKE_INSTALL_PREFIX=install \
94 ${GENERATOR:+-G} "${GENERATOR}" -A "${PLATFORM}" -T "${TOOLSET}" ../iceoryx_meta
95 cmake --build . --config ${BUILD_TYPE} --target install -- ${BUILD_TOOL_OPTIONS}
96 condition: eq(variables['iceoryx'], 'on')
97 name: install_iceoryx
98 - bash: |
99 set -e -x
100 mkdir build
101 cd build
102 prefix_path="${BUILD_SOURCESDIRECTORY}/iceoryx/build/install"
103 if [[ "${AGENT_OS}" == 'Darwin' ]] ; then
104 prefix_path="${prefix_path}:`brew --prefix openssl`"
105 # Azure sometimes adds a spurious ' to BUILD_TOOL_OPTIONS
106 BUILD_TOOL_OPTIONS="-j 4"
107 fi
108 cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
109 -DCMAKE_INSTALL_PREFIX=install \
110 -DCMAKE_PREFIX_PATH="${prefix_path//:/;}" \
111 -DANALYZER=${ANALYZER:-off} \
112 -DSANITIZER=${SANITIZER:-none} \
113 -DENABLE_SSL=${SSL:-on} \
114 -DENABLE_SECURITY=${SECURITY:-on} \
115 -DENABLE_LIFESPAN=${LIFESPAN:-on} \
116 -DENABLE_DEADLINE_MISSED=${DEADLINE_MISSED:-on} \
117 -DENABLE_TYPE_DISCOVERY=${TYPE_DISCOVERY:-on} \
118 -DENABLE_TOPIC_DISCOVERY=${TOPIC_DISCOVERY:-on} \
119 -DENABLE_COVERAGE=${COVERAGE:-off} \
120 -DENABLE_SHM=${ICEORYX:-off} \
121 -DBUILD_TESTING=on \
122 -DBUILD_IDLC_TESTING=${IDLC_TESTING:-on} \
123 -DBUILD_EXAMPLES=on \
124 -DWERROR=on \
125 ${GENERATOR:+-G} "${GENERATOR}" -A "${PLATFORM}" -T "${TOOLSET}" ..
126 ${SCAN_BUILD} cmake --build . --config ${BUILD_TYPE} --target install -- ${BUILD_TOOL_OPTIONS}
127 cmake --build . --config ${BUILD_TYPE} --target package -- ${BUILD_TOOL_OPTIONS}
128 name: script
129 - bash: |
130 set -e -x
131 cd build
132 ctest -j 4 --output-on-failure -T test -E '^CUnit_ddsrt_random_default_random$' -C ${BUILD_TYPE}
133 [[ "${BUILD_TYPE}" != 'Release' ]] || [[ "${COVERAGE:-off}" == 'off' ]] || \
134 ${SHELL} ../src/tools/ddsperf/sanity.bash
135 [[ "${SSL:-on}" != 'on' || "${SECURITY:-on}" != 'on' ]] || \
136 diff --strip-trailing-cr ../etc/cyclonedds.rnc docs/cyclonedds.rnc && \
137 diff --strip-trailing-cr ../etc/cyclonedds.xsd docs/cyclonedds.xsd && \
138 diff --strip-trailing-cr ../docs/manual/options.md docs/manual/options.md
139 [[ "${SANITIZER:-none}" == 'none' ]] || \
140 export CFLAGS="-fsanitize=${SANITIZER}" LDFLAGS="-fsanitize=${SANITIZER}"
141 INSTALLPREFIX="$(pwd)/install"
142 mkdir helloworld
143 cd helloworld
144 cmake -DCMAKE_PREFIX_PATH="${INSTALLPREFIX}" \
145 -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
146 ${GENERATOR:+-G} "${GENERATOR}" -A "${PLATFORM}" -T "${TOOLSET}" "${INSTALLPREFIX}/share/CycloneDDS/examples/helloworld"
147 cmake --build . --config ${BUILD_TYPE} -- ${BUILD_TOOL_OPTIONS}
148 condition: ne(variables['testing'], 'off')
149 name: test
150 displayName: Test
151 - bash: |
152 set -e -x
153 cd build
154 [[ "${AGENT_OS}" == 'Darwin' ]] && BUILD_TOOL_OPTIONS="-j 4"
155 cmake --build . --config ${BUILD_TYPE} --target gcov -- ${BUILD_TOOL_OPTIONS}
156 gcovr --exclude '.*/tests/.*' --root "${BUILD_SOURCESDIRECTORY}" --json "$(System.DefaultWorkingDirectory)/coverage-$(Agent.JobName).json"
157 name: generate_code_coverage
158 displayName: Generate coverage artifact
159 condition: and(succeededOrFailed(), eq(variables['coverage'], 'on'))
160 - publish: $(System.DefaultWorkingDirectory)/coverage-$(Agent.JobName).json
161 artifact: coverage-$(Agent.JobName)
162 displayName: Publish coverage artifact
163 condition: and(succeededOrFailed(), eq(variables['coverage'], 'on'))
164 - task: PublishTestResults@2
165 inputs:
166 testRunTitle: $(Agent.JobName)
167 testRunner: CTest
168 testResultsFiles: '**/Test.xml'
169 searchFolder: $(System.DefaultWorkingDirectory)/build/Testing
170 platform: $(arch)
171 configuration: $(build_type)
172 name: publish_test_results
173 displayName: Publish test results
174 condition: succeededOrFailed()