| name: Windows | |
| # Builds, lints and tests the Windows backend (Win32, Direct2D, DirectWrite) | |
| # and the tooling that runs it (`nsh run --target windows`, `nsh package | |
| # --target windows`, `cargo run` on Windows). | |
| 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-macros/**" | |
| - "crates/nsh-package/**" | |
| - "crates/nsh-platform-windows/**" | |
| - "crates/nsh-testing/**" | |
| - "crates/nsh-base/**" | |
| - "crates/nsh-windows-app/**" | |
| - "crates/nsh-windows-host/**" | |
| - "crates/xtask/**" | |
| - "examples/counter/**" | |
| - "examples/gallery/**" | |
| - "Cargo.toml" | |
| - "Cargo.lock" | |
| - ".cargo/**" | |
| - "rust-toolchain.toml" | |
| - ".github/workflows/windows.yml" | |
| pull_request: | |
| paths: | |
| - "crates/nsh-bundler/**" | |
| - "crates/nsh-cli/**" | |
| - "crates/nsh-core/**" | |
| - "crates/nsh-dev/**" | |
| - "crates/nsh-engine/**" | |
| - "crates/nsh-js/**" | |
| - "crates/nsh-macros/**" | |
| - "crates/nsh-package/**" | |
| - "crates/nsh-platform-windows/**" | |
| - "crates/nsh-testing/**" | |
| - "crates/nsh-base/**" | |
| - "crates/nsh-windows-app/**" | |
| - "crates/nsh-windows-host/**" | |
| - "crates/xtask/**" | |
| - "examples/counter/**" | |
| - "examples/gallery/**" | |
| - "Cargo.toml" | |
| - "Cargo.lock" | |
| - ".cargo/**" | |
| - "rust-toolchain.toml" | |
| - ".github/workflows/windows.yml" | |
| merge_group: | |
| types: [checks_requested] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: windows-${{ 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: | |
| runs-on: windows-latest | |
| env: | |
| # QuickJS is C: bindgen needs libclang, which the image's LLVM has. | |
| LIBCLANG_PATH: C:\Program Files\LLVM\bin | |
| # rustc can overflow its default stack on the `windows` crate's | |
| # bindings (STATUS_STACK_BUFFER_OVERRUN). | |
| RUST_MIN_STACK: "268435456" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - 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-windows -p nsh-windows-host -p nsh-windows-app | |
| -p nsh-cli -p nsh-dev -p xtask | |
| -- -D warnings | |
| # Tests need no display: they open no window. | |
| - name: Test | |
| run: cargo test -p nsh-platform-windows -p nsh-windows-host -p nsh-windows-app -p nsh-cli -p nsh-dev -p xtask | |
| # The examples' tests in Win32 windows, with the platform's input | |
| # (`nsh test --target windows`): those a real platform runs (real | |
| # time). | |
| - name: Run the examples' tests in Win32 windows | |
| shell: bash | |
| run: | | |
| cargo build -p nsh-cli | |
| run() { ./target/debug/nsh test "$@" --target windows; } | |
| 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 |