| name: Linux | |
| # Builds, lints and tests the Linux backend (GTK 4) and the tooling that runs | |
| # it (`nsh run --target linux`, `nsh package --target linux`). | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "crates/nsh-bundler/**" | |
| - "crates/nsh-cli/**" | |
| - "crates/nsh-core/**" | |
| - "crates/nsh-dev/**" | |
| - "crates/nsh-engine/**" | |
| - "crates/nsh-js/**" | |
| - "crates/nsh-linux-app/**" | |
| - "crates/nsh-linux-host/**" | |
| - "crates/nsh-macros/**" | |
| - "crates/nsh-package/**" | |
| - "crates/nsh-platform-linux/**" | |
| - "crates/nsh-testing/**" | |
| - "crates/nsh-base/**" | |
| - "crates/xtask/**" | |
| - "examples/counter/**" | |
| - "examples/gallery/**" | |
| - "Cargo.toml" | |
| - "Cargo.lock" | |
| - ".cargo/**" | |
| - "rust-toolchain.toml" | |
| - ".github/workflows/linux.yml" | |
| pull_request: | |
| paths: | |
| - "crates/nsh-bundler/**" | |
| - "crates/nsh-cli/**" | |
| - "crates/nsh-core/**" | |
| - "crates/nsh-dev/**" | |
| - "crates/nsh-engine/**" | |
| - "crates/nsh-js/**" | |
| - "crates/nsh-linux-app/**" | |
| - "crates/nsh-linux-host/**" | |
| - "crates/nsh-macros/**" | |
| - "crates/nsh-package/**" | |
| - "crates/nsh-platform-linux/**" | |
| - "crates/nsh-testing/**" | |
| - "crates/nsh-base/**" | |
| - "crates/xtask/**" | |
| - "examples/counter/**" | |
| - "examples/gallery/**" | |
| - "Cargo.toml" | |
| - "Cargo.lock" | |
| - ".cargo/**" | |
| - "rust-toolchain.toml" | |
| - ".github/workflows/linux.yml" | |
| merge_group: | |
| types: [checks_requested] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: linux-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| # CI builds each crate once: no incremental state and no debug info | |
| # (faster builds, smaller caches; panics still name their file and line). | |
| CARGO_INCREMENTAL: "0" | |
| CARGO_PROFILE_DEV_DEBUG: "0" | |
| # The toolchain file's iOS and Android targets are only the release's. | |
| RUSTUP_TOOLCHAIN: stable | |
| jobs: | |
| check: | |
| # 24.04 has GTK 4.14 and Pango 1.52+, what `nsh-platform-linux` needs. | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # QuickJS is C (bindgen needs libclang); the backend links GTK 4 and | |
| # Pango, and WebKitGTK 6.0 for web views (the hosts' default); Xvfb | |
| # is the display the examples' tests open their windows on. | |
| - name: Install clang, GTK 4 and WebKitGTK | |
| run: sudo apt-get update && sudo apt-get install -y clang libclang-dev libgtk-4-dev libwebkitgtk-6.0-dev xvfb | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy | |
| # Dependencies only: main's runs save it, pull requests restore it. | |
| - name: Cache Cargo | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref == 'refs/heads/main' }} | |
| - name: Clippy | |
| run: > | |
| cargo clippy --all-targets | |
| -p nsh-platform-linux -p nsh-linux-host -p nsh-linux-app | |
| -p nsh-cli -p nsh-dev -p xtask | |
| -- -D warnings | |
| # The backend alone, without the `webview` feature the hosts turn on: | |
| # web views as placeholders. | |
| - name: Clippy (without WebKitGTK) | |
| run: cargo clippy --all-targets -p nsh-platform-linux -- -D warnings | |
| # Tests need no display: they do not start GTK. | |
| - name: Test | |
| run: > | |
| cargo test -p nsh-platform-linux -p nsh-cli -p nsh-dev | |
| && cargo test -p nsh-platform-linux --features webview | |
| # The examples' tests in GTK windows on a virtual display, with the | |
| # platform's input (`nsh test --target linux`): those a real platform | |
| # runs (real time). | |
| - name: Run the examples' tests in GTK windows | |
| run: | | |
| cargo build -p nsh-cli | |
| # A session bus of its own: without one, GTK's portal and | |
| # accessibility lookups wait for D-Bus autolaunch on each display. | |
| run() { dbus-run-session -- xvfb-run -a ./target/debug/nsh test "$@" --target linux; } | |
| run examples/counter | |
| for file in context-menu device dock form gestures hover links navigation network photos resizable shortcuts storage timers; do | |
| run "examples/gallery/tests/$file.test.tsx" | |
| done | |
| run examples/gallery/tests/environment.test.tsx --filter appearance | |
| # Apps with Rust crates, in hosts built with them: a TSX app and a | |
| # Rust app (its root). | |
| run examples/rust-exports | |
| run examples/gallery-rs/App.test.tsx |