@@ -6,17 +6,12 @@ name: "[Code Analysis] Coverity (C/C++)"
66run-name : " [Code Analysis] Coverity (C/C++)"
77
88on :
9- workflow_call : {}
109 workflow_dispatch : {}
1110 push :
1211 branches :
1312 - main
1413 - release-*
1514
16- # Trigger workflow when enqueued to a merge group
17- # (must be under 'on')
18- merge_group : {}
19-
2015permissions : {}
2116
2217# Only run at most 1 workflow concurrently per PR or per branch to keep costs down
@@ -31,54 +26,29 @@ jobs:
3126 permissions :
3227 contents : read
3328 outputs :
34- run-analysis : ${{ steps.detect-langs .outputs.run-analysis }}
29+ run-analysis : ${{ steps.changes .outputs.cpp }}
3530 steps :
3631 - name : " Checkout code"
3732 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
3833 with :
3934 persist-credentials : false
4035 fetch-depth : 0 # Fetch all history for accurate diff
41-
42- - name : " Detect changed languages"
43- id : detect-langs
44- run : |
45- if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
46- echo "Manual dispatch: always run analysis."
47- echo "run-analysis=true" >> $GITHUB_OUTPUT
48- exit 0
49- else
50- if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then
51- git fetch origin main:main
52- echo "Fetched main branch"
53- fi
54- if [ -z "$GITHUB_SHA" ]; then
55- echo "Error: GITHUB_SHA is not set or empty."
56- exit 1
57- fi
58- changed_files=$(git diff --name-only main...$GITHUB_SHA -- '*.h' '*.hpp' '*.c' '*.cpp')
59- if [ $? -ne 0 ]; then
60- echo "Error: git diff command failed."
61- exit 1
62- fi
63- echo "Performed git diff"
64- if [ -z "$changed_files" ]; then
65- echo "No relevant changed files detected."
66- echo "run-analysis=false" >> $GITHUB_OUTPUT
67- exit 0
68- else
69- run_analysis=true
70- fi
71- echo "Changed files:"
72- echo "$changed_files"
73- echo "Run analysis:"
74- echo "$run_analysis"
75- echo "run-analysis=$run_analysis" >> $GITHUB_OUTPUT
76- fi
36+ ref : 4b2b119568189314f3e9a21015725f765ae49026
37+ - name : Detect C/C++ changes
38+ id : changes
39+ uses : dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
40+ with :
41+ filters : |
42+ cpp:
43+ - '**/*.cpp'
44+ - '**/*.c'
45+ - '**/*.h'
46+ - '**/*.hpp'
7747
7848 coverity-scan :
7949 name : " Coverity Scan"
8050 needs : detect-languages
81- if : ${{ needs.detect-languages.outputs.run-analysis == 'true' }}
51+ if : ${{ github.event_name == 'workflow_dispatch' || needs.detect-languages.outputs.run-analysis == 'true' }}
8252 runs-on : ubuntu-latest
8353 permissions :
8454 contents : read
9565 sudo apt-get install -y --no-install-recommends cmake curl g++ git libeigen3-dev libgtest-dev make \
9666 pkg-config python3-dev pybind11-dev python3-pip python3-scipy python-is-python3 libopencv-dev python3-venv
9767 pip3 install --use-pep517 -r .github/resources/coverity-requirements.txt
68+ sudo make -C tracker install-deps
69+ make -C tracker install-tools
70+ conan profile detect --force
9871
9972 - name : " Download Coverity Scan Tool"
10073 run : |
0 commit comments