diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml new file mode 100644 index 0000000..95b6697 --- /dev/null +++ b/.github/workflows/actionlint.yml @@ -0,0 +1,17 @@ +name: actionlint + +on: + pull_request: + +jobs: + actionlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6 + with: + show-progress: false + sparse-checkout: '.github/' + + - uses: docker://index.docker.io/rhysd/actionlint@sha256:b1934ee5f1c509618f2508e6eb47ee0d3520686341fec936f3b79331f9315667 # ratchet:docker://rhysd/actionlint:1.7.12 + with: + args: -color diff --git a/.github/workflows/ratchet.yml b/.github/workflows/ratchet.yml new file mode 100644 index 0000000..275736d --- /dev/null +++ b/.github/workflows/ratchet.yml @@ -0,0 +1,18 @@ +name: ratchet + +on: + pull_request: + +jobs: + ratchet: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6 + with: + show-progress: false + sparse-checkout: '.github/' + + - name: ratchet + uses: sethvargo/ratchet@27f7515b4648e179168f8f8ae2257636fdb03c48 # ratchet:sethvargo/ratchet@main + with: + files: .github/workflows/*.yml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..270fe31 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,64 @@ +name: rust + +on: + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6 + with: + show-progress: false + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # ratchet:dtolnay/rust-toolchain@stable + + - name: cargo build + run: cargo build --workspace --verbose + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6 + with: + show-progress: false + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # ratchet:dtolnay/rust-toolchain@stable + + - name: cargo test + run: cargo test --workspace --verbose + + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6 + with: + show-progress: false + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # ratchet:dtolnay/rust-toolchain@stable + with: + components: clippy + + - name: cargo clippy + run: cargo clippy --workspace --all-targets --all-features -- -D warnings + + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6 + with: + show-progress: false + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # ratchet:dtolnay/rust-toolchain@stable + with: + components: rustfmt + + - name: cargo fmt + run: cargo fmt --all -- --check diff --git a/rutt-tui/src/main.rs b/rutt-tui/src/main.rs index 64c21e8..801876b 100644 --- a/rutt-tui/src/main.rs +++ b/rutt-tui/src/main.rs @@ -63,27 +63,24 @@ async fn run_app( ui(f, state); })?; - if event::poll(std::time::Duration::from_millis(16))? { - if let Event::Key(key) = event::read()? { - if key.kind == KeyEventKind::Press { - let action = match key.code { - KeyCode::Char('q') => Some(Action::Quit), - KeyCode::Char('k') | KeyCode::Up => Some(Action::MoveUp), - KeyCode::Char('j') | KeyCode::Down => Some(Action::MoveDown), - KeyCode::Enter | KeyCode::Char('l') | KeyCode::Right => Some(Action::Enter), - KeyCode::Backspace | KeyCode::Char('h') | KeyCode::Left => { - Some(Action::Back) - } - _ => None, - }; - - if let Some(action) = action { - if action == Action::Quit { - return Ok(()); - } - state.handle_action(action, visible_height); - } + if event::poll(std::time::Duration::from_millis(16))? + && let Event::Key(key) = event::read()? + && key.kind == KeyEventKind::Press + { + let action = match key.code { + KeyCode::Char('q') => Some(Action::Quit), + KeyCode::Char('k') | KeyCode::Up => Some(Action::MoveUp), + KeyCode::Char('j') | KeyCode::Down => Some(Action::MoveDown), + KeyCode::Enter | KeyCode::Char('l') | KeyCode::Right => Some(Action::Enter), + KeyCode::Backspace | KeyCode::Char('h') | KeyCode::Left => Some(Action::Back), + _ => None, + }; + + if let Some(action) = action { + if action == Action::Quit { + return Ok(()); } + state.handle_action(action, visible_height); } } }