2727 description : ' Cache package suffix'
2828 type : string
2929 required : false
30+ with-codeql :
31+ description : ' Whether to run CodeQL static C/C++ analyzer'
32+ type : boolean
33+ required : false
34+ default : false
3035 with-tests :
3136 description : ' Whether to build test targets'
3237 type : boolean
@@ -41,15 +46,25 @@ defaults:
4146 run :
4247 shell : bash
4348
44- permissions : read-all
49+ permissions :
50+ actions : read
51+ contents : read
52+ packages : read
53+ statuses : read
4554
4655jobs :
4756 Build :
4857 name : Build
4958 runs-on : ${{ inputs.build-runner }}
5059 timeout-minutes : 240
60+ permissions :
61+ actions : read
62+ contents : read
63+ packages : read
64+ statuses : read
65+ security-events : write
5166 outputs :
52- build-package : ${{ steps.set-build-package-name.outputs.build-package }}
67+ build-package : ${{ steps.set-build-package-name.outputs.build-package }}
5368 env :
5469 DEBIAN_FRONTEND : noninteractive
5570 CMAKE_BUILD_TYPE : ' Release'
6075 NPU_COMPILER_BUILD_DIR : ./npu_compiler_build
6176 OPENVINO_INSTALL_DIR : ./openvino_install
6277 OPENVINO_BUILD_PACKAGE : l_ov_dyn_${{ inputs.os }}_npu_${{ github.sha }}
78+ CODEQL_OUTPUTS : ./codeql_outputs
6379 steps :
6480 - name : Get cache key
6581 if : ${{ inputs.build-cache }}
@@ -131,6 +147,15 @@ jobs:
131147 echo "ENABLE_TESTS_FLAG=OFF" >> $GITHUB_ENV
132148 fi
133149
150+ - name : Initialize CodeQL
151+ if : ${{ !steps.cache-restore.outputs.cache-hit && inputs.with-codeql }}
152+ uses : github/codeql-action/init@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
153+ with :
154+ languages : c-cpp
155+ build-mode : manual
156+ config-file : ${{ env.NPU_COMPILER_REPO }}/.github/codeql/config.yml
157+ source-root : ${{ env.NPU_COMPILER_REPO }}
158+
134159 - name : CMake configure - OpenVINO
135160 if : ${{ !steps.cache-restore.outputs.cache-hit }}
136161 run : |
@@ -209,12 +234,51 @@ jobs:
209234 cmake --install ${NPU_COMPILER_BUILD_DIR} --config ${{ env.CMAKE_BUILD_TYPE }} --prefix ${OPENVINO_INSTALL_DIR}
210235 cmake --install ${NPU_COMPILER_BUILD_DIR} --config ${{ env.CMAKE_BUILD_TYPE }} --prefix ${OPENVINO_INSTALL_DIR} --component tests
211236
237+ - name : Perform CodeQL Analysis
238+ id : codeql-analyze
239+ if : ${{ !steps.cache-restore.outputs.cache-hit && inputs.with-codeql }}
240+ uses : github/codeql-action/analyze@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
241+ with :
242+ category : " /language:c-cpp"
243+ output : ${{ env.CODEQL_OUTPUTS }}
244+ upload : failure-only
245+
246+ - name : Filter CodeQL results
247+ id : codeql-filtered-analyze
248+ if : ${{ !steps.cache-restore.outputs.cache-hit && inputs.with-codeql }}
249+ uses : advanced-security/filter-sarif@bc96d9fb9338c5b48cc440b1b4d0a350b26a20db # Release 1.0
250+ with :
251+ input : ${{ env.CODEQL_OUTPUTS }}
252+ output : ${{ env.CODEQL_OUTPUTS }}/filtered-results.sarif
253+ include : |
254+ - ${{ env.NPU_COMPILER_REPO }}/**
255+ exclude : |
256+ - ${{ env.NPU_COMPILER_REPO }}/thirdparty/flatbuffers/**
257+ - ${{ env.NPU_COMPILER_REPO }}/thirdparty/gtest-parallel/**
258+ - ${{ env.NPU_COMPILER_REPO }}/thirdparty/llvm-project/**
259+ - ${{ env.NPU_COMPILER_REPO }}/thirdparty/yaml-cpp/**
260+
261+ - name : Upload CodeQL SARIF
262+ if : ${{ !steps.cache-restore.outputs.cache-hit && inputs.with-codeql }}
263+ uses : github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
264+ with :
265+ sarif_file : ${{ env.CODEQL_OUTPUTS }}/filtered-results.sarif
266+ checkout_path : ${{ env.NPU_COMPILER_REPO }}
267+
268+ - name : Upload CodeQL loc as a Build Artifact
269+ if : ${{ !steps.cache-restore.outputs.cache-hit && inputs.with-codeql }}
270+ uses : actions/upload-artifact@v4
271+ with :
272+ name : ${{ env.CODEQL_OUTPUTS }}
273+ path : ${{ env.CODEQL_OUTPUTS }}
274+ retention-days : 1
275+
212276 - name : Cache artifacts
213277 if : ${{ inputs.build-cache && !steps.cache-restore.outputs.cache-hit }}
214278 uses : actions/cache/save@v4
215279 with :
216280 path : ${{ env.OPENVINO_INSTALL_DIR }}
217- key : ${{ needs.Cache .outputs.cache-key }}
281+ key : ${{ steps.cache-key .outputs.cache-key }}
218282
219283 - name : Upload artifacts
220284 uses : actions/upload-artifact@v4
0 commit comments