Skip to content

Commit fd8c735

Browse files
authored
Add initial coverity workflow (#104)
1 parent 8eeda34 commit fd8c735

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

.github/workflows/coverity.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Coverity
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "5 2 * * *"
7+
8+
permissions: read-all
9+
10+
jobs:
11+
coverity:
12+
name: Coverity
13+
14+
runs-on:
15+
- ubuntu-latest
16+
defaults:
17+
run:
18+
shell: bash -noprofile --norc -eo pipefail {0}
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Install Python 3.10
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.10'
28+
29+
- name: Load coverity from cache
30+
id: coverity-cache
31+
uses: ./.github/actions/load
32+
env:
33+
# Increase this value to reset cache
34+
CACHE_NUMBER: 1
35+
with:
36+
path: $HOME/coverity
37+
key: coverity-$CACHE_NUMBER
38+
39+
- name: Download coverity
40+
if: ${{ steps.coverity-cache.outputs.status == 'miss' }}
41+
env:
42+
COVERITY_TOKEN: ${{ secrets.COVERITY_TOKEN }}
43+
run: |
44+
cd $HOME
45+
wget https://scan.coverity.com/download/linux64 --no-verbose --post-data "token=$COVERITY_TOKEN&project=intel%2Fgraph-compiler" -O coverity.tgz
46+
tar zxf coverity.tgz
47+
mv -T cov-analysis-linux64-* coverity
48+
49+
- name: Add coverity to PATH
50+
run: |
51+
echo "$HOME/coverity/bin" >> $GITHUB_PATH
52+
53+
- name: Show coverity version
54+
run: |
55+
coverity --version
56+
57+
- name: Save coverity to cache
58+
if: ${{ steps.coverity-cache.outputs.status == 'miss' }}
59+
uses: ./.github/actions/save
60+
with:
61+
path: ${{ steps.coverity-cache.outputs.path }}
62+
dest: ${{ steps.coverity-cache.outputs.dest }}
63+
64+
- name: Add coverity inputs to env
65+
run: |
66+
version_id=$(grep 'project(GraphCompiler VERSION' CMakeLists.txt | awk '{print $3}' | tr -d '"')
67+
version_local_id="$(git rev-parse --short HEAD)"
68+
version="${version_id}+git${version_local_id}"
69+
70+
project_id=30281
71+
72+
echo "project_id=$project_id" | tee -a $GITHUB_ENV
73+
echo "email=$email" | tee -a $GITHUB_ENV
74+
echo "version=$version" | tee -a $GITHUB_ENV
75+
76+
- name: Run coverity build
77+
run: |
78+
pip install wheel
79+
cd python
80+
cov-build --dir $HOME/cov-int scripts/compile.sh
81+
tail $HOME/cov-int/build-log.txt
82+
83+
- name: Create coverity results tarball
84+
run: |
85+
cd $HOME
86+
tar zcf cov-int.tgz cov-int
87+
88+
- name: Version for coverity build
89+
run: |
90+
91+
92+
- name: Create coverity build
93+
env:
94+
COVERITY_TOKEN: ${{ secrets.COVERITY_TOKEN }}
95+
run: |
96+
cd $HOME
97+
curl -X POST \
98+
-d version="$version" \
99+
-d email="$email" \
100+
-d token=$COVERITY_TOKEN \
101+
-d file_name="cov-int.tgz" \
102+
https://scan.coverity.com/projects/$project_id/builds/init \
103+
| tee response
104+
upload_url="$(jq -r '.url' response)"
105+
build_id="$(jq -r '.build_id' response)"
106+
echo "upload_url=$upload_url" >> $GITHUB_ENV
107+
echo "build_id=$build_id" | tee -a $GITHUB_ENV
108+
109+
- name: Upload coverity build
110+
env:
111+
COVERITY_TOKEN: ${{ secrets.COVERITY_TOKEN }}
112+
run: |
113+
cd $HOME
114+
curl -X PUT \
115+
--header 'Content-Type: application/json' \
116+
--upload-file cov-int.tgz \
117+
$upload_url
118+
119+
curl -X PUT \
120+
-d token=$COVERITY_TOKEN \
121+
https://scan.coverity.com/projects/$project_id/builds/$build_id/enqueue

0 commit comments

Comments
 (0)