Skip to content

Commit 90de48c

Browse files
committed
CI: Add workflow for CMake build system
1 parent e7d837c commit 90de48c

1 file changed

Lines changed: 125 additions & 0 deletions

File tree

.github/workflows/build_cmake.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Build (CMake)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
defaults:
14+
run:
15+
shell: bash
16+
17+
jobs:
18+
build:
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: ['ubuntu', 'windows']
23+
# Qt 5.12.* is excluded: CMakeLists.txt requires Qt >= 5.15.0.
24+
qt-version: [ '5.15.*', '6.10.*' ]
25+
python-version: [ '3.12' ]
26+
runs-on: ${{ matrix.os }}-latest
27+
steps:
28+
29+
- name: Install MSVC
30+
if: ${{ matrix.os == 'windows' }}
31+
uses: ilammy/msvc-dev-cmd@v1
32+
with:
33+
arch: amd64
34+
35+
- name: Install Qt ${{ matrix.qt-version }}
36+
uses: jurplel/install-qt-action@v4
37+
with:
38+
version: ${{ matrix.qt-version }}
39+
modules: ${{ startsWith(matrix.qt-version, '6') && 'qt5compat qtscxml qtpositioning qtwebchannel qtmultimedia qtwebengine' || '' }}
40+
arch: ${{ (matrix.os == 'ubuntu' && (startsWith(matrix.qt-version, '5') && 'gcc_64' || 'linux_gcc_64')) || startsWith(matrix.qt-version, '6') && 'win64_msvc2022_64' || 'win64_msvc2019_64' }}
41+
42+
- name: Setup Python ${{ matrix.python-version }}
43+
uses: actions/setup-python@v6
44+
with:
45+
python-version: '${{ matrix.python-version }}'
46+
47+
- name: Checkout PythonQt
48+
uses: actions/checkout@v6
49+
50+
- name: Ccache
51+
if: ${{ matrix.os == 'ubuntu' }}
52+
uses: hendrikmuhs/ccache-action@v1.2.20
53+
with:
54+
key: ${{ runner.os }}-cmake-${{ matrix.qt-version }}
55+
evict-old-files: 'job'
56+
57+
- name: Set environment
58+
id: setenv
59+
run: |
60+
QT_VERSION_MAJOR=$(cut -f 1 -d . <<< "${{ matrix.qt-version }}")
61+
echo "QT_VERSION_MAJOR=$QT_VERSION_MAJOR" >> $GITHUB_ENV
62+
QT_VERSION_SHORT=$(cut -f 1,2 -d . <<< "${{ matrix.qt-version }}")
63+
echo "QT_VERSION_SHORT=$QT_VERSION_SHORT" >> $GITHUB_OUTPUT
64+
PYTHON_VERSION_FULL=$(python --version 2>&1 | cut -f 2 -d ' ')
65+
PYTHON_VERSION_SHORT=$(cut -f 1,2 -d . <<< $PYTHON_VERSION_FULL)
66+
echo "PYTHON_VERSION_SHORT=$PYTHON_VERSION_SHORT" >> $GITHUB_OUTPUT
67+
echo "$pythonLocation/bin" >> $GITHUB_PATH
68+
69+
- name: Build generator
70+
run: |
71+
cmake -G Ninja -S generator -B generator/build \
72+
-DCMAKE_BUILD_TYPE=Release \
73+
-DCMAKE_PREFIX_PATH="$QT_ROOT_DIR"
74+
cmake --build generator/build
75+
76+
- name: Generate Wrappers
77+
run: |
78+
QTDIR="$QT_ROOT_DIR" \
79+
UBSAN_OPTIONS="halt_on_error=1" \
80+
ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \
81+
./generator/build/PythonQtGenerator \
82+
--output-directory=.
83+
84+
- name: Upload Wrappers
85+
uses: actions/upload-artifact@v7
86+
with:
87+
name: cmake_wrappers_${{ matrix.os }}_${{ steps.setenv.outputs.QT_VERSION_SHORT }}
88+
path: generated_cpp
89+
if-no-files-found: error
90+
91+
- name: Build and test PythonQt (Ubuntu)
92+
if: ${{ matrix.os == 'ubuntu' }}
93+
run: |
94+
cmake -G Ninja -S . -B build \
95+
-DCMAKE_BUILD_TYPE=Release \
96+
-DCMAKE_PREFIX_PATH="$QT_ROOT_DIR" \
97+
-DPythonQt_QT_VERSION=$QT_VERSION_MAJOR \
98+
"-DPythonQt_GENERATED_PATH=$(pwd)/generated_cpp" \
99+
-DBUILD_TESTING=ON \
100+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
101+
"-DCMAKE_CXX_FLAGS=-fsanitize=address,undefined -fno-sanitize-recover=undefined" \
102+
"-DCMAKE_EXE_LINKER_FLAGS=-fsanitize=address,undefined" \
103+
"-DCMAKE_SHARED_LINKER_FLAGS=-fsanitize=address,undefined"
104+
cmake --build build --parallel $(nproc)
105+
PYTHONDEVMODE=1 PYTHONASYNCIODEBUG=1 PYTHONWARNINGS=error PYTHONMALLOC=malloc_debug \
106+
UBSAN_OPTIONS="halt_on_error=1" ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \
107+
QT_QPA_PLATFORM=offscreen \
108+
ctest --test-dir build --output-on-failure
109+
110+
- name: Build and test PythonQt (Windows)
111+
if: ${{ matrix.os == 'windows' }}
112+
shell: cmd
113+
run: |
114+
cmake -G Ninja -S . -B build ^
115+
-DCMAKE_BUILD_TYPE=Release ^
116+
"-DCMAKE_PREFIX_PATH=%QT_ROOT_DIR%" ^
117+
-DPythonQt_QT_VERSION=%QT_VERSION_MAJOR% ^
118+
"-DPythonQt_GENERATED_PATH=%CD%\generated_cpp" ^
119+
-DBUILD_TESTING=ON
120+
cmake --build build
121+
set PYTHONDEVMODE=1
122+
set PYTHONASYNCIODEBUG=1
123+
set PYTHONWARNINGS=error
124+
set QT_QPA_PLATFORM=offscreen
125+
ctest --test-dir build --output-on-failure

0 commit comments

Comments
 (0)