diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml new file mode 100644 index 0000000..9a71208 --- /dev/null +++ b/.github/workflows/run_tests.yml @@ -0,0 +1,124 @@ +name: "Run Tests" + +on: + pull_request: + branches: + - "**" + push: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: "1" + +jobs: + check_style: + name: "Check Style" + if: github.repository == 'errmayank/ryuk' + runs-on: ubuntu-latest + steps: + - name: "Checkout repository" + uses: actions/checkout@v4 + + - name: "Setup pnpm" + uses: pnpm/action-setup@v4 + with: + version: 10.26.2 + + - name: "Check Prettier formatting" + run: ./script/prettier + shell: bash + + - name: "Check Rust formatting" + run: cargo fmt --all -- --check + + - name: "Check for typos" + uses: crate-ci/typos@v1.40.0 + + run_tests_linux_x86_64: + name: "Test Linux x86_64" + if: github.repository == 'errmayank/ryuk' + runs-on: ubuntu-latest + steps: + - name: "Checkout repository" + uses: actions/checkout@v4 + + - name: "Install Linux dependencies" + run: | + sudo apt-get update + sudo apt-get install -y \ + libx11-xcb-dev \ + libxkbcommon-x11-dev \ + libwayland-dev \ + libfontconfig-dev \ + libasound2-dev \ + libssl-dev + + - name: "Run Clippy" + run: ./script/clippy + shell: bash + + - name: "Install Nextest" + uses: taiki-e/install-action@nextest + + - name: "Run tests" + run: cargo nextest run --workspace --no-fail-fast + + run_tests_macos_arm64: + name: "Test macOS ARM64" + if: github.repository == 'errmayank/ryuk' + runs-on: macos-latest + steps: + - name: "Checkout repository" + uses: actions/checkout@v4 + + - name: "Run Clippy" + run: ./script/clippy + shell: bash + + - name: "Install Nextest" + uses: taiki-e/install-action@nextest + + - name: "Run tests" + run: cargo nextest run --workspace --no-fail-fast + + run_tests_macos_x86_64: + name: "Test macOS x86_64" + if: github.repository == 'errmayank/ryuk' + runs-on: macos-15-intel + steps: + - name: "Checkout repository" + uses: actions/checkout@v4 + + - name: "Run Clippy" + run: ./script/clippy + shell: bash + + - name: "Install Nextest" + uses: taiki-e/install-action@nextest + + - name: "Run tests" + run: cargo nextest run --workspace --no-fail-fast + + run_tests_windows_x86_64: + name: "Test Windows x86_64" + if: github.repository == 'errmayank/ryuk' + runs-on: windows-latest + steps: + - name: "Checkout repository" + uses: actions/checkout@v4 + + - name: "Run Clippy" + run: ./script/clippy.ps1 + shell: pwsh + + - name: "Install Nextest" + uses: taiki-e/install-action@nextest + + - name: "Run tests" + run: cargo nextest run --workspace --no-fail-fast diff --git a/crates/editor/src/tests.rs b/crates/editor/src/tests.rs index 5dbc501..4e4d454 100644 --- a/crates/editor/src/tests.rs +++ b/crates/editor/src/tests.rs @@ -239,37 +239,37 @@ fn test_toggle_formatting(cx: &mut TestAppContext) { cx.editor(|editor, _, cx| { let buffer = editor.buffer().read(cx); - // At "qui[c]k" + // At 'c' in "quick" let fmt = formatting_at(buffer, 7); assert_eq!(fmt.bold, Some(true)); assert_eq!(fmt.italic, None); assert_eq!(fmt.underline, None); - // At "bro[w]n" + // At 'w' in "brown" let fmt = formatting_at(buffer, 13); assert_eq!(fmt.bold, Some(true)); assert_eq!(fmt.italic, Some(true)); assert_eq!(fmt.underline, None); - // At "fo[x]" + // At 'x' in "fox" let fmt = formatting_at(buffer, 18); assert_eq!(fmt.bold, Some(true)); assert_eq!(fmt.italic, Some(true)); assert_eq!(fmt.underline, Some(true)); - // At "ju[m]ps" + // At 'm' in "jumps" let fmt = formatting_at(buffer, 22); assert_eq!(fmt.bold, None); assert_eq!(fmt.italic, Some(true)); assert_eq!(fmt.underline, Some(true)); - // At "o[v]er" + // At 'v' in "over" let fmt = formatting_at(buffer, 27); assert_eq!(fmt.bold, None); assert_eq!(fmt.italic, None); assert_eq!(fmt.underline, Some(true)); - // At "over t[h]e lazy" + // At 'h' in "over the lazy" let fmt = formatting_at(buffer, 32); assert_eq!(fmt.bold, None); assert_eq!(fmt.italic, None); diff --git a/script/clippy b/script/clippy index 28548b7..8d08728 100755 --- a/script/clippy +++ b/script/clippy @@ -9,3 +9,6 @@ fi set -x "${CARGO:-cargo}" clippy "$@" --release --all-targets --all-features -- --deny warnings + +which typos >/dev/null 2>&1 || exit 0 +typos diff --git a/script/clippy.ps1 b/script/clippy.ps1 new file mode 100644 index 0000000..2bbeb4b --- /dev/null +++ b/script/clippy.ps1 @@ -0,0 +1,27 @@ +$ErrorActionPreference = 'Stop' + +$Cargo = if ($env:CARGO) { + $env:CARGO +} +elseif ($cmd = Get-Command cargo -ErrorAction Ignore) { + $cmd.Source +} +else { + throw 'Could not find cargo in path.' +} + +$needAddWorkspace = $false +if ($args -notcontains "-p" -and $args -notcontains "--package") { + $needAddWorkspace = $true +} + +if ($needAddWorkspace) { + & $Cargo clippy --workspace --release --all-targets --all-features -- --deny warnings +} +else { + & $Cargo clippy --release --all-targets --all-features -- --deny warnings +} + +if (Get-Command typos -ErrorAction Ignore) { + & typos +} diff --git a/script/prettier b/script/prettier index 28b7375..6665066 100755 --- a/script/prettier +++ b/script/prettier @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail