From 9795a8ce4dc99d98019b4f3fa58484e6f1d8e1ca Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 6 Nov 2025 18:15:47 +0100 Subject: [PATCH] CI: Attempt to run python tests only on Linux when doing Slint internal changes --- .github/ci_path_filters.yaml | 4 ++ .github/workflows/ci.yaml | 71 ++++++--------------- .github/workflows/nightly_tests.yaml | 9 +++ .github/workflows/python_test_reusable.yaml | 64 +++++++++++++++++++ 4 files changed, 98 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/python_test_reusable.yaml diff --git a/.github/ci_path_filters.yaml b/.github/ci_path_filters.yaml index 6db4b2ac6e..ca01600f4b 100644 --- a/.github/ci_path_filters.yaml +++ b/.github/ci_path_filters.yaml @@ -52,15 +52,19 @@ internal: &internal api_cpp: - 'api/cpp/**' - 'tools/compiler/**' + - *ci_config api_python: - 'api/python/**' + - *ci_config api_node: - 'api/node/**' + - *ci_config api_rs: - 'api/rs/**' + - *ci_config tests: - 'tests/**' diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a542d17698..d4f9efc7b5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -128,57 +128,28 @@ jobs: working-directory: examples/imagefilter/node run: pnpm check - python_test: + # For changes to Slint internals, do a quick test on Linux for Python only. + python_test_linux: needs: files-changed - if: needs.files-changed.outputs.internal == 'true' || needs.files-changed.outputs.api_python == 'true' || needs.files-changed.outputs.tests == 'true' - env: - DYLD_FRAMEWORK_PATH: /Users/runner/work/slint/Qt/5.15.2/clang_64/lib - QT_QPA_PLATFORM: offscreen - RUSTFLAGS: -D warnings - CARGO_PROFILE_DEV_DEBUG: 0 - CARGO_INCREMENTAL: false - RUST_BACKTRACE: full - SLINT_BACKEND: winit - strategy: - matrix: - os: [ubuntu-22.04, macos-14, windows-2022] - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v5 - - uses: ./.github/actions/install-linux-dependencies - - name: Install Qt - if: runner.os == 'Linux' - uses: jurplel/install-qt-action@v4 - with: - version: "5.15.2" - setup-python: false - cache: true - - name: Setup headless display - if: runner.os != 'macOS' - uses: pyvista/setup-headless-display-action@v4 - - uses: ./.github/actions/setup-rust - with: - key: x-napi-v2-${{ steps.node-install.outputs.node-version }} # the cache key consists of a manually bumpable version and the node version, as the cached rustc artifacts contain linking information where to find node.lib, which is in a versioned directory. - - uses: actions/setup-python@v6 - with: - python-version: "3.12" - - name: Install uv - uses: astral-sh/setup-uv@v7 - - uses: fjwillemsen/setup-nox2@v3.0.0 - - name: Run python tests - working-directory: api/python/slint - run: nox --default-venv-backend uv - - name: Run mypy - working-directory: api/python/slint - run: uv run mypy -p tests -p slint - - name: Run ruff linter - working-directory: api/python/slint - run: uv tool run ruff check - - name: Run ruff linter - working-directory: api/python/briefcase - run: uv tool run ruff check + if: needs.files-changed.outputs.internal == 'true' || needs.files-changed.outputs.api_python == 'true' + uses: ./.github/workflows/python_test_reusable.yaml + with: + name: "Python Linux" + os: "ubuntu-22.04" + python_test_macos: + needs: files-changed + if: needs.files-changed.outputs.api_python == 'true' + uses: ./.github/workflows/python_test_reusable.yaml + with: + name: "Python macOS" + os: "macos-14" + python_test_windows: + needs: files-changed + if: needs.files-changed.outputs.api_python == 'true' + uses: ./.github/workflows/python_test_reusable.yaml + with: + name: "Python Windows" + os: "windows-2022" cpp_test_driver: needs: files-changed diff --git a/.github/workflows/nightly_tests.yaml b/.github/workflows/nightly_tests.yaml index 060b37c3b4..1ef87d30a4 100644 --- a/.github/workflows/nightly_tests.yaml +++ b/.github/workflows/nightly_tests.yaml @@ -302,3 +302,12 @@ jobs: - uses: ./.github/actions/install-skia-dependencies - name: Build wgpu_texture demo run: cargo apk build -p wgpu_texture --target aarch64-linux-android --lib + + python: + strategy: + matrix: + os: [ubuntu-22.04, macos-14, windows-2022] + uses: ./.github/workflows/python_test_reusable.yaml + with: + name: "Python ${{ matrix.os }}" + os: ${{ matrix.os }} diff --git a/.github/workflows/python_test_reusable.yaml b/.github/workflows/python_test_reusable.yaml new file mode 100644 index 0000000000..23674e60a2 --- /dev/null +++ b/.github/workflows/python_test_reusable.yaml @@ -0,0 +1,64 @@ +# Copyright © SixtyFPS GmbH +# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 + +name: Python Test (Reusable) + +on: + workflow_call: + inputs: + name: + description: 'Name of the job' + required: true + type: string + os: + description: 'Operating system to run on' + required: true + type: string + +env: + DYLD_FRAMEWORK_PATH: /Users/runner/work/slint/Qt/5.15.2/clang_64/lib + QT_QPA_PLATFORM: offscreen + RUSTFLAGS: -D warnings + CARGO_PROFILE_DEV_DEBUG: 0 + CARGO_INCREMENTAL: false + RUST_BACKTRACE: full + SLINT_BACKEND: winit + +jobs: + python_test: + name: ${{ inputs.name }} + runs-on: ${{ inputs.os }} + steps: + - uses: actions/checkout@v5 + - uses: ./.github/actions/install-linux-dependencies + - name: Install Qt + if: runner.os == 'Linux' + uses: jurplel/install-qt-action@v4 + with: + version: "5.15.2" + setup-python: false + cache: true + - name: Setup headless display + if: runner.os != 'macOS' + uses: pyvista/setup-headless-display-action@v4 + - uses: ./.github/actions/setup-rust + with: + key: x-napi-v2-${{ steps.node-install.outputs.node-version }} # the cache key consists of a manually bumpable version and the node version, as the cached rustc artifacts contain linking information where to find node.lib, which is in a versioned directory. + - uses: actions/setup-python@v6 + with: + python-version: "3.12" + - name: Install uv + uses: astral-sh/setup-uv@v7 + - uses: fjwillemsen/setup-nox2@v3.0.0 + - name: Run python tests + working-directory: api/python/slint + run: nox --default-venv-backend uv + - name: Run mypy + working-directory: api/python/slint + run: uv run mypy -p tests -p slint + - name: Run ruff linter + working-directory: api/python/slint + run: uv tool run ruff check + - name: Run ruff linter + working-directory: api/python/briefcase + run: uv tool run ruff check