Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-D warnings"
# RUSTFLAGS can't catch Cargo's own lints (like unused dependencies),
# so fail the build on those separately.
CARGO_BUILD_WARNINGS: "deny"

# Disable all permissions by default (https://docs.zizmor.sh/audits/#excessive-permissions)
permissions: {}
Expand Down
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ argon2 = "0.6.0"
axum = { version = "0.8.8", features = ["macros", "tracing"] }
axum-server = { version = "0.8.0", features = ["tls-rustls-no-provider"] }
clap = { version = "4.6.0", features = ["derive", "env", "cargo"] }
fake = { version = "5.1.0", default-features = false }
friendly-zoo = "1.1.0"
garde = { version = "0.23.0", default-features = false, features = [
"derive",
Expand All @@ -94,7 +93,6 @@ listenfd = "1.0.2"
mime_guess = "2.0.5"
rand = { version = "0.10.1" }
serde = "1.0.228"
serde-aux = { version = "4.7.0", default-features = false }
serde_json = "1.0.149"
serde_qs = { version = "1.1.0", features = ["axum"] }
sqlx = { version = "0.8.6", features = [
Expand Down Expand Up @@ -125,7 +123,6 @@ tower-http = { version = "0.7.1", features = ["tracing", "trace"] }
tracing = "0.1.44"
tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
uuid = { version = "1.22.0", features = ["v4", "serde"] }
visdom = "1.0.4"
rustls = { version = "0.23.37", default-features = false, features = ["ring"] }
htmf = { git = "https://github.com/raffomania/htmf", features = [
"pretty-print",
Expand All @@ -139,7 +136,6 @@ async-trait = "0.1.89"
chrono = "0.4.44"
redact = "0.1.11"
enum_delegate = "0.2.0"
tower-livereload = "0.10.3"
reqwest = { version = "0.13.2", features = [
"brotli",
"gzip",
Expand All @@ -156,6 +152,8 @@ derive_more = { version = "2.1.1", features = ["debug"] }
# For passing LogLevels to sqlx
log = "0.4.29"
quick-xml = { version = "0.42.0", features = ["serialize"] }
tower-livereload = { version = "0.10.3" }
fake = { version = "5.1.0", default-features = false }

[patch.crates-io]
activitypub_federation = { git = "https://github.com/raffomania/activitypub-federation-rust", branch = "update-axum" }
Expand All @@ -167,6 +165,7 @@ regex = "1.12.3"

[dev-dependencies]
http-body-util = "0.1.3"
visdom = "1.0.4"
serde_json = "1.0.149"
test-log = { version = "0.2.19", features = [
"trace",
Expand Down
2 changes: 2 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ ci-fast: check-database-info check-sbom && reuse-lint
set -euo pipefail

export RUSTFLAGS="-D warnings"
# Match CI: turn Cargo's own lint warnings into errors
export CARGO_BUILD_WARNINGS="deny"
# Prevent full recompilations in the normal dev setup which has different rustflags
export CARGO_TARGET_DIR="target_ci"
export CARGO_TERM_QUIET="true"
Expand Down
5 changes: 5 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ mod tracing_filter;
mod tracing_format;

use anyhow::Result;
// Shut up the cargo unused dependencies lint for this specific dependency.
// It's only used in development and there's no good alternative to fix this.
#[cfg(not(debug_assertions))]
#[expect(unused_imports)]
use fake;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
3 changes: 1 addition & 2 deletions src/routes/bookmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ use uuid::Uuid;
use crate::{
authentication::AuthUser,
db::{self, bookmarks::InsertBookmark},
extract::{self},
federation,
extract, federation,
form_errors::FormErrors,
forms::{self, bookmarks::CreateBookmark},
htmf_response::HtmfResponse,
Expand Down
3 changes: 1 addition & 2 deletions src/routes/federation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ use url::Url;
use uuid::Uuid;

use crate::{
db::{self},
extract,
db, extract,
federation::{self, person::Person},
response_error::ResponseResult,
server::AppState,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use uuid::Uuid;
use crate::{
authentication::AuthUser,
db::{self, LinkDestination},
extract::{self},
extract,
form_errors::FormErrors,
forms::links::{CreateLink, PartialCreateLink},
htmf_response::HtmfResponse,
Expand Down
3 changes: 1 addition & 2 deletions src/routes/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use uuid::Uuid;
use crate::{
atom::{self, Feed},
authentication::AuthUser,
db::{self},
extract::{self},
db, extract,
form_errors::FormErrors,
forms::{
self,
Expand Down
10 changes: 2 additions & 8 deletions src/routes/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@ use serde::{Deserialize, Serialize};
use serde_qs::web::QsQuery;

use crate::{
authentication::AuthUser,
db::{self},
extract,
htmf_response::HtmfResponse,
response_error::ResponseResult,
server::AppState,
views,
views::layout,
authentication::AuthUser, db, extract, htmf_response::HtmfResponse,
response_error::ResponseResult, server::AppState, views, views::layout,
};
pub fn router() -> Router<AppState> {
let router: Router<AppState> = Router::new();
Expand Down
4 changes: 2 additions & 2 deletions src/routes/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ use crate::{
authentication::{self, AuthUser},
db,
db::sessions::Session,
extract::{self},
extract,
forms::users::{CreateOidcUser, Login, OidcLoginQuery, OidcSelectUsername},
htmf_response::HtmfResponse,
oidc::{self},
oidc,
response_error::{ResponseError, ResponseResult},
server::AppState,
session,
Expand Down
26 changes: 9 additions & 17 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ use listenfd::ListenFd;
use sqlx::PgPool;
use tower::ServiceBuilder;
use tower_http::trace::TraceLayer;
use tower_livereload::LiveReloadLayer;
use url::Url;

use crate::{
archive,
cli::ListenArgs,
db::{self},
federation, oidc, routes,
};
use crate::{archive, cli::ListenArgs, db, federation, oidc, routes};

#[derive(Clone)]
pub struct AppState {
Expand Down Expand Up @@ -53,19 +49,10 @@ pub fn app(state: AppState) -> anyhow::Result<Router> {
.layer(FederationMiddleware::new(state.federation_config.clone())),
);

#[cfg(all(debug_assertions, not(test)))]
{
use tower_livereload::LiveReloadLayer;

fn not_htmx_request_livereload_predicate(
req: &axum::http::Request<axum::body::Body>,
) -> bool {
!req.headers().contains_key("hx-request")
}

if cfg!(all(debug_assertions, not(test))) {
router = router
.layer(LiveReloadLayer::new().request_predicate(not_htmx_request_livereload_predicate));
};
}

Ok(router.with_state(state))
}
Expand Down Expand Up @@ -186,3 +173,8 @@ async fn wipe_all_data(pool: &PgPool) -> anyhow::Result<()> {
tx.commit().await?;
Ok(())
}

/// Return true if the given request was not made by htmx.
fn not_htmx_request_livereload_predicate(req: &axum::http::Request<axum::body::Body>) -> bool {
!req.headers().contains_key("hx-request")
}
2 changes: 1 addition & 1 deletion src/tests/federation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::Result;
use axum::http::StatusCode;

use crate::{
db::{self},
db,
federation::{self, webfinger},
forms::{
bookmarks::CreateBookmark,
Expand Down
6 changes: 1 addition & 5 deletions src/tests/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ use sqlx::{Postgres, Row, Transaction, query};
use url::Url;
use uuid::Uuid;

use crate::{
authentication::hash_password,
db::{self},
forms::ap_users::CreateApUser,
};
use crate::{authentication::hash_password, db, forms::ap_users::CreateApUser};

#[test_log::test(tokio::test)]
async fn generate_missing_ap_users_migration() -> Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
self,
bookmarks::{InsertBookmark, UpdateBookmark},
},
routes::search::{self},
routes::search,
tests::util::{request_builder::TestPage, test_app::TestApp},
};

Expand Down
Loading
Loading