From 6c1d1848b2e50f753a9a27a05473bc5f4f5d6e1b Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Fri, 30 May 2025 01:22:08 +0200 Subject: [PATCH] Add a CI check for PRs (#360) Closes #339 --- .github/workflows/pr.yml | 44 ++++++++++++++++++++++++++++++++++ Cargo.toml | 1 - src/bin/edit/draw_statusbar.rs | 2 +- src/bin/edit/main.rs | 6 ----- 4 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..56a1f41 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,44 @@ +name: PR Check + +on: + pull_request: + branches: + - main + +env: + CARGO_TERM_COLOR: always + +jobs: + check: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - windows-latest + steps: + # The Windows runners have autocrlf enabled by default. + - name: Disable git autocrlf + run: git config --global core.autocrlf false + if: matrix.os == 'windows-latest' + - name: Checkout + uses: actions/checkout@v4 + # https://github.com/actions/cache/blob/main/examples.md#rust---cargo + # Depends on `Cargo.lock` --> Has to be after checkout. + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Install Rust + run: rustup toolchain install nightly --no-self-update --profile minimal --component rust-src,rustfmt,clippy + - name: Check formatting + run: cargo fmt --all -- --check + - name: Run tests + run: cargo test --all-features --all-targets + - name: Run clippy + run: cargo clippy --all-features --all-targets -- --deny warnings diff --git a/Cargo.toml b/Cargo.toml index cbc43b5..e334997 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,6 @@ name = "lib" harness = false [features] -debug-layout = [] debug-latency = [] # We use `opt-level = "s"` as it significantly reduces binary size. diff --git a/src/bin/edit/draw_statusbar.rs b/src/bin/edit/draw_statusbar.rs index 0eba7de..474d7dd 100644 --- a/src/bin/edit/draw_statusbar.rs +++ b/src/bin/edit/draw_statusbar.rs @@ -155,7 +155,7 @@ pub fn draw_statusbar(ctx: &mut Context, state: &mut State) { ), ); - #[cfg(any(feature = "debug-layout", feature = "debug-latency"))] + #[cfg(feature = "debug-latency")] ctx.label( "stats", &arena_format!(ctx.arena(), "{}/{}", tb.logical_line_count(), tb.visual_line_count(),), diff --git a/src/bin/edit/main.rs b/src/bin/edit/main.rs index e017643..0f625b2 100644 --- a/src/bin/edit/main.rs +++ b/src/bin/edit/main.rs @@ -158,12 +158,6 @@ fn run() -> apperr::Result<()> { draw(&mut ctx, &mut state); - #[cfg(feature = "debug-layout")] - { - drop(ctx); - state.buffer.buffer.copy_from_str(&tui.debug_layout()); - } - #[cfg(feature = "debug-latency")] { passes += 1;