diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml new file mode 100644 index 0000000..35504a0 --- /dev/null +++ b/.github/workflows/CI.yaml @@ -0,0 +1,77 @@ +name: CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + RUSTFLAGS: "-Dwarnings" + RUST_BACKTRACE: 1 + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + check: + if: github.event.pull_request.draft == false + name: Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: awalsh128/cache-apt-pkgs-action@v1 + with: + packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev + version: 1.0 + - uses: dtolnay/rust-toolchain@1.90.0 + with: + components: rustfmt, clippy + - uses: Swatinem/rust-cache@v2 + with: + cache-all-crates: "true" + shared-key: "shared" + - run: cargo check + + + test: + if: github.event.pull_request.draft == false + name: Tests + runs-on: ubuntu-latest + needs: [check] + steps: + - uses: actions/checkout@v5 + - uses: awalsh128/cache-apt-pkgs-action@v1 + with: + packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev + version: 1.0 + - uses: dtolnay/rust-toolchain@1.90.0 + with: + components: rustfmt, clippy + - uses: Swatinem/rust-cache@v2 + with: + cache-all-crates: "true" + shared-key: "shared" + - run: cargo test + +# Doesn't seem to benefit from "check" cache, so run them in parallel + clippy: + if: github.event.pull_request.draft == false + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: awalsh128/cache-apt-pkgs-action@v1 + with: + packages: libwebkit2gtk-4.1-dev libgtk-3-dev libasound2-dev libudev-dev libayatana-appindicator3-dev libxdo-dev libglib2.0-dev + version: 1.0 + - uses: dtolnay/rust-toolchain@1.90.0 + with: + components: rustfmt, clippy + - uses: Swatinem/rust-cache@v2 + with: + cache-all-crates: "true" + shared-key: "shared" + - run: cargo clippy -- -W clippy::pedantic diff --git a/src/main.rs b/src/main.rs index ec1111c..ee484da 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,10 +28,10 @@ fn App() -> Element { #[component] pub fn SqlInput() -> Element { let mut sql = use_signal(|| "SELECT * FROM test;".to_string()); - let mut connection_url = use_signal(|| "".to_string()); + let mut connection_url = use_signal(String::new); let mut connect_txt = use_signal(|| "Connect".to_string()); let mut button_text = use_signal(|| "Execute".to_string()); - let mut result = use_signal(|| "".to_string()); + let mut result = use_signal(String::new); let connect_to_db = move |_| async move { let db_conn = consume_context::().0;