Skip to content

Check formatting in CI #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 2, 2025
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
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2025-04-15
components: rust-src
components: rust-src,rustfmt,clippy

- name: Check formatting
run: cargo fmt --all --check

- name: Build
run: |
Expand Down
5 changes: 4 additions & 1 deletion crates/core/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::process::Command;
fn main() {
// note: add error checking yourself.
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().unwrap();
let output = Command::new("git")
.args(&["rev-parse", "HEAD"])
.output()
.unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
}
28 changes: 15 additions & 13 deletions crates/core/src/bson/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ mod test {
let neg_one_bytes = (-1i64).to_le_bytes();
let mut parser = Parser::new(&neg_one_bytes);
assert_eq!(parser.read_int64().unwrap(), -1);

let min_bytes = (i64::MIN).to_le_bytes();
let mut parser = Parser::new(&min_bytes);
assert_eq!(parser.read_int64().unwrap(), i64::MIN);

let neg_42_bytes = (-42i64).to_le_bytes();
let mut parser = Parser::new(&neg_42_bytes);
assert_eq!(parser.read_int64().unwrap(), -42);
Expand All @@ -227,11 +227,11 @@ mod test {
let neg_one_bytes = (-1i32).to_le_bytes();
let mut parser = Parser::new(&neg_one_bytes);
assert_eq!(parser.read_int32().unwrap(), -1);

let min_bytes = (i32::MIN).to_le_bytes();
let mut parser = Parser::new(&min_bytes);
assert_eq!(parser.read_int32().unwrap(), i32::MIN);

let neg_42_bytes = (-42i32).to_le_bytes();
let mut parser = Parser::new(&neg_42_bytes);
assert_eq!(parser.read_int32().unwrap(), -42);
Expand All @@ -243,11 +243,11 @@ mod test {
let mut parser = Parser::new(&neg_pi_bytes);
let val = parser.read_double().unwrap();
assert!((val - (-3.14159)).abs() < 0.00001);

let neg_inf_bytes = f64::NEG_INFINITY.to_le_bytes();
let mut parser = Parser::new(&neg_inf_bytes);
assert_eq!(parser.read_double().unwrap(), f64::NEG_INFINITY);

let nan_bytes = f64::NAN.to_le_bytes();
let mut parser = Parser::new(&nan_bytes);
assert!(parser.read_double().unwrap().is_nan());
Expand All @@ -257,13 +257,13 @@ mod test {
fn test_read_bool_edge_cases() {
let mut parser = Parser::new(&[0x00]);
assert_eq!(parser.read_bool().unwrap(), false);

let mut parser = Parser::new(&[0x01]);
assert_eq!(parser.read_bool().unwrap(), true);

let mut parser = Parser::new(&[0xFF]);
assert_eq!(parser.read_bool().unwrap(), true);

let mut parser = Parser::new(&[0x7F]);
assert_eq!(parser.read_bool().unwrap(), true);
}
Expand Down Expand Up @@ -327,7 +327,7 @@ mod test {
#[test]
fn test_element_type_invalid() {
let invalid_types = [0, 11, 12, 13, 14, 15, 19, 20, 99, 255];

for invalid_type in invalid_types {
let data = [invalid_type];
let mut parser = Parser::new(&data);
Expand Down Expand Up @@ -375,7 +375,9 @@ mod test {

#[test]
fn test_object_id_exact_size() {
let data = &[0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c];
let data = &[
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
];
let mut parser = Parser::new(data);
let oid = parser.read_object_id().unwrap();
assert_eq!(oid, data);
Expand All @@ -385,11 +387,11 @@ mod test {
fn test_advance_checked_boundary() {
let data = &[0x01, 0x02, 0x03];
let mut parser = Parser::new(data);

// Should succeed
assert!(parser.advance_checked(3).is_ok());
assert_eq!(parser.remaining().len(), 0);

// Should fail - no more data
assert!(parser.advance_checked(1).is_err());
}
Expand Down
3 changes: 1 addition & 2 deletions crates/core/src/ext.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use sqlite_nostd::{Connection, Destructor, ManagedStmt, ResultCode, sqlite3};
use sqlite_nostd::{sqlite3, Connection, Destructor, ManagedStmt, ResultCode};

pub trait SafeManagedStmt {
fn exec(&self) -> Result<(), ResultCode>;
Expand All @@ -23,7 +23,6 @@ impl SafeManagedStmt for ManagedStmt {
}
}


pub trait ExtendedDatabase {
fn exec_text(&self, sql: &str, param: &str) -> Result<(), ResultCode>;
}
Expand Down
1 change: 0 additions & 1 deletion crates/shell/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

fn main() {
let mut cfg = cc::Build::new();

Expand Down
1 change: 0 additions & 1 deletion crates/shell/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ fn panic(_info: &core::panic::PanicInfo) -> ! {
#[lang = "eh_personality"]
extern "C" fn eh_personality() {}


#[no_mangle]
pub extern "C" fn core_init(_dummy: *mut c_char) -> c_int {
powersync_init_static()
Expand Down
1 change: 0 additions & 1 deletion crates/sqlite/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
#![no_main]