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.
2
5
# Update this workflow when our min/max python minor versions update
3
6
# This workflow is necessary to ensure that we can build and run with
4
7
# a debug python build without too much worrying about SIGABRT being thrown
5
8
# IMPORTANT: binaries are not to be uploaded from this workflow!
6
9
7
- name : Ubuntu debug python
10
+ name : Ubuntu Checks
8
11
defaults :
9
12
run :
10
13
shell : bash -leo pipefail {0}
23
26
- ' *.md'
24
27
- ' .github/workflows/*.yml'
25
28
# re-include current file to not be excluded
26
- - ' !.github/workflows/build -ubuntu-debug-python .yml'
29
+ - ' !.github/workflows/run -ubuntu-checks .yml'
27
30
28
31
pull_request :
29
32
branches : main
35
38
- ' *.md'
36
39
- ' .github/workflows/*.yml'
37
40
# re-include current file to not be excluded
38
- - ' !.github/workflows/build -ubuntu-debug-python .yml'
41
+ - ' !.github/workflows/run -ubuntu-checks .yml'
39
42
40
43
concurrency :
41
- group : ${{ github.workflow }}-${{ github.ref }}-ubuntu-debug-python
44
+ group : ${{ github.workflow }}-${{ github.ref }}-ubuntu-checks
42
45
cancel-in-progress : true
43
46
44
47
jobs :
45
- debug_python :
48
+ debug_coverage :
46
49
runs-on : ${{ matrix.os }}
47
50
strategy :
48
51
fail-fast : false # if a particular matrix build fails, don't skip the rest
69
72
# https://github.com/orgs/community/discussions/47863
70
73
run : |
71
74
sudo apt-get update --fix-missing
72
-
75
+ sudo apt-get install lcov -y
73
76
sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libfreetype6-dev libportmidi-dev -y
74
77
75
78
- name : Install pyenv
@@ -95,10 +98,10 @@ jobs:
95
98
run : pyenv install ${{ matrix.python }} --debug -v
96
99
97
100
- name : Build pygame-ce
98
- id : build-pygame-ce
101
+ id : build
99
102
run : |
100
103
pyenv global ${{ matrix.python }}-debug
101
- python dev.py build --lax
104
+ python dev.py build --lax --coverage
102
105
103
106
- name : Run tests
104
107
env :
@@ -107,3 +110,49 @@ jobs:
107
110
run : |
108
111
pyenv global ${{ matrix.python }}-debug
109
112
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.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-wheels-coverage
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
+
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
+ CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
144
+ echo "$CHANGED_FILES" | grep '^src_c/' || echo "::set-output name=skip::true"
145
+
146
+ - name : Install cppcheck
147
+ if : steps.check-changes.outputs.skip != 'true'
148
+ run : |
149
+ sudo apt-get update --fix-missing
150
+ sudo apt install cppcheck
151
+
152
+ - name : Run Static Checker
153
+ if : steps.check-changes.outputs.skip != 'true'
154
+ run : cppcheck src_c --enable=performance,portability,warning \
155
+ --suppress=*:src_c/freetype/ft_cache.c --suppress=*:src_c/scrap* \
156
+ --suppress=*:src_c/scale_mmx*.c --suppress=*:src_c/SDL_gfx/* \
157
+ --suppress=missingReturn --suppress=syntaxError -DWITH_THREAD -j $(nproc) \
158
+ -DPG_MAJOR_VERSION -DPG_MINOR_VERSION -DPG_PATCH_VERSION -DPG_VERSION_TAG
0 commit comments