forked from intel/mlir-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (141 loc) · 5.45 KB
/
coverity.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Coverity
on:
workflow_dispatch:
schedule:
- cron: "5 2 * * 1"
push:
paths:
- .github/workflows/coverity.yml
permissions: read-all
jobs:
coverity:
name: Coverity
runs-on: ubuntu-latest
env:
COV_TOKEN: jQxsG_hSGU57M7A7lqyBvg
LLVM_SHA_FILE: /home/runner/work/mlir-extensions/mlir-extensions/build_tools/llvm_version.txt
defaults:
run:
shell: bash -leo pipefail {0}
timeout-minutes: 450
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache coverity
id: cache-coverity
uses: actions/cache@v4
env:
COVERITY_CACHE_NUMBER: 1 # Increase to reset cache
with:
path: |
/home/runner/coverity
key: ${{ runner.os }}-${{ env.COVERITY_CACHE_NUMBER }}
- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python }}
activate-environment: imex-devel
- name: Conda info
run: conda info
- name: Install Build tools
run: |
conda install cmake ninja conda-forge::lit conda-forge::doxygen
conda list
- name: Download coverity
if: steps.cache-coverity.outputs.cache-hit != 'true'
run: |
cd
curl -X POST https://scan.coverity.com/download/linux64 -d "token=$COV_TOKEN" --data-urlencode "project=MLIR Extensions" -o coverity.tgz
tar zxf coverity.tgz
mv -T cov-analysis-linux64-* coverity
- name: Add coverity to PATH
run: |
echo "$HOME/coverity/bin" >> $GITHUB_PATH
- name: Show coverity version
run: |
coverity --version
- name: Add coverity inputs to env
run: |
version="$(git rev-parse --short HEAD)"
email="[email protected]"
project_id=30755
echo "project_id=$project_id" | tee -a $GITHUB_ENV
echo "email=$email" | tee -a $GITHUB_ENV
echo "version=$version" | tee -a $GITHUB_ENV
- name: Setup Cache Vars
run: |
echo 'LLVM_SHA<<EOF' >> $GITHUB_ENV
cat $LLVM_SHA_FILE >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Cache LLLVM-MLIR
id: cache-llvm-mlir
uses: actions/cache@v4
env:
LLVM_CACHE_NUMBER: 1 # Increase to reset cache
with:
path: |
/home/runner/work/llvm-mlir/_mlir_install/**
key: ${{ runner.os }}-build-llvm-${{ env.LLVM_CACHE_NUMBER }}-${{ env.LLVM_SHA }}
- name: Build LLVM-MLIR
if: steps.cache-llvm-mlir.outputs.cache-hit != 'true'
run: |
mkdir -p /home/runner/work/llvm-mlir
cd /home/runner/work/llvm-mlir
echo "INFO: Need to rebuild LLVM-MLIR. Previous installation for MLIR not found"
np=`nproc`
echo "INFO: nproc $np"
git clone https://github.com/llvm/llvm-project --branch main --single-branch
cd llvm-project
git checkout ${LLVM_SHA}
git apply /home/runner/work/mlir-extensions/mlir-extensions/build_tools/patches/*.patch
cmake -G Ninja -B _build -S llvm \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_USE_LINKER=gold \
-DLLVM_INSTALL_UTILS=ON \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DCMAKE_INSTALL_PREFIX=/home/runner/work/llvm-mlir/_mlir_install
cmake --build _build --target install
- name: Create coverity build
run: |
external_lit=`which lit`
echo ${external_lit}
cd /home/runner/work/mlir-extensions/mlir-extensions
cmake -S . -B _build -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_EXTERNAL_LIT=${external_lit} \
-DMLIR_DIR=/home/runner/work/llvm-mlir/_mlir_install/lib/cmake/mlir \
-DLLVM_LIT_ARGS=-a
cov-build --dir $HOME/cov-int cmake --build _build --target check-imex
- name: Create coverity results tarball
run: |
cd $HOME
tar zcf cov-int.tgz cov-int
- name: Create coverity artifact
run: |
cd $HOME
curl -X POST \
-d version="$version" \
-d email="$email" \
-d token=$COV_TOKEN \
-d file_name="cov-int.tgz" \
https://scan.coverity.com/projects/$project_id/builds/init \
| tee response
upload_url="$(jq -r '.url' response)"
build_id="$(jq -r '.build_id' response)"
echo "upload_url=$upload_url" >> $GITHUB_ENV
echo "build_id=$build_id" | tee -a $GITHUB_ENV
- name: Upload coverity build
run: |
cd $HOME
curl -X PUT \
--header 'Content-Type: application/json' \
--upload-file cov-int.tgz \
$upload_url
curl -X PUT \
-d token=$COV_TOKEN \
https://scan.coverity.com/projects/$project_id/builds/$build_id/enqueue