From 42ae9964b76a24bc1b4f8ac243ce90a4dafff3fd Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Mon, 29 Apr 2024 09:16:03 -0400 Subject: [PATCH 01/14] Initial ci.yml (WIP) --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..58e1549c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +name: CI + +on: + push: + branches: + - main + - kendall/github-ci # TODO remove! + pull_request: + branches: + - '*' + +env: + CARGO_TERM_COLOR: always + # Make sure CI fails on all warnings, including Clippy lints + RUSTFLAGS: "-Dwarnings" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Init Hermit + uses: cashapp/activate-hermit@v1 + with: + cache: true + - name: Build + run: just build + + # test: + # # ... + # lint: + # # ... From c0e54ae6efd793057da0f6ff7b7fe0db0b6cf630 Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Mon, 29 Apr 2024 09:17:06 -0400 Subject: [PATCH 02/14] WIP ci.yml --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58e1549c..31dbcc69 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,8 @@ jobs: uses: cashapp/activate-hermit@v1 with: cache: true + - name: Setup + run: just setup - name: Build run: just build From c25bbca7b9e0abe4e17ba1ebc704815e07e96ed4 Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Mon, 29 Apr 2024 09:19:35 -0400 Subject: [PATCH 03/14] WIP ci.yml --- .github/workflows/ci.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 31dbcc69..c18d3f53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,8 +27,22 @@ jobs: run: just setup - name: Build run: just build + test: + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + rust: [ stable, nightly ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Init Hermit + uses: cashapp/activate-hermit@v1 + with: + cache: true + - name: Setup + run: just setup + - name: Test + run: just test - # test: - # # ... # lint: # # ... From bd718a2bd6674e9e27bfa78f75c4c021a6c6409c Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Mon, 29 Apr 2024 09:24:17 -0400 Subject: [PATCH 04/14] WIP ci.yml --- .github/workflows/ci.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c18d3f53..d0d68d90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: - name: Init Hermit uses: cashapp/activate-hermit@v1 with: - cache: true + cache: "true" - name: Setup run: just setup - name: Build @@ -35,10 +35,18 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 + + - name: Set Environment Variables for Hermit + run: echo "HERMIT_STATE_DIR_RAW=$RUNNER_TEMP/hermit" >> $GITHUB_ENV + - name: Debug environment + run: | + echo "HERMIT_STATE_DIR_RAW: $HERMIT_STATE_DIR_RAW" + echo "Other relevant environment variable checks" + - name: Init Hermit uses: cashapp/activate-hermit@v1 with: - cache: true + cache: "true" - name: Setup run: just setup - name: Test From e5058cacb820eb094112fedb1be71d3350e609bd Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Mon, 29 Apr 2024 09:27:21 -0400 Subject: [PATCH 05/14] WIP ci.yml --- .github/workflows/ci.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0d68d90..b44cbc88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,19 +30,11 @@ jobs: test: strategy: matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] + os: [ ubuntu-latest, macos-latest ] # TODO add back windows-latest rust: [ stable, nightly ] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - - name: Set Environment Variables for Hermit - run: echo "HERMIT_STATE_DIR_RAW=$RUNNER_TEMP/hermit" >> $GITHUB_ENV - - name: Debug environment - run: | - echo "HERMIT_STATE_DIR_RAW: $HERMIT_STATE_DIR_RAW" - echo "Other relevant environment variable checks" - - name: Init Hermit uses: cashapp/activate-hermit@v1 with: From 9e59d682fc295ce27f72d2542fb14bd87fc358fa Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Mon, 29 Apr 2024 09:29:41 -0400 Subject: [PATCH 06/14] WIP ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b44cbc88..632f2bdd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: - name: Init Hermit uses: cashapp/activate-hermit@v1 with: - cache: "true" + cache: true - name: Setup run: just setup - name: Build @@ -38,7 +38,7 @@ jobs: - name: Init Hermit uses: cashapp/activate-hermit@v1 with: - cache: "true" + cache: true - name: Setup run: just setup - name: Test From fcfa67fc20a8a090e78532dc458f5d140c50874c Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Mon, 29 Apr 2024 09:32:51 -0400 Subject: [PATCH 07/14] WIP ci.yml --- .github/workflows/ci.yml | 15 ++++++++++++--- Justfile | 6 +++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 632f2bdd..8e5b0f22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,15 @@ jobs: run: just setup - name: Test run: just test - - # lint: - # # ... + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Init Hermit + uses: cashapp/activate-hermit@v1 + with: + cache: true + - name: Setup + run: just setup + - name: Build + run: just lint diff --git a/Justfile b/Justfile index 569590b6..e33f1f5e 100644 --- a/Justfile +++ b/Justfile @@ -14,7 +14,11 @@ build: test: cargo test -# Run linting, look for warnings in the output to correct +# Run linting, look for warnings and/or diffs in the output to correct lint: cargo clippy --workspace + cargo fmt -- --check + +# Run formatting +fmt: cargo fmt \ No newline at end of file From 4af23f74e1a8fb24d8f555e92090b0da87635a9b Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Mon, 29 Apr 2024 09:35:11 -0400 Subject: [PATCH 08/14] Fix formatting, test failed test --- .github/workflows/ci.yml | 2 +- crates/protocol/src/message/order.rs | 8 ++-- crates/protocol/src/message/order_status.rs | 47 ++++++++++----------- crates/protocol/src/message/quote.rs | 1 - crates/protocol/src/resource/mod.rs | 2 + crates/protocol/src/test_data.rs | 4 +- 6 files changed, 33 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e5b0f22..57895c3b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,5 +53,5 @@ jobs: cache: true - name: Setup run: just setup - - name: Build + - name: Lint run: just lint diff --git a/crates/protocol/src/message/order.rs b/crates/protocol/src/message/order.rs index 527e3836..d283dc52 100644 --- a/crates/protocol/src/message/order.rs +++ b/crates/protocol/src/message/order.rs @@ -21,7 +21,7 @@ impl Order { created_at: Utc::now(), }; - let data = OrderData ; + let data = OrderData; Ok(Message { metadata, @@ -59,9 +59,9 @@ mod tests { #[test] fn can_parse_order_from_json() { let order = Order::create( - "did:example:from_1234".to_string(), - "did:example:to_1234".to_string(), - MessageKind::Rfq.typesafe_id().unwrap(), + "did:example:from_1234".to_string(), + "did:example:to_1234".to_string(), + MessageKind::Rfq.typesafe_id().unwrap(), ) .expect("Could not create Order"); let json: String = serde_json::to_string(&order).expect("failed to serialize Order"); diff --git a/crates/protocol/src/message/order_status.rs b/crates/protocol/src/message/order_status.rs index e5c2827f..b6128eec 100644 --- a/crates/protocol/src/message/order_status.rs +++ b/crates/protocol/src/message/order_status.rs @@ -22,9 +22,7 @@ impl OrderStatus { created_at: Utc::now(), }; - let data = OrderStatusData { - order_status, - }; + let data = OrderStatusData { order_status }; Ok(Message { metadata, @@ -42,8 +40,8 @@ impl OrderStatus { #[derive(Debug, Deserialize, PartialEq, Serialize)] #[serde(rename_all = "camelCase")] pub struct OrderStatusData { - /// Current status of Order that's being executed - order_status: String, + /// Current status of Order that's being executed + order_status: String, } #[cfg(test)] @@ -52,29 +50,30 @@ mod tests { #[test] fn can_create() { - let order_status: Message = OrderStatus::create( - "did:example:from_1234".to_string(), - "did:example:to_1234".to_string(), - MessageKind::Rfq.typesafe_id().unwrap(), - "COMPLETED".to_string() - ) - .expect("failed to create OrderStatus"); + let order_status: Message = OrderStatus::create( + "did:example:from_1234".to_string(), + "did:example:to_1234".to_string(), + MessageKind::Rfq.typesafe_id().unwrap(), + "COMPLETED".to_string(), + ) + .expect("failed to create OrderStatus"); - assert_eq!(order_status.metadata.id.type_prefix(), "orderstatus"); + assert_eq!(order_status.metadata.id.type_prefix(), "orderstatus"); } #[test] fn can_parse_order_status_from_json() { - let order_status = OrderStatus::create( - "did:example:from_1234".to_string(), - "did:example:to_1234".to_string(), - MessageKind::Rfq.typesafe_id().unwrap(), - "COMPLETED".to_string() - ) - .expect("Could not create OrderStatus"); - let json: String = serde_json::to_string(&order_status).expect("failed to serialize OrderStatus"); - let parsed_order_status: Message = - serde_json::from_str(&json).expect("failed to deserialize OrderStatus"); - assert_eq!(order_status, parsed_order_status); + let order_status = OrderStatus::create( + "did:example:from_1234".to_string(), + "did:example:to_1234".to_string(), + MessageKind::Rfq.typesafe_id().unwrap(), + "COMPLETED".to_string(), + ) + .expect("Could not create OrderStatus"); + let json: String = + serde_json::to_string(&order_status).expect("failed to serialize OrderStatus"); + let parsed_order_status: Message = + serde_json::from_str(&json).expect("failed to deserialize OrderStatus"); + assert_eq!(order_status, parsed_order_status); } } diff --git a/crates/protocol/src/message/quote.rs b/crates/protocol/src/message/quote.rs index 8ca193f3..6cbaa00c 100644 --- a/crates/protocol/src/message/quote.rs +++ b/crates/protocol/src/message/quote.rs @@ -73,7 +73,6 @@ pub struct PaymentInstructions { #[derive(Debug, Deserialize, PartialEq, Serialize)] #[skip_serializing_none] - #[serde(rename_all = "camelCase")] pub struct PaymentInstruction { /// Link or Instruction describing how to pay the PFI. diff --git a/crates/protocol/src/resource/mod.rs b/crates/protocol/src/resource/mod.rs index 092fac0d..667cff05 100644 --- a/crates/protocol/src/resource/mod.rs +++ b/crates/protocol/src/resource/mod.rs @@ -67,5 +67,7 @@ mod tests { let offering_id = ResourceKind::Offering.typesafe_id().unwrap(); assert!(offering_id.to_string().starts_with("offering_")); + + assert_eq!(0, 1) } } diff --git a/crates/protocol/src/test_data.rs b/crates/protocol/src/test_data.rs index c2c2c94d..2acc15e8 100644 --- a/crates/protocol/src/test_data.rs +++ b/crates/protocol/src/test_data.rs @@ -1,5 +1,7 @@ use crate::message::close::{Close, CloseData}; -use crate::message::quote::{Quote, QuoteData, QuoteDetails, PaymentInstructions, PaymentInstruction}; +use crate::message::quote::{ + PaymentInstruction, PaymentInstructions, Quote, QuoteData, QuoteDetails, +}; use crate::message::Message; use crate::resource::offering::{CurrencyDetails, Offering, OfferingData, PaymentMethod}; use crate::resource::Resource; From b807d938e6d7cb53eeda56491abae744c91fb0c0 Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Mon, 29 Apr 2024 09:36:51 -0400 Subject: [PATCH 09/14] Undo tmp test failure, test build failure --- crates/protocol/src/lib.rs | 2 ++ crates/protocol/src/resource/mod.rs | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/protocol/src/lib.rs b/crates/protocol/src/lib.rs index 3691a555..8b575806 100644 --- a/crates/protocol/src/lib.rs +++ b/crates/protocol/src/lib.rs @@ -1,5 +1,7 @@ pub mod message; pub mod resource; +hello + #[cfg(test)] pub mod test_data; diff --git a/crates/protocol/src/resource/mod.rs b/crates/protocol/src/resource/mod.rs index 667cff05..092fac0d 100644 --- a/crates/protocol/src/resource/mod.rs +++ b/crates/protocol/src/resource/mod.rs @@ -67,7 +67,5 @@ mod tests { let offering_id = ResourceKind::Offering.typesafe_id().unwrap(); assert!(offering_id.to_string().starts_with("offering_")); - - assert_eq!(0, 1) } } From b197f2e325083cb679a98288ed589cedab0fb061 Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Mon, 29 Apr 2024 09:39:10 -0400 Subject: [PATCH 10/14] Undo build failure test, fix linting --- crates/protocol/src/lib.rs | 2 -- crates/protocol/src/message/close.rs | 2 +- crates/protocol/src/message/order.rs | 2 +- crates/protocol/src/message/order_status.rs | 2 +- crates/protocol/src/resource/offering.rs | 15 ++++++--------- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/crates/protocol/src/lib.rs b/crates/protocol/src/lib.rs index 8b575806..3691a555 100644 --- a/crates/protocol/src/lib.rs +++ b/crates/protocol/src/lib.rs @@ -1,7 +1,5 @@ pub mod message; pub mod resource; -hello - #[cfg(test)] pub mod test_data; diff --git a/crates/protocol/src/message/close.rs b/crates/protocol/src/message/close.rs index 2a44bff5..d1494e61 100644 --- a/crates/protocol/src/message/close.rs +++ b/crates/protocol/src/message/close.rs @@ -19,7 +19,7 @@ impl Close { to, kind: MessageKind::Close, id: MessageKind::Close.typesafe_id()?, - exchange_id: exchange_id, + exchange_id, created_at: Utc::now(), }; diff --git a/crates/protocol/src/message/order.rs b/crates/protocol/src/message/order.rs index d283dc52..40c59c02 100644 --- a/crates/protocol/src/message/order.rs +++ b/crates/protocol/src/message/order.rs @@ -17,7 +17,7 @@ impl Order { to, kind: MessageKind::Order, id: MessageKind::Order.typesafe_id()?, - exchange_id: exchange_id, + exchange_id, created_at: Utc::now(), }; diff --git a/crates/protocol/src/message/order_status.rs b/crates/protocol/src/message/order_status.rs index b6128eec..ac49888b 100644 --- a/crates/protocol/src/message/order_status.rs +++ b/crates/protocol/src/message/order_status.rs @@ -18,7 +18,7 @@ impl OrderStatus { to, kind: MessageKind::OrderStatus, id: MessageKind::OrderStatus.typesafe_id()?, - exchange_id: exchange_id, + exchange_id, created_at: Utc::now(), }; diff --git a/crates/protocol/src/resource/offering.rs b/crates/protocol/src/resource/offering.rs index 0c9c7b23..11704bbd 100644 --- a/crates/protocol/src/resource/offering.rs +++ b/crates/protocol/src/resource/offering.rs @@ -82,15 +82,12 @@ pub struct PaymentMethod { impl PaymentMethod { pub fn required_payment_details_schema(&self) -> Option { - self.required_payment_details - .as_ref() - .map(|json| { - JSONSchema::options() - .with_draft(Draft::Draft7) - .compile(json) - .ok() - }) - .flatten() + self.required_payment_details.as_ref().and_then(|json| { + JSONSchema::options() + .with_draft(Draft::Draft7) + .compile(json) + .ok() + }) } } From 2fae1431b6ababb060b88a1846b71a49b44c2d65 Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Mon, 29 Apr 2024 09:41:33 -0400 Subject: [PATCH 11/14] Showcase windows-latest issue{ --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57895c3b..e2b5a44e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: test: strategy: matrix: - os: [ ubuntu-latest, macos-latest ] # TODO add back windows-latest + os: [ ubuntu-latest, macos-latest, windows-latest ] # TODO add back windows-latest rust: [ stable, nightly ] runs-on: ${{ matrix.os }} steps: From b8280c643015c856a21fa34efa32f82d90eb2e1c Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Mon, 29 Apr 2024 09:42:56 -0400 Subject: [PATCH 12/14] Prepare for PR --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2b5a44e..e685af48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: test: strategy: matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] # TODO add back windows-latest + os: [ ubuntu-latest, macos-latest ] # TODO add back windows-latest https://github.com/TBD54566975/tbdex-rs/issues/44 rust: [ stable, nightly ] runs-on: ${{ matrix.os }} steps: From e663952e3de70539fa042587123df30d9aa4904f Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Mon, 29 Apr 2024 09:45:11 -0400 Subject: [PATCH 13/14] Remove temporary branch inclusion for development --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e685af48..bdc83cfb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - kendall/github-ci # TODO remove! pull_request: branches: - '*' From a96f439442dbe4a3478f8e9e128e76e0304a9c50 Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Mon, 29 Apr 2024 10:03:02 -0400 Subject: [PATCH 14/14] Trigger CI for all PRs regardless of source and target branch --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bdc83cfb..3a16a018 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,8 +5,6 @@ on: branches: - main pull_request: - branches: - - '*' env: CARGO_TERM_COLOR: always