1- # This workflow runs a build with a python version that has debug symbols
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.
25# Update this workflow when our min/max python minor versions update
36# This workflow is necessary to ensure that we can build and run with
47# a debug python build without too much worrying about SIGABRT being thrown
58# IMPORTANT: binaries are not to be uploaded from this workflow!
69
7- name : Ubuntu debug python
10+ name : Ubuntu Checks
811defaults :
912 run :
1013 shell : bash -leo pipefail {0}
2326 - ' *.md'
2427 - ' .github/workflows/*.yml'
2528 # re-include current file to not be excluded
26- - ' !.github/workflows/build -ubuntu-debug-python .yml'
29+ - ' !.github/workflows/run -ubuntu-checks .yml'
2730
2831 pull_request :
2932 branches : main
3538 - ' *.md'
3639 - ' .github/workflows/*.yml'
3740 # re-include current file to not be excluded
38- - ' !.github/workflows/build -ubuntu-debug-python .yml'
41+ - ' !.github/workflows/run -ubuntu-checks .yml'
3942
4043concurrency :
41- group : ${{ github.workflow }}-${{ github.ref }}-ubuntu-debug-python
44+ group : ${{ github.workflow }}-${{ github.ref }}-ubuntu-checks
4245 cancel-in-progress : true
4346
4447jobs :
45- debug_python :
48+ debug_coverage :
4649 runs-on : ${{ matrix.os }}
4750 strategy :
4851 fail-fast : false # if a particular matrix build fails, don't skip the rest
6972 # https://github.com/orgs/community/discussions/47863
7073 run : |
7174 sudo apt-get update --fix-missing
72-
75+ sudo apt-get install lcov -y
7376 sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libfreetype6-dev libportmidi-dev -y
7477
7578 - name : Install pyenv
98101 id : build-pygame-ce
99102 run : |
100103 pyenv global ${{ matrix.python }}-debug
101- python dev.py build --lax
104+ python dev.py build --lax --coverage
102105
103106 - name : Run tests
104107 env :
@@ -107,3 +110,50 @@ jobs:
107110 run : |
108111 pyenv global ${{ matrix.python }}-debug
109112 python -m pygame.tests -v --exclude opengl,music,timing --time_out 300
113+
114+ - name : Generate coverage
115+ id : gen-coverage
116+ # want to continue regardless of whether a test failed or not as long as the job wasn't cancelled
117+ if : ${{ steps.build-pygame-ce.conclusion == 'success' && !cancelled() }}
118+ run : |
119+ lcov --capture --directory . --output-file ./coverage.info
120+ genhtml ./coverage.info --output-directory ./out
121+
122+ # We upload the generated files under github actions assets
123+ - name : Upload coverage html
124+ # want to continue only if the coverage generation was successful
125+ if : ${{ steps.gen-coverage.conclusion == 'success' && !cancelled() }}
126+ uses : actions/upload-artifact@v4
127+ with :
128+ name : pygame-coverage-${{ matrix.os }}-${{ matrix.python }}
129+ path : ./out
130+
131+ # Run cppcheck static analysis on src_c changes
132+ run-cppcheck :
133+ runs-on : ubuntu-24.04
134+ needs : debug_coverage
135+
136+ steps :
137+ - uses : actions/checkout@v4.2.2
138+
139+ - name : Check if any src_c files changed
140+ id : check-changes
141+ run : |
142+ git fetch origin ${{ github.base_ref }} --depth=1 || true
143+ git checkout ${{ github.base_ref }}
144+ CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
145+ echo "$CHANGED_FILES" | grep '^src_c/' || echo "skip=true" >> "$GITHUB_OUTPUT"
146+
147+ - name : Install cppcheck
148+ if : steps.check-changes.outputs.skip != 'true'
149+ run : |
150+ sudo apt-get update --fix-missing
151+ sudo apt install cppcheck
152+
153+ - name : Run Static Checker
154+ if : steps.check-changes.outputs.skip != 'true'
155+ run : cppcheck src_c --enable=performance,portability,warning \
156+ --suppress=*:src_c/freetype/ft_cache.c --suppress=*:src_c/scrap* \
157+ --suppress=*:src_c/scale_mmx*.c --suppress=*:src_c/SDL_gfx/* \
158+ --suppress=missingReturn --suppress=syntaxError -DWITH_THREAD -j $(nproc) \
159+ -DPG_MAJOR_VERSION -DPG_MINOR_VERSION -DPG_PATCH_VERSION -DPG_VERSION_TAG
0 commit comments