From 71b79cf1b436bc117ef0487d63be125b01988e15 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Mon, 14 Apr 2025 20:46:32 +0800 Subject: [PATCH] chore: Add Windows CI (#789) --- .github/workflows/ci.yml | 29 +++++++++++++----- crates/ui/src/kbd.rs | 64 ++++++++++++++++++++-------------------- 2 files changed, 54 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0668a85b..770024af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,20 +3,32 @@ on: pull_request: push: branches: - - '*' + - "*" tags: - - '*' + - "*" jobs: test: name: Test if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - runs-on: macos-latest + strategy: + fail-fast: false + matrix: + include: + - target: aarch64-apple-darwin + run_on: macos-latest + - target: x86_64-linux-gnu + run_on: ubuntu-latest + - target: x86_64-windows-msvc + run_on: windows-latest + runs-on: ${{ matrix.run_on }} steps: - uses: actions/checkout@v4 - name: Install system dependencies + if: ${{ matrix.run_on != 'windows-latest' }} run: script/bootstrap - name: Machete + if: ${{ matrix.run_on == 'macos-latest' }} uses: bnjbvr/cargo-machete@main - name: Setup | Cache Cargo uses: actions/cache@v4 @@ -27,13 +39,16 @@ jobs: ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ - key: ubuntu-test-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Install Tools - run: cargo install typos-cli || echo "typos-cli already installed" + key: test-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} + - name: Typo check + if: ${{ matrix.run_on == 'macos-latest' }} + run: | + cargo install typos-cli || echo "typos-cli already installed" + typos - name: Lint + if: ${{ matrix.run_on == 'macos-latest' }} run: | cargo clippy -- --deny warnings - typos - name: Build test run: | cargo test --all diff --git a/crates/ui/src/kbd.rs b/crates/ui/src/kbd.rs index 3e6030a1..f5150127 100644 --- a/crates/ui/src/kbd.rs +++ b/crates/ui/src/kbd.rs @@ -212,38 +212,7 @@ mod tests { use super::Kbd; use gpui::Keystroke; - if cfg!(target_os = "windows") { - assert_eq!(Kbd::format(&Keystroke::parse("a").unwrap()), "A"); - assert_eq!(Kbd::format(&Keystroke::parse("ctrl-a").unwrap()), "Ctrl+A"); - assert_eq!( - Kbd::format(&Keystroke::parse("shift-space").unwrap()), - "Shift+Space" - ); - assert_eq!( - Kbd::format(&Keystroke::parse("ctrl-alt-a").unwrap()), - "Ctrl+Alt+A" - ); - assert_eq!( - Kbd::format(&Keystroke::parse("ctrl-alt-shift-a").unwrap()), - "Ctrl+Alt+Shift+A" - ); - assert_eq!( - Kbd::format(&Keystroke::parse("ctrl-alt-shift-win-a").unwrap()), - "Ctrl+Alt+Shift+Win+A" - ); - assert_eq!( - Kbd::format(&Keystroke::parse("ctrl-shift-backspace").unwrap()), - "Ctrl+Shift+Backspace" - ); - assert_eq!( - Kbd::format(&Keystroke::parse("alt-delete").unwrap()), - "Alt+Delete" - ); - assert_eq!( - Kbd::format(&Keystroke::parse("alt-tab").unwrap()), - "Alt+Tab" - ); - } else { + if cfg!(target_os = "macos") { assert_eq!(Kbd::format(&Keystroke::parse("cmd-a").unwrap()), "⌘A"); assert_eq!(Kbd::format(&Keystroke::parse("cmd-enter").unwrap()), "⌘⏎"); assert_eq!( @@ -279,6 +248,37 @@ mod tests { Kbd::format(&Keystroke::parse("cmd-ctrl-shift-alt-a").unwrap()), "⌃⌥⇧⌘A" ); + } else { + assert_eq!(Kbd::format(&Keystroke::parse("a").unwrap()), "A"); + assert_eq!(Kbd::format(&Keystroke::parse("ctrl-a").unwrap()), "Ctrl+A"); + assert_eq!( + Kbd::format(&Keystroke::parse("shift-space").unwrap()), + "Shift+Space" + ); + assert_eq!( + Kbd::format(&Keystroke::parse("ctrl-alt-a").unwrap()), + "Ctrl+Alt+A" + ); + assert_eq!( + Kbd::format(&Keystroke::parse("ctrl-alt-shift-a").unwrap()), + "Ctrl+Alt+Shift+A" + ); + assert_eq!( + Kbd::format(&Keystroke::parse("ctrl-alt-shift-win-a").unwrap()), + "Ctrl+Alt+Shift+Win+A" + ); + assert_eq!( + Kbd::format(&Keystroke::parse("ctrl-shift-backspace").unwrap()), + "Ctrl+Shift+Backspace" + ); + assert_eq!( + Kbd::format(&Keystroke::parse("alt-delete").unwrap()), + "Alt+Delete" + ); + assert_eq!( + Kbd::format(&Keystroke::parse("alt-tab").unwrap()), + "Alt+Tab" + ); } } }