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
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,20 @@ jobs:
include:
- target: x86_64-unknown-linux-gnu # Debian
os: ubuntu-latest
container: ''
shell: bash
cargo_env: ''
# TODO: Fix compiling for musl
# - target: x86_64-unknown-linux-musl # Alpine
# os: ubuntu-latest
# container: alpine:latest
# shell: sh
# cargo_env: "source $HOME/.cargo/env"
# cargo_env: "source $HOME/.cargo/env"
- target: aarch64-unknown-linux-gnu # Debian
os: ubuntu-24.04-arm
container: ''
shell: bash
cargo_env: ''
# TODO: Fix cross compiling for the below targets
# - target: aarch64-unknown-linux-musl # Alpine
# os: ubuntu-24.04-arm
Expand All @@ -84,13 +88,19 @@ jobs:
# cargo_env: "source $HOME/.cargo/env"
- target: x86_64-apple-darwin # macOS/Intel
os: macos-latest
container: ''
shell: bash
cargo_env: ''
- target: aarch64-apple-darwin # macOS/Apple Silicon
os: macos-latest
container: ''
shell: bash
cargo_env: ''
- target: x86_64-pc-windows-msvc # Windows
os: windows-latest
container: ''
shell: bash
cargo_env: ''
name: Build (${{ matrix.target }})
needs: setup_release
runs-on: ${{ matrix.os }}
Expand Down
3 changes: 2 additions & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
array_width = 30
color = "Always"
comment_width = 120
error_on_line_overflow = true
error_on_unformatted = true
fn_params_layout = "Vertical"
Expand All @@ -11,5 +12,5 @@ normalize_doc_attributes = true
reorder_impl_items = true
single_line_if_else_max_width = 100
single_line_let_else_max_width = 100
style_edition = "2021"
style_edition = "2024"
wrap_comments = true
8 changes: 4 additions & 4 deletions crates/server/src/auth.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![doc = "Authentication utilities for the application."]
//! Authentication utilities for the application.

// lib imports
use base64::{engine::general_purpose, Engine as _};
use bcrypt::{hash, verify, DEFAULT_COST};
use base64::{Engine as _, engine::general_purpose};
use bcrypt::{DEFAULT_COST, hash, verify};
use diesel::{QueryDsl, RunQueryDsl};
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation};
use jsonwebtoken::{DecodingKey, EncodingKey, Header, Validation, decode, encode};
use once_cell::sync::Lazy;
use rand::Rng;
use rocket::http::Status;
Expand Down
4 changes: 2 additions & 2 deletions crates/server/src/certs.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#![doc = "Certificate utilities for the application."]
//! Certificate utilities for the application.

// standard imports
use std::fs;
use std::path::Path;

// lib imports
use rcgen::{generate_simple_self_signed, CertifiedKey};
use rcgen::{CertifiedKey, generate_simple_self_signed};

/// Ensure that the certificates exist at the given paths.
pub fn ensure_certificates_exist(
Expand Down
5 changes: 3 additions & 2 deletions crates/server/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc = "Configuration module for the application."]
//! Configuration module for the application.

// lib imports
use config::{Config, ConfigError, Environment, File};
Expand Down Expand Up @@ -81,7 +81,8 @@ impl Default for ServerSettings {
impl Settings {
/// Create a new instance of `Settings`.
pub fn new() -> Result<Self, ConfigError> {
// Start with defaults provided via set_default and then merge in any provided config file or environment variables.
// Start with defaults provided via set_default and then merge in any provided config file
// or environment variables.
let config = Config::builder()
.set_default("general.data_dir", GeneralSettings::default().data_dir)?
.set_default("server.use_https", ServerSettings::default().use_https)?
Expand Down
7 changes: 4 additions & 3 deletions crates/server/src/db/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#![doc = "Database utilities for the application."]
//! Database utilities for the application.

pub(crate) mod models;
pub(crate) mod schema;

// lib imports
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
use diesel_migrations::{EmbeddedMigrations, MigrationHarness, embed_migrations};
use rocket::{
Build,
Rocket,
fairing::{Fairing, Info, Kind},
Build, Rocket,
};
use rocket_sync_db_pools::{database, diesel};

Expand Down
2 changes: 1 addition & 1 deletion crates/server/src/db/models.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc = "Database models for the application."]
//! Database models for the application.

// lib imports
use diesel::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/server/src/db/schema.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc = "Database schema for the application."]
//! Database schema for the application.

// lib imports
use diesel::table;
Expand Down
2 changes: 1 addition & 1 deletion crates/server/src/dependencies/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc = "Module for everything related to dependencies."]
//! Module for everything related to dependencies.

use cargo_metadata::{MetadataCommand, Package};
use std::error::Error;
Expand Down
2 changes: 1 addition & 1 deletion crates/server/src/globals.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc = "Miscellaneous utilities for the application."]
//! Miscellaneous utilities for the application.

// lib imports
use once_cell::sync::Lazy;
Expand Down
2 changes: 1 addition & 1 deletion crates/server/src/logging/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc = "Logging utilities for the application."]
//! Logging utilities for the application.

// standard imports
use std::io;
Expand Down
8 changes: 5 additions & 3 deletions crates/server/src/tray.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#![doc = "Tray icon utilities for the application."]
//! Tray icon utilities for the application.

// lib imports
use tao::{
event::Event,
event_loop::{ControlFlow, EventLoopBuilder},
};
use tray_icon::{
TrayIconBuilder,
TrayIconEvent,
menu::{AboutMetadata, Menu, MenuEvent, MenuItem, PredefinedMenuItem, Submenu},
TrayIconBuilder, TrayIconEvent,
};

// local imports
Expand Down Expand Up @@ -124,7 +125,8 @@ pub fn launch() {
);

// We have to request a redraw here to have the icon actually show up.
// Tao only exposes a redraw method on the Window so we use core-foundation directly.
// Tao only exposes a redraw method on the Window so we use core-foundation
// directly.
#[cfg(target_os = "macos")]
{
use objc2_core_foundation::CFRunLoop;
Expand Down
2 changes: 1 addition & 1 deletion crates/server/src/web/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc = "Web server utilities for the application."]
//! Web server utilities for the application.

// modules
mod routes;
Expand Down
8 changes: 4 additions & 4 deletions crates/server/src/web/routes/auth.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#![doc = "Routes for the web server."]
//! Routes for the web server.

// lib imports
use diesel::QueryDsl;
use diesel::RunQueryDsl;
use diesel::{ExpressionMethods, SelectableHelper};
use rocket::http::Status;
use rocket::serde::{json::Json, Deserialize, Serialize};
use rocket::serde::{Deserialize, Serialize, json::Json};
use rocket::{get, post};
use rocket_okapi::{openapi, JsonSchema};
use rocket_okapi::{JsonSchema, openapi};

// local imports
use crate::auth::{AdminGuard, Claims};
use crate::db::models::User;
use crate::db::DbConn;
use crate::db::models::User;

#[derive(Deserialize, JsonSchema)]
pub struct LoginForm {
Expand Down
2 changes: 1 addition & 1 deletion crates/server/src/web/routes/common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc = "Routes for the web server."]
//! Routes for the web server.

// lib imports
use rocket::get;
Expand Down
2 changes: 1 addition & 1 deletion crates/server/src/web/routes/dependencies.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc = "Routes for dependencies."]
//! Routes for dependencies.

// lib imports
use cargo_metadata::Package;
Expand Down
2 changes: 1 addition & 1 deletion crates/server/src/web/routes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc = "Common routes module for the web server."]
//! Common routes module for the web server.

// modules
mod auth;
Expand Down
6 changes: 3 additions & 3 deletions crates/server/src/web/routes/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
use diesel::{QueryDsl, RunQueryDsl};
use rocket::http::Status;
use rocket::post;
use rocket::serde::{json::Json, Deserialize};
use rocket_okapi::openapi;
use rocket::serde::{Deserialize, json::Json};
use rocket_okapi::JsonSchema;
use rocket_okapi::openapi;

// local imports
use crate::auth::AdminGuard;
use crate::db::models::User;
use crate::db::DbConn;
use crate::db::models::User;

#[derive(Deserialize, JsonSchema)]
pub struct CreateUserForm {
Expand Down
2 changes: 1 addition & 1 deletion crates/server/tests/fixtures/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::fs;
use std::path::Path;

// lib imports
use diesel::sqlite::SqliteConnection;
use diesel::Connection;
use diesel::sqlite::SqliteConnection;
use diesel_migrations::MigrationHarness;
use once_cell::sync::Lazy;
use rocket::http::Status;
Expand Down
5 changes: 3 additions & 2 deletions crates/server/tests/test_web/routes/dependencies.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use crate::test_web::test_request;

use rocket::http::Status;
use rocket::serde::json::{serde_json, Value};
use rocket::serde::json::{Value, serde_json};

#[rocket::async_test]
async fn test_get_dependencies_route() {
let response = test_request("get", "/dependencies", None, Status::Ok, None).await;

// ensure response is a json list of dictionaries, and each dictionary has the keys name, version, and license
// ensure response is a json list of dictionaries, and each dictionary has the keys name,
// version, and license
let body = response.body;
let json: Value = serde_json::from_str(&body).unwrap();

Expand Down
Loading