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
79+ CODEQL_ARTIFACT_NAME : l_codeql_${{ inputs.os }}_npu_${{ github.sha }}
6380 steps :
6481 - name : Get cache key
6582 if : ${{ inputs.build-cache }}
@@ -131,6 +148,14 @@ jobs:
131148 echo "ENABLE_TESTS_FLAG=OFF" >> $GITHUB_ENV
132149 fi
133150
151+ - name : Initialize CodeQL
152+ if : ${{ !steps.cache-restore.outputs.cache-hit && inputs.with-codeql }}
153+ uses : github/codeql-action/init@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
154+ with :
155+ languages : c-cpp
156+ build-mode : manual
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+ checkout_path : ${{ env.NPU_COMPILER_REPO }}
246+
247+ - name : Filter CodeQL results
248+ id : codeql-filtered-analyze
249+ if : ${{ !steps.cache-restore.outputs.cache-hit && inputs.with-codeql }}
250+ uses : advanced-security/filter-sarif@bc96d9fb9338c5b48cc440b1b4d0a350b26a20db # Release 1.0
251+ with :
252+ input : ${{ env.CODEQL_OUTPUTS }}/cpp.sarif
253+ output : ${{ env.CODEQL_OUTPUTS }}/filtered-results.sarif
254+ patterns : |
255+ +**
256+ -thirdparty/flatbuffers/**
257+ -thirdparty/gtest-parallel/**
258+ -thirdparty/llvm-project/**
259+ -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_ARTIFACT_NAME }}
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