|
| 1 | +# Copyright © SixtyFPS GmbH <[email protected]> |
| 2 | +# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 |
| 3 | + |
| 4 | +name: Build and Test (Reusable) |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_call: |
| 8 | + inputs: |
| 9 | + name: |
| 10 | + description: 'Name of the job' |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + os: |
| 14 | + description: 'Operating system to run on' |
| 15 | + required: true |
| 16 | + type: string |
| 17 | + rust_version: |
| 18 | + description: 'Rust version to use' |
| 19 | + required: true |
| 20 | + type: string |
| 21 | + extra_args: |
| 22 | + description: 'Extra arguments to pass to cargo test' |
| 23 | + required: false |
| 24 | + type: string |
| 25 | + default: "" |
| 26 | + cache: |
| 27 | + description: 'Use rust-cache' |
| 28 | + required: false |
| 29 | + type: boolean |
| 30 | + default: true |
| 31 | + save_if: |
| 32 | + description: 'Condition to save the cache' |
| 33 | + required: false |
| 34 | + type: boolean |
| 35 | + default: true |
| 36 | + timeout_minutes: |
| 37 | + description: 'Timeout in minutes' |
| 38 | + required: false |
| 39 | + type: number |
| 40 | + default: 120 |
| 41 | + |
| 42 | +jobs: |
| 43 | + build_and_test: |
| 44 | + name: ${{ inputs.name }} |
| 45 | + timeout-minutes: ${{ inputs.timeout_minutes }} |
| 46 | + env: |
| 47 | + MACOSX_DEPLOYMENT_TARGET: "11.0" |
| 48 | + DYLD_FRAMEWORK_PATH: /Users/runner/work/slint/Qt/6.2.2/macos/lib |
| 49 | + QT_QPA_PLATFORM: offscreen |
| 50 | + RUSTFLAGS: -D warnings |
| 51 | + CARGO_PROFILE_DEV_DEBUG: 0 |
| 52 | + CARGO_INCREMENTAL: false |
| 53 | + RUST_BACKTRACE: 1 |
| 54 | + SLINT_EMIT_DEBUG_INFO: 1 |
| 55 | + |
| 56 | + runs-on: ${{ inputs.os }} |
| 57 | + |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v5 |
| 60 | + - uses: ./.github/actions/install-linux-dependencies |
| 61 | + - uses: ./.github/actions/install-skia-dependencies |
| 62 | + - uses: ilammy/msvc-dev-cmd@v1 |
| 63 | + - uses: actions/setup-python@v6 |
| 64 | + with: |
| 65 | + python-version: '3.10' |
| 66 | + - name: Install Qt |
| 67 | + if: runner.os != 'Windows' |
| 68 | + uses: jurplel/install-qt-action@v4 |
| 69 | + with: |
| 70 | + version: "6.2.2" |
| 71 | + setup-python: false |
| 72 | + cache: true |
| 73 | + - name: Install ffmpeg and alsa (Linux) |
| 74 | + if: runner.os == 'Linux' |
| 75 | + run: sudo apt-get install clang libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev libasound2-dev pkg-config |
| 76 | + - name: Install gstreamer and libunwind (Linux) |
| 77 | + if: runner.os == 'Linux' |
| 78 | + run: sudo apt-get install libunwind-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good |
| 79 | + - name: Setup headless display |
| 80 | + if: runner.os != 'macOS' |
| 81 | + uses: pyvista/setup-headless-display-action@v4 |
| 82 | + - uses: ./.github/actions/setup-rust |
| 83 | + with: |
| 84 | + toolchain: ${{ inputs.rust_version }} |
| 85 | + key: x-v3 |
| 86 | + save_if: ${{ inputs.save_if }} |
| 87 | + cache: ${{ inputs.cache }} |
| 88 | + - name: Run tests |
| 89 | + run: cargo test --verbose --all-features --workspace --timings ${{ inputs.extra_args }} --exclude slint-node --exclude pyslint --exclude test-driver-node --exclude slint-node --exclude test-driver-nodejs --exclude test-driver-cpp --exclude mcu-board-support --exclude mcu-embassy --exclude printerdemo_mcu --exclude uefi-demo --exclude slint-cpp --exclude slint-python -- --skip=_qt::t |
| 90 | + env: |
| 91 | + SLINT_CREATE_SCREENSHOTS: 1 |
| 92 | + shell: bash |
| 93 | + - name: Run tests (qt) |
| 94 | + run: cargo test --verbose --all-features --workspace ${{ inputs.extra_args }} --exclude slint-node --exclude pyslint --exclude test-driver-node --exclude slint-node --exclude test-driver-nodejs --exclude test-driver-cpp --exclude mcu-board-support --exclude mcu-embassy --exclude printerdemo_mcu --exclude uefi-demo --exclude slint-cpp --exclude slint-python --bin test-driver-rust -- _qt --test-threads=1 |
| 95 | + shell: bash |
| 96 | + - name: live-preview for rust test |
| 97 | + env: |
| 98 | + SLINT_LIVE_PREVIEW: 1 |
| 99 | + run: cargo test --verbose --features=build-time,slint/live-preview -p test-driver-rust -- --skip=_qt::t |
| 100 | + shell: bash |
| 101 | + - name: Upload build timing report |
| 102 | + if: always() |
| 103 | + uses: actions/upload-artifact@v5 |
| 104 | + with: |
| 105 | + name: cargo-timings-${{ inputs.os }}-${{ inputs.rust_version }} |
| 106 | + path: target/cargo-timings/cargo-timing.html |
| 107 | + if-no-files-found: ignore |
| 108 | + - name: Archive screenshots after failed tests |
| 109 | + if: ${{ failure() }} |
| 110 | + uses: actions/upload-artifact@v5 |
| 111 | + with: |
| 112 | + name: screenshots-${{ inputs.os }} |
| 113 | + path: | |
| 114 | + tests/screenshots/references |
| 115 | +
|
0 commit comments