From 5fadffef4da86e54d804b6584388dff0d84ee36d Mon Sep 17 00:00:00 2001 From: oxalica Date: Sat, 31 Aug 2024 22:48:03 -0400 Subject: [PATCH] Add GitHub CI and fix clippy warnings --- .github/workflows/ci.yaml | 89 +++++++++++++++++++++++++++++++++++++++ Cargo.toml | 9 ++++ blahctl/Cargo.toml | 4 ++ blahd/Cargo.toml | 3 ++ blahd/src/main.rs | 2 +- 5 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..6deb479 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,89 @@ +name: CI +on: + pull_request: + push: + +permissions: + contents: read + +env: + RUST_BACKTRACE: full + RUSTDOCFLAGS: -Dwarnings + RUSTFLAGS: -Dwarnings + +jobs: + style: + name: Code style + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Rust stable + run: | + rustup update --no-self-update stable + rustup default stable + + - name: Cache dependencies + uses: Swatinem/rust-cache@v2 + + - name: Rustfmt + run: cargo fmt -- --check + + - name: Clippy + run: cargo clippy --workspace --all-targets -- -D clippy::dbg_macro -D clippy::todo + + - name: Rustdoc + run: cargo doc --workspace + + test: + strategy: + matrix: + rust: [stable] + name: Test ${{ matrix.rust }} + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Rust ${{ matrix.rust }} + run: | + rustup update --no-self-update ${{ matrix.rust }} + rustup default ${{ matrix.rust }} + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v2 + + - name: Build + run: cargo build --workspace --all-targets + + - name: Test + run: cargo test --workspace --all-targets -- --include-ignored + + nix-flake: + name: Flake package + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install nix + uses: cachix/install-nix-action@v26 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Cache nix store + uses: DeterminateSystems/magic-nix-cache-action@b46e247b898aa56e6d2d2e728dc6df6c84fdb738 + with: + # I do NOT consent to share build cache between FlakeHub. + # This should NOT be the default. + use-flakehub: false + + - name: Flake check + run: nix flake check --no-update-lock-file --show-trace + + - name: Flake build + run: nix build --no-update-lock-file --show-trace --print-build-logs diff --git a/Cargo.toml b/Cargo.toml index 64ed488..5cfd42f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,12 @@ members = [ ] default-members = ["blahd"] +[workspace.lints.clippy] +dbg_macro = "warn" +print_stderr = "warn" +print_stdout = "warn" +todo = "warn" + [package] name = "blah" version = "0.0.0" @@ -25,3 +31,6 @@ serde = { version = "1", features = ["derive"] } serde_jcs = "0.1" serde_json = "1" uuid = { version = "1", features = ["serde"] } + +[lints] +workspace = true diff --git a/blahctl/Cargo.toml b/blahctl/Cargo.toml index cbe5d36..dada5e3 100644 --- a/blahctl/Cargo.toml +++ b/blahctl/Cargo.toml @@ -14,3 +14,7 @@ rusqlite = "0.32" tokio = { version = "1", features = ["rt", "macros"] } blah = { path = "..", features = ["rusqlite"] } + +[lints.clippy] +dbg_macro = "warn" +todo = "warn" diff --git a/blahd/Cargo.toml b/blahd/Cargo.toml index 77d4399..5ef3566 100644 --- a/blahd/Cargo.toml +++ b/blahd/Cargo.toml @@ -27,3 +27,6 @@ uuid = { version = "1", features = ["v4"] } blah = { path = "..", features = ["rusqlite"] } basic-toml = "0.1.9" serde-inline-default = "0.2.0" + +[lints] +workspace = true diff --git a/blahd/src/main.rs b/blahd/src/main.rs index 392657e..9ae898f 100644 --- a/blahd/src/main.rs +++ b/blahd/src/main.rs @@ -356,7 +356,7 @@ async fn room_get_feed( )) } -/// Ref: https://www.jsonfeed.org/version/1.1/ +/// Ref: #[derive(Debug, Serialize)] #[serde(tag = "version", rename = "https://jsonfeed.org/version/1.1")] struct FeedRoom {