Skip to content

Commit 65ac33a

Browse files
authored
Merge pull request libgit2#5382 from libgit2/pks/azure-coverity
azure: fix Coverity pipeline
2 parents bd6b1c4 + 86c54cc commit 65ac33a

File tree

4 files changed

+69
-93
lines changed

4 files changed

+69
-93
lines changed

azure-pipelines/coverity-build.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.

azure-pipelines/coverity-publish.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.

azure-pipelines/coverity.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash -e
2+
3+
if test -z "$COVERITY_TOKEN"
4+
then
5+
echo "Need to set a coverity token"
6+
exit 1
7+
fi
8+
9+
case $(uname -m) in
10+
i?86)
11+
BITS=32;;
12+
amd64|x86_64)
13+
BITS=64;;
14+
*)
15+
echo "Unsupported arch '$(uname -m)'"
16+
exit 1;;
17+
esac
18+
19+
SCAN_TOOL=https://scan.coverity.com/download/cxx/linux${BITS}
20+
SOURCE_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)
21+
BUILD_DIR=${SOURCE_DIR}/coverity-build
22+
TOOL_DIR=${BUILD_DIR}/coverity-tools
23+
24+
# Install coverity tools
25+
if ! test -d "$TOOL_DIR"
26+
then
27+
mkdir -p "$TOOL_DIR"
28+
curl --silent --location --data "project=libgit2&token=$COVERITY_TOKEN" "$SCAN_TOOL" |
29+
tar -xzC "$TOOL_DIR"
30+
ln -s "$(find "$TOOL_DIR" -type d -name 'cov-analysis*')" "$TOOL_DIR"/cov-analysis
31+
fi
32+
33+
cp "${SOURCE_DIR}/script/user_nodefs.h" "$TOOL_DIR"/cov-analysis/config/
34+
35+
# Build libgit2 with Coverity
36+
mkdir -p "$BUILD_DIR"
37+
cd "$BUILD_DIR"
38+
cmake "$SOURCE_DIR"
39+
COVERITY_UNSUPPORTED=1 \
40+
"$TOOL_DIR/cov-analysis/bin/cov-build" --dir cov-int \
41+
cmake --build .
42+
43+
# Upload results
44+
tar -czf libgit2.tgz cov-int
45+
REVISION=$(cd ${SOURCE_DIR} && git rev-parse --short HEAD)
46+
HTML="$(curl \
47+
--silent \
48+
--write-out "\n%{http_code}" \
49+
--form token="$COVERITY_TOKEN" \
50+
--form email=libgit2@gmail.com \
51+
--form file=@libgit2.tgz \
52+
--form version="$REVISION" \
53+
--form description="libgit2 build" \
54+
https://scan.coverity.com/builds?project=libgit2)"
55+
56+
# Status code is the last line
57+
STATUS_CODE="$(echo "$HTML" | tail -n1)"
58+
if test "${STATUS_CODE}" != 200 && test "${STATUS_CODE}" != 201
59+
then
60+
echo "Received error code ${STATUS_CODE} from Coverity"
61+
exit 1
62+
fi

azure-pipelines/coverity.yml

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,20 @@ jobs:
77
pool:
88
vmImage: 'Ubuntu 16.04'
99
steps:
10+
- script: |
11+
cd $(Build.SourcesDirectory)/azure-pipelines/docker
12+
docker build -t libgit2/xenial --build-arg BASE=ubuntu:xenial -f xenial .
13+
displayName: 'Build Docker image'
1014
- task: Docker@0
11-
displayName: Build
15+
displayName: Analyze
1216
inputs:
1317
action: 'Run an image'
14-
docker:
15-
image: xenial
16-
base: xenial
18+
imageName: libgit2/xenial
1719
volumes: |
1820
$(Build.SourcesDirectory):/home/libgit2/source
1921
$(Build.BinariesDirectory):/home/libgit2/build
2022
envVars: |
2123
COVERITY_TOKEN=$(COVERITY_TOKEN)
2224
workDir: '/home/libgit2/build'
23-
containerCommand: '/home/libgit2/source/azure-pipelines/coverity-build.sh'
25+
containerCommand: '/home/libgit2/source/azure-pipelines/coverity.sh'
2426
detached: false
25-
- task: Docker@0
26-
displayName: Publish
27-
inputs:
28-
action: 'Run an image'
29-
imageName: 'libgit2/trusty-openssl:latest'
30-
volumes: |
31-
$(Build.SourcesDirectory):/home/libgit2/source
32-
$(Build.BinariesDirectory):/home/libgit2/build
33-
envVars: |
34-
COVERITY_TOKEN=$(COVERITY_TOKEN)
35-
workDir: '/home/libgit2/build'
36-
containerCommand: '/home/libgit2/source/azure-pipelines/coverity-publish.sh'
37-
detached: false
38-
continueOnError: true

0 commit comments

Comments
 (0)