Skip to content

Commit f990414

Browse files
committed
Combine all "checks" CI into a single workflow
1 parent ffcda0d commit f990414

File tree

3 files changed

+58
-147
lines changed

3 files changed

+58
-147
lines changed

.github/workflows/build-ubuntu-coverage.yml

Lines changed: 0 additions & 97 deletions
This file was deleted.

.github/workflows/cppcheck.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/build-ubuntu-debug-python.yml renamed to .github/workflows/run-ubuntu-checks.yml

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
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
811
defaults:
912
run:
1013
shell: bash -leo pipefail {0}
@@ -23,7 +26,7 @@ on:
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
@@ -35,14 +38,14 @@ on:
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

4043
concurrency:
41-
group: ${{ github.workflow }}-${{ github.ref }}-ubuntu-debug-python
44+
group: ${{ github.workflow }}-${{ github.ref }}-ubuntu-checks
4245
cancel-in-progress: true
4346

4447
jobs:
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
@@ -69,7 +72,7 @@ jobs:
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
@@ -95,10 +98,10 @@ jobs:
9598
run: pyenv install ${{ matrix.python }} --debug -v
9699

97100
- name: Build pygame-ce
98-
id: build-pygame-ce
101+
id: build
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,49 @@ 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.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+
- uses: actions/[email protected]
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

Comments
 (0)