Debian Codegraph @

.azure/coverity-scan.yml

raw
1 #
2 # Copyright(c) 2021 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 # Azure Pipeline specifically for building and submitting to Coverity Scan
15 #
16
17 trigger: none
18 pr: none
19
20 schedules:
21 - cron: "0 12 * * *"
22 branches:
23 include: [ master ]
24 always: false
25
26 strategy:
27 matrix:
28 'Ubuntu 20.04 LTS with Clang 10 (Debug, x86_64)':
29 image: ubuntu-20.04
30 cc: clang
31 cxx: clang++
32
33 pool:
34 vmImage: $(image)
35
36 steps:
37 ## Fetch version number to ensure up-to-date cache
38 - bash: |
39 set -e
40 slug=$(echo "${BUILD_REPOSITORY_URI}" | sed -nE 's#.*/([^/]+/[^\]+)#\1#p')
41 headers=$(basename $(mktemp "$(pwd)/curl.XXXXXXXX"))
42 code=$(curl -X HEAD -s -S -F project="${slug}" \
43 -F token="${token}" \
44 -o /dev/null -D ${headers} -w '%{http_code}' \
45 "https://scan.coverity.com/download/cxx/linux64")
46 [ "${code}" != "200" ] && echo "cURL exited with ${code}" 1>&2 && exit 1
47 file=$(sed -n -E 's/.*filename="([^"]+)".*/\1/p' ${headers})
48 echo "###vso[task.setvariable variable=cov_archive;]${file}"
49 echo "###vso[task.setvariable variable=cov_analysis;]$(pwd)/cov-analysis"
50 echo "###vso[task.setvariable variable=PATH;]$(pwd)/cov-analysis/bin:${PATH}"
51 rm -f ${headers}
52 name: setup_coverity
53 env:
54 token: $(COVERITY_SCAN_TOKEN)
55 - task: Cache@2
56 inputs:
57 key: coverity | 1 | "$(cov_archive)"
58 path: $(cov_analysis)
59 cacheHitVar: coverity_cached
60 name: cache_coverity
61 ## Download Coverity on cache miss
62 - bash: |
63 set -e
64 slug=$(echo "${BUILD_REPOSITORY_URI}" | sed -nE 's#.*/([^/]+/[^\]+)#\1#p')
65 headers=$(basename $(mktemp "$(pwd)/tmp.XXXXXXXX"))
66 code=$(curl -s -S -F project="${slug}" \
67 -F token="${token}" \
68 -O -J -D ${headers} -w '%{http_code}' \
69 "https://scan.coverity.com/download/cxx/linux64")
70 [ "${code}" != "200" ] && echo "cURL exited with ${code}" 1>&2 && exit 1
71 file=$(sed -n -E 's/^.*filename="([^"]+)".*$/\1/p' ${headers})
72 tar -xzf ${file} -C .
73 dir=$(find . -type d -name "cov-analysis*" | head -1)
74 mv "${dir}" "${COV_ANALYSIS}"
75 rm -f ${headers} "${file}"
76 name: install_coverity
77 condition: ne(variables['coverity_cached'], 'true')
78 env:
79 token: $(COVERITY_SCAN_TOKEN)
80 - bash: |
81 set -e -x
82 echo "###vso[task.setvariable variable=scan_build;]cov-build --dir $(pwd)/cov-int"
83 cov-configure --clang
84 name: configure_coverity
85 - template: /.azure/templates/build-test.yml
86 ## Submit to Coverity Scan
87 - bash: |
88 set -e -x
89 slug=$(echo "${BUILD_REPOSITORY_URI}" | sed -nE 's#.*/([^/]+/[^\]+)#\1#p')
90 tar -czf analysis-results.tgz cov-int
91 code=$(curl -s -S -F project="${slug}" \
92 -F token="${token}" \
93 -F [email protected] \
94 -F version=$(git rev-parse --short HEAD) \
95 -F description="Azure Pipelines build" \
96 -F email="${COVERITY_SCAN_EMAIL:[email protected]}" \
97 -w '%{http_code}' \
98 "https://scan.coverity.com/builds")
99 [[ "${code}" =~ "success" ]] || (echo "cURL exited with ${code}" 1>&2 && exit 1)
100 rm -f analysis-results.tgz
101 name: submit_to_coverity_scan
102 env:
103 token: $(COVERITY_SCAN_TOKEN)
104 ## Save Coverity build log for debugging
105 - task: PublishBuildArtifacts@1
106 inputs:
107 pathToPublish: cov-int/build-log.txt
108 artifactName: 'coverity-build-log.txt'