Add GitHub CI and fix clippy warnings

This commit is contained in:
oxalica 2024-08-31 22:48:03 -04:00
parent 812d6c8602
commit 5fadffef4d
5 changed files with 106 additions and 1 deletions

89
.github/workflows/ci.yaml vendored Normal file
View file

@ -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

View file

@ -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

View file

@ -14,3 +14,7 @@ rusqlite = "0.32"
tokio = { version = "1", features = ["rt", "macros"] }
blah = { path = "..", features = ["rusqlite"] }
[lints.clippy]
dbg_macro = "warn"
todo = "warn"

View file

@ -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

View file

@ -356,7 +356,7 @@ async fn room_get_feed(
))
}
/// Ref: https://www.jsonfeed.org/version/1.1/
/// Ref: <https://www.jsonfeed.org/version/1.1/>
#[derive(Debug, Serialize)]
#[serde(tag = "version", rename = "https://jsonfeed.org/version/1.1")]
struct FeedRoom {