From c8b6d77c926daea4785207b8758da7ea4fb697a8 Mon Sep 17 00:00:00 2001 From: Carter Himmel Date: Wed, 6 Sep 2023 11:54:53 -0600 Subject: [PATCH] chore: error handler for circle back --- .github/workflows/test.yml | 31 ++++++++++--------- .pre-commit-config.yaml | 27 +++++++++++++--- .../src/context_menu/circle_back.rs | 3 +- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e358799..1213f03 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,11 +1,15 @@ -name: Tests +name: CI env: SQLX_OFFLINE: true + CARGO_TERM_COLOR: always on: push: + branches: [main] + paths-ignore: ["**.md"] pull_request: + paths-ignore: ["**.md"] concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -13,34 +17,31 @@ concurrency: jobs: check: - name: Lint, Format, and Build + name: Test Suite runs-on: chortle steps: - name: Checkout uses: actions/checkout@v3 - - name: Cache Cargo - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }} - - name: Setup Problem Matchers uses: r7kamura/rust-problem-matchers@v1 + - run: rustup toolchain install stable --profile minimal + + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + - name: Setup Rust uses: dtolnay/rust-toolchain@stable + - name: Install Cargo Make + uses: davidB/rust-cargo-make@v1 + - name: Run Formatter - run: cargo fmt --all --check + run: cargo make format - name: Run Clippy - run: cargo clippy -- -D warnings + run: cargo make lint - name: Build run: cargo build --all-features --release diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e177318..33e18c0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,9 +8,26 @@ repos: - id: check-yaml - id: check-added-large-files - - repo: https://github.com/doublify/pre-commit-rust - rev: v1.0 + - repo: local hooks: - - id: fmt - - id: cargo-check - - id: clippy + - id: format + name: format + description: Format files with cargo make fmt. + entry: cargo make format + language: system + types: [rust] + pass_filenames: false + - id: lint + name: lint + description: Lint files with cargo make lint. + entry: cargo make lint + language: system + types: [rust] + pass_filenames: false + - id: check + name: check + description: Check files with Cargo Check + entry: cargo check + language: system + types: [rust] + pass_filenames: false diff --git a/chuckle-interactions/src/context_menu/circle_back.rs b/chuckle-interactions/src/context_menu/circle_back.rs index b5e7c7f..5922b88 100644 --- a/chuckle-interactions/src/context_menu/circle_back.rs +++ b/chuckle-interactions/src/context_menu/circle_back.rs @@ -4,7 +4,7 @@ use time::{Duration, OffsetDateTime}; use twilight_model::application::interaction::InteractionData; use zephyrus::prelude::*; -use crate::commands::{text_response, user_from_interaction}; +use crate::commands::{handle_generic_error, text_response, user_from_interaction}; #[derive(Modal, Debug)] #[modal(title = "Circle Back")] @@ -21,6 +21,7 @@ struct CircleBackModal { #[command(message, name = "Circle Back")] #[description = "Circle back to this message in a given amount of time"] #[only_guilds] +#[error_handler(handle_generic_error)] pub async fn circle_back(ctx: &SlashContext) -> DefaultCommandResult { let data = match &ctx.interaction.data { Some(InteractionData::ApplicationCommand(data)) => data,