Skip to content

Commit 0ad0dce

Browse files
committed
add python tests
1 parent 534e88f commit 0ad0dce

6 files changed

Lines changed: 381 additions & 22 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: 'Setup Python Environment'
2+
description: 'Installs Python, PySide6/Shiboken dependencies, and configurs Clang'
3+
4+
inputs:
5+
python-version:
6+
description: 'The version of Python to install'
7+
required: false
8+
default: '3.12'
9+
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Set up Python
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: ${{ inputs.python-version }}
17+
18+
- name: Install Dependencies
19+
shell: bash
20+
run: |
21+
pip install --upgrade pip
22+
pip install pytest pytest-qt PySide6 shiboken6
23+
24+
- name: Install Dependencies (Linux)
25+
if: runner.os == 'Linux'
26+
shell: bash
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y llvm libclang-dev
30+
31+
CLANG_LIB_FILE=$(find /usr/lib/llvm-* -name "libclang.so" 2>/dev/null | head -n 1)
32+
CLANG_LIB_DIR=$(dirname "$CLANG_LIB_FILE")
33+
CLANG_ROOT_DIR=$(dirname "$CLANG_LIB_DIR")
34+
QT_LIB_DIR=$(qtpaths --query QT_INSTALL_LIBS)
35+
36+
echo "Detected Clang Root: $CLANG_ROOT_DIR"
37+
echo "CLANG_INSTALL_DIR=$CLANG_ROOT_DIR" >> $GITHUB_ENV
38+
echo "LD_LIBRARY_PATH=$CLANG_LIB_DIR:$QT_LIB_DIR:${LD_LIBRARY_PATH}" >> $GITHUB_ENV
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: 'Setup Qt Environment'
2+
description: 'Installs Xvfb and Qt'
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Install Xvfb (Linux)
8+
if: runner.os == 'Linux'
9+
shell: bash
10+
run: sudo apt install -y xvfb
11+
12+
- name: Install Qt
13+
uses: jurplel/install-qt-action@v4
14+
with:
15+
version: 6.10.1
16+
target: desktop
17+
modules: 'qtpositioning'
18+
cached: true

.github/workflows/tests.yaml

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ on:
66
workflow_dispatch:
77

88
jobs:
9-
Test:
9+
Core:
1010
name: ${{ matrix.os }} - ${{ matrix.config_name }}
11+
runs-on: ${{ matrix.os }}
1112
strategy:
1213
fail-fast: false
1314
matrix:
@@ -21,25 +22,13 @@ jobs:
2122
- config_name: "QML"
2223
cmake_flags: "-DSIMPLE_MAP_VIEW_BUILD_QML=ON -DSIMPLE_MAP_VIEW_BUILD_TESTS=ON"
2324
build_type: "Debug"
24-
25-
runs-on: ${{ matrix.os }}
26-
25+
2726
steps:
2827
- name: Checkout
29-
uses: actions/checkout@v4
28+
uses: actions/checkout@v6
3029

31-
- name: Install Xvfb (Linux)
32-
if: runner.os == 'Linux'
33-
run: |
34-
sudo apt install -y xvfb
35-
36-
- name: Install Qt
37-
uses: jurplel/install-qt-action@v4
38-
with:
39-
version: 6.10.1
40-
target: desktop
41-
modules: 'qtpositioning'
42-
cached: true
30+
- name: Setup Qt Environment
31+
uses: ./.github/actions/setup-qt-env
4332

4433
- name: Configure CMake
4534
shell: bash
@@ -63,4 +52,40 @@ jobs:
6352
if: runner.os != 'Linux'
6453
shell: bash
6554
working-directory: build
66-
run: ctest -C ${{ matrix.build_type }} --output-on-failure
55+
run: ctest -C ${{ matrix.build_type }} --output-on-failure
56+
57+
Python:
58+
name: Python ${{ matrix.python-versions }} ${{ matrix.os }}
59+
needs: Core
60+
runs-on: ${{ matrix.os }}
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
os: [ubuntu-latest, windows-latest]
65+
python-versions: ['3.10', '3.11', '3.12', '3.13']
66+
67+
steps:
68+
- name: Checkout
69+
uses: actions/checkout@v6
70+
71+
- name: Setup Qt Environment
72+
uses: ./.github/actions/setup-qt-env
73+
74+
- name: Setup Python Environment
75+
uses: ./.github/actions/setup-python-env
76+
with:
77+
python-version: ${{ matrix.python-versions }}
78+
79+
- name: Install Bindings
80+
shell: bash
81+
env:
82+
PYTHONIOENCODING: utf-8
83+
run: pip install .
84+
85+
- name: Run (Linux)
86+
if: runner.os == 'Linux'
87+
run: xvfb-run pytest
88+
89+
- name: Run (Windows)
90+
if: runner.os != 'Linux'
91+
run: pytest

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.vscode
2+
build
3+
tests/python/__pycache__

0 commit comments

Comments
 (0)