1- # This workflow runs a build with a python version that has debug symbols
2- # Also generates coverage information from unit tests
3- #
4- # Note that for intrinsics, it only runs what gets compiled
5- # -# and would naturally run. It also is limited to what can run in
6- # -# a CI environment
7- # -# IMPORTANT: binaries are not to be uploaded from this workflow!
8- #
1+ # This workflow runs a build with a python version that has debug symbols.
2+ # Also generates coverage information from unit tests. Note that for intrinsics,
3+ # it only runs what gets compiled and would naturally run. It also is limited to
4+ # what can run in a CI environment.
95# Update this workflow when our min/max python minor versions update
106# This workflow is necessary to ensure that we can build and run with
117# a debug python build without too much worrying about SIGABRT being thrown
128# IMPORTANT: binaries are not to be uploaded from this workflow!
139
14- name : Ubuntu debug
10+ name : Ubuntu Checks
1511defaults :
1612 run :
1713 shell : bash -leo pipefail {0}
3026 - ' *.md'
3127 - ' .github/workflows/*.yml'
3228 # re-include current file to not be excluded
33- - ' !.github/workflows/build -ubuntu-debug .yml'
29+ - ' !.github/workflows/run -ubuntu-checks .yml'
3430
3531 pull_request :
3632 branches : main
4238 - ' *.md'
4339 - ' .github/workflows/*.yml'
4440 # re-include current file to not be excluded
45- - ' !.github/workflows/build -ubuntu-debug .yml'
41+ - ' !.github/workflows/run -ubuntu-checks .yml'
4642
4743concurrency :
48- group : ${{ github.workflow }}-${{ github.ref }}-ubuntu-debug
44+ group : ${{ github.workflow }}-${{ github.ref }}-ubuntu-checks
4945 cancel-in-progress : true
5046
5147jobs :
52- debug :
48+ debug_coverage :
5349 runs-on : ${{ matrix.os }}
5450 strategy :
5551 fail-fast : false # if a particular matrix build fails, don't skip the rest
@@ -106,7 +102,7 @@ jobs:
106102 id : build-pygame-ce
107103 run : |
108104 pyenv global ${{ matrix.python }}-debug
109- python dev.py build --wheel -- lax --coverage --ctest
105+ python dev.py build --lax --coverage
110106
111107 - name : Run tests
112108 env :
@@ -119,7 +115,7 @@ jobs:
119115 - name : Generate coverage
120116 id : gen-coverage
121117 # want to continue regardless of whether a test failed or not as long as the job wasn't cancelled
122- if : ${{ steps.build.conclusion == 'success' && !cancelled() }}
118+ if : ${{ steps.build-pygame-ce .conclusion == 'success' && !cancelled() }}
123119 run : |
124120 lcov --capture --directory . --output-file ./coverage.info
125121 genhtml ./coverage.info --output-directory ./out
@@ -139,3 +135,32 @@ jobs:
139135 with :
140136 name : ctest_suite_log
141137 path : ./ctest.log
138+
139+ # Run cppcheck static analysis on src_c changes
140+ run-cppcheck :
141+ runs-on : ubuntu-24.04
142+ needs : debug_coverage
143+
144+ steps :
145+ - uses : actions/checkout@v4.2.2
146+
147+ - name : Check if any src_c files changed
148+ id : check-changes
149+ run : |
150+ git fetch origin ${{ github.base_ref }} --depth=1 || true
151+ CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
152+ echo "$CHANGED_FILES" | grep '^src_c/' || echo "::set-output name=skip::true"
153+
154+ - name : Install cppcheck
155+ if : steps.check-changes.outputs.skip != 'true'
156+ run : |
157+ sudo apt-get update --fix-missing
158+ sudo apt install cppcheck
159+
160+ - name : Run Static Checker
161+ if : steps.check-changes.outputs.skip != 'true'
162+ run : cppcheck src_c --enable=performance,portability,warning \
163+ --suppress=*:src_c/freetype/ft_cache.c --suppress=*:src_c/scrap* \
164+ --suppress=*:src_c/scale_mmx*.c --suppress=*:src_c/SDL_gfx/* \
165+ --suppress=missingReturn --suppress=syntaxError -DWITH_THREAD -j $(nproc) \
166+ -DPG_MAJOR_VERSION -DPG_MINOR_VERSION -DPG_PATCH_VERSION -DPG_VERSION_TAG
0 commit comments