From db332e59f2c9cb75b2fb91d1d842df3203cab6a4 Mon Sep 17 00:00:00 2001 From: Xavier Vello Date: Thu, 2 May 2024 12:04:53 +0200 Subject: [PATCH 1/2] fix capture CI (#32) --- Cargo.lock | 2 +- capture/Cargo.toml | 2 +- capture/tests/django_compat.rs | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 82c787a..9d7fc97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -267,7 +267,7 @@ dependencies = [ [[package]] name = "axum-test-helper" version = "0.4.0" -source = "git+https://github.com/orphan-rs/axum-test-helper.git#8ca0aedaad5a6bdf351c34d5b80593ae1b7d2f3f" +source = "git+https://github.com/posthog/axum-test-helper.git#002d45d8bbbac04e6a474e9a850b7f023a87d32f" dependencies = [ "axum 0.7.5", "bytes", diff --git a/capture/Cargo.toml b/capture/Cargo.toml index 4e35d10..ae5ad9a 100644 --- a/capture/Cargo.toml +++ b/capture/Cargo.toml @@ -38,4 +38,4 @@ uuid = { workspace = true } [dev-dependencies] assert-json-diff = { workspace = true } -axum-test-helper = { git = "https://github.com/orphan-rs/axum-test-helper.git" } # TODO: remove, directly use reqwest like capture-server tests +axum-test-helper = { git = "https://github.com/posthog/axum-test-helper.git" } # TODO: remove, directly use reqwest like capture-server tests diff --git a/capture/tests/django_compat.rs b/capture/tests/django_compat.rs index d1d313c..87b0a1b 100644 --- a/capture/tests/django_compat.rs +++ b/capture/tests/django_compat.rs @@ -201,6 +201,11 @@ async fn it_matches_django_capture_behaviour() -> anyhow::Result<()> { if let Some(object) = expected.as_object_mut() { // site_url is unused in the pipeline now, let's drop it object.remove("site_url"); + + // Remove sent_at field if empty: Rust will skip marshalling it + if let Some(None) = object.get("sent_at").map(|v| v.as_str()) { + object.remove("sent_at"); + } } let match_config = assert_json_diff::Config::new(assert_json_diff::CompareMode::Strict); @@ -209,7 +214,9 @@ async fn it_matches_django_capture_behaviour() -> anyhow::Result<()> { { println!( "record mismatch at line {}, event {}: {}", - line_number, event_number, e + line_number + 1, + event_number, + e ); mismatches += 1; } From c6d5c67d901248d0b8019973201ada1db704c587 Mon Sep 17 00:00:00 2001 From: Xavier Vello Date: Thu, 2 May 2024 12:11:41 +0200 Subject: [PATCH 2/2] ci: move cargo check to linting job (#33) --- .github/workflows/rust.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ed5acb2..a525f3b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -67,9 +67,6 @@ jobs: - name: Run cargo test run: cargo test --all-features - - name: Run cargo check - run: cargo check --all-features - linting: runs-on: depot-ubuntu-22.04-4 @@ -89,12 +86,15 @@ jobs: ~/.cargo/git target key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }} - + + - name: Check format + run: cargo fmt -- --check + - name: Run clippy run: cargo clippy -- -D warnings - - name: Check format - run: cargo fmt -- --check + - name: Run cargo check + run: cargo check --all-features shear: runs-on: depot-ubuntu-22.04-4