[projmgr] Check invalid context-set
(#1086)
#397
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: cpp-linter | |
on: | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- '.github/workflows/cpp-linter.yml' | |
- '.github/.cppcheck_suppressions' | |
- '.github/cppcheck_googletest.cfg' | |
- '**/*.cpp' | |
- '**/*.h' | |
- '**/*.hpp' | |
- '**/*.in' | |
- '**/CMakeLists.txt' | |
- '!**/docs/**/*' | |
- '!**/*.md' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
linter_report: "cppcheck_report.md" | |
permissions: | |
contents: read | |
jobs: | |
lint: | |
name: cppcheck | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Harden Runner | |
if: ${{ !github.event.repository.private }} | |
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 | |
with: | |
egress-policy: audit | |
- name: Checkout devtools | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install cppcheck | |
- name: Run cppcheck | |
run: | | |
cppcheck --enable=performance,portability,unusedFunction,warning \ | |
--library=.github/cppcheck_googletest.cfg --suppressions-list=.github/.cppcheck_suppressions \ | |
--force -i./external --language=c++ --max-ctu-depth=20 \ | |
--platform=unix64 --std=c++17 --verbose --std=c++17 \ | |
-i./tools/buildmgr/test -i./tools/packchk/test \ | |
-i./tools/packgen/test -i./tools/projmgr/test \ | |
-i./tools/svdconv/Test -i./test \ | |
--template="|{file}|{line}|{severity}|{message}|" \ | |
--output-file=./${{ env.linter_report }} . | |
- name: Check errors | |
run: | | |
echo "value=$(test ! -s ${{ env.linter_report}} &>/dev/null ; echo $?)" >> $GITHUB_OUTPUT | |
id: errors | |
- name: Append report | |
if: ${{ steps.errors.outputs.value == '1' }} | |
run: | | |
echo -e -n "## :boom: [Linter Results](https://cppcheck.sourceforge.io/)\\n|File|Line|Severity|Message|\n|:--|:--|:--|--|\n" | cat - ./${{ env.linter_report }} > ./tmpfile | |
mv ./tmpfile ./${{ env.linter_report }} | |
- name: Archive Cppcheck results | |
if: ${{ steps.errors.outputs.value == '1' }} | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: cppcheck-report | |
path: ./${{ env.linter_report }} | |
retention-days: 1 | |
if-no-files-found: error | |
- name: Print Linter Summary | |
if: ${{ steps.errors.outputs.value == '1' }} | |
run: cat ${{ env.linter_report }} >> $GITHUB_STEP_SUMMARY | |
- name: Validate results | |
run: | | |
if [ "${{ steps.errors.outputs.value}}" = "1" ]; then | |
echo "💥 Issue(s) detected. Check summary: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
exit 1 | |
else | |
echo "👍 No issues detected." | |
fi |