slint/.github/workflows/ci.yaml
Nigel Breslaw 7a22e21534 Update
2025-11-18 15:01:41 +02:00

648 lines
28 KiB
YAML

# Copyright © SixtyFPS GmbH <info@slint.dev>
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
name: CI
on:
workflow_dispatch:
workflow_call:
secrets:
CLOUDFLARE_API_TOKEN:
required: true
CLOUDFLARE_ACCOUNT_ID:
required: true
ANDROID_KEYSTORE_PASSWORD:
required: true
ANDROID_KEYSTORE_BASE64:
required: true
READ_WRITE_PRIVATE_KEY:
required: true
env:
MACOSX_DEPLOYMENT_TARGET: "11.0"
SLINT_COMPILER_DENY_WARNINGS: 1
jobs:
files-changed:
runs-on: ubuntu-latest
timeout-minutes: 1
permissions:
pull-requests: read
outputs:
slint: ${{ steps.filter.outputs.slint }}
figma_inspector : ${{ steps.filter.outputs.figma_inspector }}
material_components : ${{ steps.filter.outputs.material_components }}
internal : ${{ steps.filter.outputs.internal }}
api_cpp : ${{ steps.filter.outputs.api_cpp }}
api_python : ${{ steps.filter.outputs.api_python }}
api_node : ${{ steps.filter.outputs.api_node }}
api_rs : ${{ steps.filter.outputs.api_rs }}
tests : ${{ steps.filter.outputs.tests }}
examples : ${{ steps.filter.outputs.examples }}
vsce : ${{ steps.filter.outputs.vsce }}
slintpad : ${{ steps.filter.outputs.slintpad }}
updater_test : ${{ steps.filter.outputs.updater_test }}
servo_example : ${{ steps.filter.outputs.servo_example }}
steps:
- uses: actions/checkout@v5
- uses: dorny/paths-filter@v3
id: filter
with:
token: ${{ github.token }}
filters: .github/ci_path_filters.yaml
build_and_test:
needs: files-changed
if: needs.files-changed.outputs.slint == 'true'
strategy:
matrix:
include:
- os: ubuntu-22.04
name: "Ubuntu 22.04 1.88"
rust_version: "1.88"
save_if: ${{ github.ref == 'refs/heads/master' }}
- os: windows-2022
name: "Windows 2022 beta"
rust_version: "beta"
save_if: ${{ github.ref == 'refs/heads/master' }}
extra_args: "--exclude ffmpeg --exclude gstreamer-player"
- os: macos-14
name: "MacOS 14 stable"
rust_version: "stable"
save_if: ${{ github.ref == 'refs/heads/master' }}
extra_args: "--exclude ffmpeg --exclude gstreamer-player"
uses: ./.github/workflows/build_and_test_reusable.yaml
with:
os: ${{ matrix.os }}
name: ${{ matrix.name }}
rust_version: ${{ matrix.rust_version }}
extra_args: ${{ matrix.extra_args }} --exclude material-gallery
save_if: ${{ matrix.save_if }}
timeout_minutes: 120
# For changes to Slint internals, do a quick test on Linux for Node.js only.
node_test_linux:
needs: files-changed
if: needs.files-changed.outputs.internal == 'true' || needs.files-changed.outputs.api_node == 'true' || needs.files-changed.outputs.tests == 'true'
uses: ./.github/workflows/node_test_reusable.yaml
with:
name: "Node.js Linux"
os: "ubuntu-22.04"
node_test_macos:
needs: files-changed
if: needs.files-changed.outputs.api_node == 'true' || needs.files-changed.outputs.tests == 'true'
uses: ./.github/workflows/node_test_reusable.yaml
with:
name: "Node.js macOS"
os: "macos-14"
node_test_windows:
needs: files-changed
if: needs.files-changed.outputs.api_node == 'true' || needs.files-changed.outputs.tests == 'true'
uses: ./.github/workflows/node_test_reusable.yaml
with:
name: "Node.js Windows"
os: "windows-2022"
# 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'
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
if: needs.files-changed.outputs.internal == 'true' || needs.files-changed.outputs.api_cpp == '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_INCREMENTAL: false
RUST_BACKTRACE: 1
CARGO_PROFILE_DEV_DEBUG: 0
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
with:
force-gcc-10: true
- name: Install Qt
if: runner.os == 'Linux'
uses: jurplel/install-qt-action@v4
with:
version: "5.15.2"
cache: true
- name: Set default style
if: runner.os != 'Windows'
run: echo "SLINT_STYLE=native" >> $GITHUB_ENV
- name: Set default style
if: runner.os == 'Windows'
run: |
echo "SLINT_STYLE=fluent" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "SLINT_NO_QT=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- uses: ./.github/actions/setup-rust
- name: Run tests
run: cargo test --verbose -p test-driver-cpp --features slint-cpp/backend-qt
cpp_cmake:
needs: files-changed
if: needs.files-changed.outputs.internal == 'true' || needs.files-changed.outputs.api_cpp == 'true' || needs.files-changed.outputs.examples == 'true'
env:
DYLD_FRAMEWORK_PATH: /Users/runner/work/slint/Qt/6.5.1/clang_64/lib
QT_QPA_PLATFORM: offscreen
CARGO_INCREMENTAL: false
RUST_BACKTRACE: 1
CARGO_PROFILE_DEV_DEBUG: 0
SLINT_EMIT_DEBUG_INFO: 1
strategy:
matrix:
include:
- os: macos-14
rust_version: "1.88"
- os: windows-2022
rust_version: "nightly"
- os: ubuntu-22.04
rust_version: "stable"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/install-linux-dependencies
with:
force-gcc-10: true
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: 6.5.1
cache: true
- uses: ./.github/actions/setup-rust
- uses: ilammy/msvc-dev-cmd@v1
- name: Select MSVC (windows)
if: matrix.os == 'windows-2022'
run: |
echo "CC=cl.exe" >> $GITHUB_ENV
echo "CXX=cl.exe" >> $GITHUB_ENV
- name: Enable test coverage for resource embedding in C++ when building examples
if: matrix.os == 'ubuntu-22.04'
run: |
echo "SLINT_EMBED_RESOURCES=true" >> $GITHUB_ENV
- name: C++ Build
uses: lukka/run-cmake@v3.4
with:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: CMakeLists.txt
cmakeAppendedArgs: "-DSLINT_BUILD_TESTING=ON -DSLINT_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Debug -DSLINT_FEATURE_RENDERER_SKIA=ON -DSLINT_FEATURE_BACKEND_QT=ON -DSLINT_FEATURE_EXPERIMENTAL=ON -DSLINT_FEATURE_TESTING=ON"
buildDirectory: ${{ runner.workspace }}/cppbuild
buildWithCMakeArgs: "--config Debug"
- name: ctest
working-directory: ${{ runner.workspace }}/cppbuild
run: ctest --verbose -C Debug
- name: cpack
working-directory: ${{ runner.workspace }}/cppbuild
run: cmake --build . --config Debug --target package
- name: "Create C++ packages artifact"
uses: actions/upload-artifact@v5
with:
name: cpp_bin-${{ matrix.os }}
path: ${{ runner.workspace }}/cppbuild/Slint-cpp-*
cpp_package_test:
needs: [cpp_cmake]
runs-on: ubuntu-22.04
env:
QT_QPA_PLATFORM: offscreen
CARGO_INCREMENTAL: false
CARGO_PROFILE_DEV_DEBUG: 0
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/install-linux-dependencies
with:
force-gcc-10: true
- name: Install Qt (Ubuntu)
uses: jurplel/install-qt-action@v4
with:
version: 6.5.1
cache: true
- uses: actions/download-artifact@v6
with:
name: cpp_bin-ubuntu-22.04
path: cpp-package
- name: unpack package
run: |
mkdir package
tar xvf cpp-package/Slint-cpp-*.tar.gz -C package --strip-components=1
echo "CMAKE_PREFIX_PATH=`pwd`/package" >> $GITHUB_ENV
# Build the examples with a config different than the package (which is debug)
- name: Build examples
uses: lukka/run-cmake@v3.4
with:
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
cmakeListsTxtPath: examples/CMakeLists.txt
cmakeAppendedArgs: "-DCMAKE_BUILD_TYPE=Release -DSLINT_FEATURE_INTERPRETER=1 -DSLINT_FEATURE_BACKEND_QT=1"
buildDirectory: ${{ runner.workspace }}/examples/build
buildWithCMakeArgs: "--config Release"
vsce_build_test:
needs: files-changed
if: needs.files-changed.outputs.vsce == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v5
- uses: pnpm/action-setup@v4.2.0
with:
version: 10.18.2
- uses: Swatinem/rust-cache@v2
with:
key: "vsce_1" # increment this to bust the cache if needed
- uses: ./.github/actions/install-linux-dependencies
- uses: actions/setup-node@v6
with:
node-version: 22
package-manager-cache: false
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Fake slint-lsp build
run: |
mkdir -p target/debug
echo 1 > target/debug/slint-lsp
- name: Run pnpm install
working-directory: editors/vscode
run: pnpm install --frozen-lockfile
- name: vscode prebuild
working-directory: editors/vscode
run: pnpm vscode:prepublish
- name: Build VS Code extension
working-directory: editors/vscode
run: pnpm local-package
- name: Typescript syntax check # has to run after the build as it depends on the wasm
working-directory: editors/vscode
run: pnpm type-check
- name: Check tmGrammar
working-directory: editors/vscode
run: pnpm test_grammar
# test to compile the mcu backend for the arm target (no_std)
mcu:
needs: files-changed
if: needs.files-changed.outputs.internal == 'true' || needs.files-changed.outputs.examples == 'true' || needs.files-changed.outputs.api_rs == 'true'
env:
SLINT_FONT_SIZES: 8,11,10,12,13,14,15,16,18,20,22,24,32
RUSTFLAGS: --cfg slint_int_coord -D warnings
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_PROFILE_RELEASE_OPT_LEVEL: s
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- feature: pico-st7789
target: thumbv6m-none-eabi
- feature: pico2-st7789
target: thumbv8m.main-none-eabihf
- feature: stm32h735g
target: thumbv7em-none-eabihf
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-rust
with:
target: ${{matrix.target}}
- name: Check
run: cargo check --target=${{matrix.target}} -p printerdemo_mcu --no-default-features --features=mcu-board-support/${{matrix.feature}} --release
# test to compile the mcu backend for the arm target (no_std) using embassy
mcu-embassy:
needs: files-changed
if: needs.files-changed.outputs.internal == 'true' || needs.files-changed.outputs.examples == 'true' || needs.files-changed.outputs.api_rs == 'true'
env:
SLINT_FONT_SIZES: 8,11,10,12,13,14,15,16,18,20,22,24,32
RUSTFLAGS: --cfg slint_int_coord -D warnings
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_PROFILE_RELEASE_OPT_LEVEL: s
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-rust
with:
target: thumbv8m.main-none-eabihf
- name: Check
working-directory: examples/mcu-embassy
run: cargo check --bin ui_mcu --target=thumbv8m.main-none-eabihf --no-default-features --features="mcu-embassy/mcu" --release
# mcu_esp:
# env:
# RUSTFLAGS: -D warnings
# runs-on: ubuntu-22.04
# steps:
# - uses: actions/checkout@v5
# - uses: dtolnay/rust-toolchain@stable
# - uses: esp-rs/xtensa-toolchain@v1.6
# with:
# default: true
# buildtargets: esp32
# ldproxy: false
# # version pinned until new version of esp-hal with https://github.com/esp-rs/esp-hal/pull/2615/
# version: 1.82.0
# - uses: Swatinem/rust-cache@v2
# - name: S3Box
# run: cargo +esp check -p printerdemo_mcu --target xtensa-esp32s3-none-elf --no-default-features --features=mcu-board-support/esp32-s3-box --config examples/mcu-board-support/esp32_s3_box/cargo-config.toml --release
ffi_32bit_build:
needs: files-changed
if: needs.files-changed.outputs.internal == 'true' || needs.files-changed.outputs.api_cpp == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-rust
with:
target: armv7-unknown-linux-gnueabihf
- uses: baptiste0928/cargo-install@v3
with:
crate: cross
- name: Check
run: cross check --target=armv7-unknown-linux-gnueabihf -p slint-cpp --no-default-features --features=testing,interpreter,std
docs:
needs: files-changed
if: needs.files-changed.outputs.slint == 'true'
uses: ./.github/workflows/build_docs.yaml
secrets:
READ_WRITE_PRIVATE_KEY: ${{ secrets.READ_WRITE_PRIVATE_KEY }}
with:
release: false
app-id: ${{ vars.READ_WRITE_APP_ID }}
slintpad:
needs: files-changed
if: needs.files-changed.outputs.slintpad == 'true'
uses: ./.github/workflows/wasm_editor_and_interpreter.yaml
wasm_demo:
needs: files-changed
if: needs.files-changed.outputs.internal == 'true' || needs.files-changed.outputs.examples == 'true' || needs.files-changed.outputs.api_rs == 'true'
uses: ./.github/workflows/wasm_demos.yaml
with:
build_artifacts: false
tree-sitter:
needs: files-changed
if: needs.files-changed.outputs.slint == 'true'
uses: ./.github/workflows/tree_sitter.yaml
with:
latest: false
tag: "v0.25.3"
# Checkout a old version of the tests and example, then run the slint-updater on them
# and check that it worked with the interpreter test.
updater_test:
needs: files-changed
if: needs.files-changed.outputs.updater_test == 'true'
env:
SLINT_NO_QT: 1
CARGO_INCREMENTAL: false
RUST_BACKTRACE: 1
CARGO_PROFILE_DEV_DEBUG: 0
strategy:
matrix:
from_version: ["0.3.0"]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: ./.github/actions/install-linux-dependencies
- uses: ./.github/actions/setup-rust
- name: Checkout old version
run: |
git checkout v${{ matrix.from_version }} --no-overlay -- examples
git checkout v${{ matrix.from_version }} --no-overlay -- tests/cases
git checkout v${{ matrix.from_version }} --no-overlay -- tests/helper_components
# Remove examples and demos from the workspace because they may no longer exist or their Cargo.toml might prevent the build of the updater
sed -i "/examples/d" Cargo.toml
sed -i "/demos/d" Cargo.toml
- name: "Commit old checkout"
run: |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "${GITHUB_ACTOR}"
git commit -a -m "REVERT TESTS TO v${{ matrix.from_version }}"
- name: run the updater
run: |
cargo run -p slint-updater -- -i examples/*/*.slint
cargo run -p slint-updater -- -i examples/*/*/*.slint
cargo run -p slint-updater -- -i tests/cases/*.slint
cargo run -p slint-updater -- -i tests/cases/*/*.slint
- name: Show the diff
run: git diff
- name: test
# Skip a few tests that rely on private renamed properties.
# Skip the tests which makes two way binding to output property (these are warning in previous version)
# Skip the test that use impure functions in property bindings (this is also warning in previous version)
# Skip the example that did not exist or that are broken
# Skip the path layout related tests as the element has been removed
# Skip the booker as it use api from the LineEdit that wasn"t meant to be used
run: |
cargo test -p test-driver-interpreter -- \
--skip test_interpreter_text_cursor_move \
--skip test_interpreter_text_cursor_move_grapheme \
--skip test_interpreter_text_cut \
--skip test_interpreter_text_select_all \
--skip test_interpreter_text_surrogate_cursor \
--skip test_interpreter_text_text_change \
--skip test_interpreter_crashes_layout_deleted_item \
--skip test_interpreter_focus_focus_change_subcompo \
--skip test_interpreter_focus_focus_change_through_signal \
--skip test_interpreter_globals_alias_to_global \
--skip test_interpreter_text_default_color \
--skip test_interpreter_crashes_issue1271_set_in_if \
--skip test_interpreter_models_assign_equal_model \
--skip example_carousel \
--skip example_fancy_demo \
--skip example_dial \
--skip example_fancy_switches \
--skip example_sprite_sheet \
--skip test_interpreter_elements_path_fit \
--skip test_interpreter_layout_path \
--skip test_interpreter_7guis_booker \
# Test that the formater don't introduce slint compilation error
fmt_test:
needs: files-changed
if: needs.files-changed.outputs.slintpad == 'true' || needs.files-changed.outputs.tests == 'true'
env:
SLINT_NO_QT: 1
CARGO_INCREMENTAL: false
RUST_BACKTRACE: 1
CARGO_PROFILE_DEV_DEBUG: 0
RUSTFLAGS: -D warnings
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/install-linux-dependencies
- uses: ./.github/actions/setup-rust
- name: run the formatter
run: |
cargo run -p slint-lsp --no-default-features -- format -i tests/cases/**/*.slint
cargo run -p slint-lsp --no-default-features -- format -i examples/**/*.slint
- name: Show the diff
run: git diff
- name: Run the intepreter test to make sure that the test are passing after format
run: cargo test -p test-driver-interpreter
- name: "Commit changes"
run: |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "${GITHUB_ACTOR}"
git commit -a -m "Run slint-lsp format"
- name: Do another pass to check that it is idempotent
run: |
cargo run -p slint-lsp --no-default-features -- format -i tests/cases/**/*.slint
cargo run -p slint-lsp --no-default-features -- format -i examples/**/*.slint
git diff --exit-code
esp-idf-quick:
needs: files-changed
if: needs.files-changed.outputs.internal == 'true' || needs.files-changed.outputs.api_cpp == 'true' || needs.files-changed.outputs.examples == 'true'
runs-on: ubuntu-22.04
container: espressif/idf:release-v5.2
steps:
- name: Fix up pydantic regression (https://github.com/espressif/idf-component-manager/issues/97#issuecomment-3380777944)
run: |
. ${IDF_PATH}/export.sh
cd $IDF_PYTHON_ENV_PATH
bin/pip install pydantic==2.11.10
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
- uses: esp-rs/xtensa-toolchain@v1.6
with:
default: true
buildtargets: esp32
ldproxy: false
- uses: Swatinem/rust-cache@v2
- name: Build and Test Printer demo
shell: bash
working-directory: demos/printerdemo_mcu/esp-idf
run: |
. ${IDF_PATH}/export.sh
idf.py build
android:
needs: files-changed
if: needs.files-changed.outputs.internal == 'true' || needs.files-changed.outputs.api_rs == 'true' || needs.files-changed.outputs.examples == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install Android API level 30
run: ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "platforms;android-30"
- name: Cache cargo-apk
id: cargo-apk-cache
uses: actions/cache@v4
with:
path: ~/.cargo/bin/cargo-apk
key: cargo-apk-cache
# Only build cargo-apk if not cached
- uses: dtolnay/rust-toolchain@stable
if: steps.cargo-apk-cache.outputs.cache-hit != 'true'
- name: Install cargo-apk
if: steps.cargo-apk-cache.outputs.cache-hit != 'true'
run: cargo install cargo-apk
- uses: ./.github/actions/setup-rust
with:
target: aarch64-linux-android
- name: Build todo demo
run: cargo apk build -p todo --target aarch64-linux-android --lib
- name: Build energy-monitor example
run: cargo apk build -p energy-monitor --target aarch64-linux-android --lib
- name: Build printerdemo example
run: cargo apk build -p printerdemo --target aarch64-linux-android --lib
- name: Build usecases demo
run: cargo apk build -p usecases --target aarch64-linux-android --lib
miri:
needs: files-changed
if: needs.files-changed.outputs.internal == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-rust
with:
toolchain: nightly
key: miri
components: miri
- name: Run Miri
run: cargo miri test -p vtable -p const-field-offset -p i-slint-common
test-figma-inspector:
needs: files-changed
if: needs.files-changed.outputs.figma_inspector == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v6
with:
node-version: 22
package-manager-cache: false
id: node-install
- uses: pnpm/action-setup@v4.2.0
with:
version: 10.18.2
- name: Run pnpm install
working-directory: tools/figma-inspector
run: pnpm install --frozen-lockfile
- name: Run build
working-directory: tools/figma-inspector
run: pnpm build
- name: Run tests
working-directory: tools/figma-inspector
run: pnpm test
- name: Type Check
working-directory: tools/figma-inspector
run: pnpm type-check
- name: Build zip
working-directory: tools/figma-inspector
run: pnpm zip
- name: Archive zip
uses: actions/upload-artifact@v5
with:
name: figma-plugin
path: tools/figma-inspector/zip
material-components:
needs: files-changed
if: needs.files-changed.outputs.material_components == 'true'
permissions:
contents: read
deployments: write
uses: ./.github/workflows/material.yaml
secrets:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
servo_example:
needs: files-changed
if: needs.files-changed.outputs.servo_example == 'true'
uses: ./.github/workflows/servo_example.yaml