From d485d748b94659501d6d33c80cffa5dd05263b2a Mon Sep 17 00:00:00 2001 From: ndefokou Date: Fri, 15 Nov 2024 16:08:10 +0100 Subject: [PATCH 01/17] Improving CI workflow --- .github/workflows/rust.yml | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1b413c66..fda6a064 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,13 +1,19 @@ name: Rust CI -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: + branches: + - main env: CARGO_TERM_COLOR: always jobs: build: - name: Build and Test + name: Build, Test, and Lint runs-on: ubuntu-latest steps: @@ -35,14 +41,25 @@ jobs: rustflags: - name: Install Nextest test runner - uses: taiki-e/install-action@nextest + run: cargo install cargo-nextest - name: Create example env file run: | - chmod +x .github/scripts/test_config.sh - sh .github/scripts/test_config.sh + if [ -f .github/scripts/test_config.sh ]; then + chmod +x .github/scripts/test_config.sh + sh .github/scripts/test_config.sh + else + echo "No test_config.sh script found, skipping..." + fi - - name: Build and Run Test - run: | - cargo build --workspace --all-features - cargo nextest run --workspace --all-features + - name: Run Clippy (Lint) + run: cargo clippy --workspace --all-targets --all-features -- -D warnings + + - name: Check Formatting + run: cargo fmt --all -- --check + + - name: Build Project + run: cargo build --workspace --all-features + + - name: Run Tests + run: cargo nextest run --workspace --all-features From 2acad7db6c9ab96ea06fed460e9219e22c67352a Mon Sep 17 00:00:00 2001 From: ndefokou Date: Mon, 18 Nov 2024 12:39:21 +0100 Subject: [PATCH 02/17] Adding CD workflow --- .github/workflows/rust.yml | 46 +++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fda6a064..cd39fc58 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,4 +1,4 @@ -name: Rust CI +name: Rust CI/CD on: push: @@ -12,8 +12,9 @@ env: CARGO_TERM_COLOR: always jobs: - build: - name: Build, Test, and Lint + # Continuous Integration Job + ci: + name: Continuous Integration runs-on: ubuntu-latest steps: @@ -45,13 +46,8 @@ jobs: - name: Create example env file run: | - if [ -f .github/scripts/test_config.sh ]; then - chmod +x .github/scripts/test_config.sh - sh .github/scripts/test_config.sh - else - echo "No test_config.sh script found, skipping..." - fi - + chmod +x .github/scripts/test_config.sh + sh .github/scripts/test_config.sh - name: Run Clippy (Lint) run: cargo clippy --workspace --all-targets --all-features -- -D warnings @@ -63,3 +59,33 @@ jobs: - name: Run Tests run: cargo nextest run --workspace --all-features + + # Continuous Deployment Job + cd: + name: Continuous Deployment + needs: ci + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + + - name: Build Release + run: cargo build --release --workspace --all-features + + - name: Deploy to Production + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + HOST: ${{ secrets.PRODUCTION_HOST }} + USER: ${{ secrets.PRODUCTION_USER }} + run: | + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ssh_key + chmod 600 ssh_key + scp -i ssh_key target/release/your_binary ${{ env.USER }}@${{ env.HOST }}:/path/to/your/binary + ssh -i ssh_key ${{ env.USER }}@${{ env.HOST }} 'systemctl restart your-service' + rm -f ssh_key From 64cb6645a82f6f04787aeb824d48e369932ed79a Mon Sep 17 00:00:00 2001 From: ndefokou Date: Mon, 18 Nov 2024 13:56:04 +0100 Subject: [PATCH 03/17] Adding CD workflow --- .github/workflows/rust.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cd39fc58..da706b8e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -48,8 +48,6 @@ jobs: run: | chmod +x .github/scripts/test_config.sh sh .github/scripts/test_config.sh - - name: Run Clippy (Lint) - run: cargo clippy --workspace --all-targets --all-features -- -D warnings - name: Check Formatting run: cargo fmt --all -- --check From cb9118033e3be00fe80f6fc949e01c9c65f64e8e Mon Sep 17 00:00:00 2001 From: ndefokou Date: Mon, 18 Nov 2024 14:14:26 +0100 Subject: [PATCH 04/17] Formatting the project for pipeline to pass --- crates/filesystem/src/lib.rs | 9 ++++++-- crates/web-plugins/did-endpoint/src/didgen.rs | 5 ++++- crates/web-plugins/did-endpoint/src/plugin.rs | 2 +- .../did-utils/src/methods/peer/method.rs | 21 +++++++------------ .../did-utils/src/methods/peer/util.rs | 2 +- .../protocols/forward/src/web/routing.rs | 9 ++++++-- .../src/web/handler/mod.rs | 2 +- .../protocols/pickup/src/model.rs | 12 +++++++---- .../didcomm-messaging/shared/src/utils.rs | 12 +++-------- .../didcomm-messaging/src/manager.rs | 0 .../didcomm-messaging/src/midlw.rs | 10 ++------- .../didcomm-messaging/src/protocols.rs | 0 12 files changed, 41 insertions(+), 43 deletions(-) delete mode 100644 crates/web-plugins/didcomm-messaging/src/manager.rs delete mode 100644 crates/web-plugins/didcomm-messaging/src/protocols.rs diff --git a/crates/filesystem/src/lib.rs b/crates/filesystem/src/lib.rs index b90d116e..f208acc9 100644 --- a/crates/filesystem/src/lib.rs +++ b/crates/filesystem/src/lib.rs @@ -112,11 +112,16 @@ mod tests { impl FileSystem for MockFileSystem { fn read_to_string(&self, path: &Path) -> IoResult { - Ok(self.map.get(path.to_str().unwrap()).cloned().unwrap_or_default()) + Ok(self + .map + .get(path.to_str().unwrap()) + .cloned() + .unwrap_or_default()) } fn write(&mut self, path: &Path, content: &str) -> IoResult<()> { - self.map.insert(path.to_str().unwrap().to_string(), content.to_string()); + self.map + .insert(path.to_str().unwrap().to_string(), content.to_string()); Ok(()) } diff --git a/crates/web-plugins/did-endpoint/src/didgen.rs b/crates/web-plugins/did-endpoint/src/didgen.rs index a9cbf87b..0a18fe9d 100644 --- a/crates/web-plugins/did-endpoint/src/didgen.rs +++ b/crates/web-plugins/did-endpoint/src/didgen.rs @@ -192,7 +192,10 @@ where // Validate the keys in the DID document if let Some(verification_methods) = &diddoc.verification_method { for method in verification_methods { - let pubkey = method.public_key.as_ref().ok_or(String::from("Missing key"))?; + let pubkey = method + .public_key + .as_ref() + .ok_or(String::from("Missing key"))?; let kid = util::handle_vm_id(&method.id, &diddoc); match pubkey { KeyFormat::Jwk(_) => validate_key(&kid, keystore)?, diff --git a/crates/web-plugins/did-endpoint/src/plugin.rs b/crates/web-plugins/did-endpoint/src/plugin.rs index 26a8e26e..50d93b6d 100644 --- a/crates/web-plugins/did-endpoint/src/plugin.rs +++ b/crates/web-plugins/did-endpoint/src/plugin.rs @@ -1,10 +1,10 @@ use super::{didgen, web}; use axum::Router; use database::Repository; +use filesystem::FileSystem; use keystore::Secrets; use plugin_api::{Plugin, PluginError}; use std::sync::{Arc, Mutex}; -use filesystem::FileSystem; #[derive(Default)] pub struct DidEndpoint { diff --git a/crates/web-plugins/didcomm-messaging/did-utils/src/methods/peer/method.rs b/crates/web-plugins/didcomm-messaging/did-utils/src/methods/peer/method.rs index 5b1f1970..a6200075 100644 --- a/crates/web-plugins/didcomm-messaging/did-utils/src/methods/peer/method.rs +++ b/crates/web-plugins/didcomm-messaging/did-utils/src/methods/peer/method.rs @@ -227,13 +227,12 @@ impl DidPeer { } match did { - s if s.starts_with("did:peer:0") => self.expand_did_peer_0(did).map_err(Into::into), - s if s.starts_with("did:peer:2") => self.expand_did_peer_2(did).map_err(Into::into), - s if s.starts_with("did:peer:4") => self.expand_did_peer_4(did).map_err(Into::into), - _ => Err(DIDResolutionError::MethodNotSupported), + s if s.starts_with("did:peer:0") => self.expand_did_peer_0(did).map_err(Into::into), + s if s.starts_with("did:peer:2") => self.expand_did_peer_2(did).map_err(Into::into), + s if s.starts_with("did:peer:4") => self.expand_did_peer_4(did).map_err(Into::into), + _ => Err(DIDResolutionError::MethodNotSupported), + } } -} - /// Expands did:peer:0 address /// @@ -814,10 +813,7 @@ mod tests { let did_method = DidPeer::default(); let did = "did:peer:1zQmbEB1EqP7PnNVaHiSpXhkatAA6kNyQK9mWkvrMx2eckgq"; - assert!(matches!( - did_method.expand(did).unwrap_err(), - DIDResolutionError::MethodNotSupported - )); + assert!(matches!(did_method.expand(did).unwrap_err(), DIDResolutionError::MethodNotSupported)); } #[test] @@ -983,10 +979,7 @@ mod tests { fn test_expand_did_peer_0_fails_on_too_long_did() { let did_method = DidPeer::default(); let did = "did:peer:0zQebt6zPwbE4Vw5GFAjjARHrNXFALofERVv4q6Z4db8cnDRQm"; - assert!(matches!( - did_method.expand(did).unwrap_err(), - DIDResolutionError::InvalidPublicKeyLength - )); + assert!(matches!(did_method.expand(did).unwrap_err(), DIDResolutionError::InvalidPublicKeyLength)); } #[test] diff --git a/crates/web-plugins/didcomm-messaging/did-utils/src/methods/peer/util.rs b/crates/web-plugins/didcomm-messaging/did-utils/src/methods/peer/util.rs index e5cfc558..03eb7be2 100644 --- a/crates/web-plugins/didcomm-messaging/did-utils/src/methods/peer/util.rs +++ b/crates/web-plugins/didcomm-messaging/did-utils/src/methods/peer/util.rs @@ -1,6 +1,6 @@ use super::errors::DIDPeerMethodError; use crate::didcore::Document as DIDDocument; -use crate::didcore::{VerificationMethodType, Service}; +use crate::didcore::{Service, VerificationMethodType}; use serde_json::{json, Map, Value}; pub(super) fn abbreviate_service_for_did_peer_2(service: &Service) -> Result { diff --git a/crates/web-plugins/didcomm-messaging/protocols/forward/src/web/routing.rs b/crates/web-plugins/didcomm-messaging/protocols/forward/src/web/routing.rs index 999400a6..b841b1a0 100644 --- a/crates/web-plugins/didcomm-messaging/protocols/forward/src/web/routing.rs +++ b/crates/web-plugins/didcomm-messaging/protocols/forward/src/web/routing.rs @@ -32,7 +32,10 @@ async fn checks( Ok(next.unwrap().to_string()) } -pub(crate) async fn handler(state: Arc, message: Message) -> Result, ForwardError> { +pub(crate) async fn handler( + state: Arc, + message: Message, +) -> Result, ForwardError> { let AppStateRepository { message_repository, connection_repository, @@ -163,7 +166,9 @@ mod test { .await .expect("Unable unpack"); - let msg = mediator_forward_process(Arc::new(state.clone()), msg).await.unwrap(); + let msg = mediator_forward_process(Arc::new(state.clone()), msg) + .await + .unwrap(); println!("Mediator1 is forwarding message \n{:?}\n", msg); } diff --git a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/web/handler/mod.rs b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/web/handler/mod.rs index 71ce846d..8cba1dcf 100644 --- a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/web/handler/mod.rs +++ b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/web/handler/mod.rs @@ -1,6 +1,6 @@ +mod midlw; #[cfg(feature = "stateful")] pub mod stateful; -mod midlw; #[cfg(feature = "stateless")] mod stateless; diff --git a/crates/web-plugins/didcomm-messaging/protocols/pickup/src/model.rs b/crates/web-plugins/didcomm-messaging/protocols/pickup/src/model.rs index c2ebe66f..76d71116 100644 --- a/crates/web-plugins/didcomm-messaging/protocols/pickup/src/model.rs +++ b/crates/web-plugins/didcomm-messaging/protocols/pickup/src/model.rs @@ -82,7 +82,7 @@ pub(crate) struct LiveDeliveryChange<'a> { pub(crate) id: &'a str, pub(crate) pthid: &'a str, - + #[serde(rename = "type")] pub(crate) type_: &'a str, @@ -110,7 +110,7 @@ impl<'a> From> for MessageBuilder { #[cfg(test)] mod tests { use super::*; - use didcomm::{MessageBuilder, Attachment}; + use didcomm::{Attachment, MessageBuilder}; use serde_json::{json, Value}; #[test] @@ -148,12 +148,16 @@ mod tests { let id = "12345"; let thid = "67890"; let type_ = "https://didcomm.org/messagepickup/3.0/delivery-response"; - let attachment = Attachment::json(json!({"key": "value"})).id("123".to_owned()).finalize(); + let attachment = Attachment::json(json!({"key": "value"})) + .id("123".to_owned()) + .finalize(); let response = DeliveryResponse { id, thid, type_, - body: BodyDeliveryResponse { recipient_did: None }, + body: BodyDeliveryResponse { + recipient_did: None, + }, attachments: vec![attachment.clone()], }; diff --git a/crates/web-plugins/didcomm-messaging/shared/src/utils.rs b/crates/web-plugins/didcomm-messaging/shared/src/utils.rs index ab908e18..af375177 100644 --- a/crates/web-plugins/didcomm-messaging/shared/src/utils.rs +++ b/crates/web-plugins/didcomm-messaging/shared/src/utils.rs @@ -2,7 +2,7 @@ pub mod resolvers; pub mod tests_utils; use did_utils::{ - didcore::{VerificationMethodType, Document, KeyFormat, VerificationMethod}, + didcore::{Document, KeyFormat, VerificationMethod, VerificationMethodType}, jwk::Jwk, }; use filesystem::FileSystem; @@ -104,10 +104,7 @@ mod tests { ) .unwrap(); - assert_eq!( - vm_id, - "#key-2" - ); + assert_eq!(vm_id, "#key-2"); assert_eq!( json_canon::to_string(&jwk).unwrap(), json_canon::to_string(&expected_jwk).unwrap() @@ -128,10 +125,7 @@ mod tests { ) .unwrap(); - assert_eq!( - vm_id, - "#key-1" - ); + assert_eq!(vm_id, "#key-1"); assert_eq!( json_canon::to_string(&jwk).unwrap(), json_canon::to_string(&expected_jwk).unwrap() diff --git a/crates/web-plugins/didcomm-messaging/src/manager.rs b/crates/web-plugins/didcomm-messaging/src/manager.rs deleted file mode 100644 index e69de29b..00000000 diff --git a/crates/web-plugins/didcomm-messaging/src/midlw.rs b/crates/web-plugins/didcomm-messaging/src/midlw.rs index 055e0395..037b6813 100644 --- a/crates/web-plugins/didcomm-messaging/src/midlw.rs +++ b/crates/web-plugins/didcomm-messaging/src/midlw.rs @@ -38,10 +38,7 @@ pub async fn unpack_didcomm_message( let bytes = match hyper::body::to_bytes(body).await { Ok(bytes) => bytes, Err(_) => { - let response = ( - StatusCode::BAD_REQUEST, - Error::UnparseablePayload.json(), - ); + let response = (StatusCode::BAD_REQUEST, Error::UnparseablePayload.json()); return response.into_response(); } @@ -133,10 +130,7 @@ async fn unpack_payload( } if plain_message.from.is_none() || !metadata.authenticated || metadata.anonymous_sender { - let response = ( - StatusCode::BAD_REQUEST, - Error::AnonymousPacker.json(), - ); + let response = (StatusCode::BAD_REQUEST, Error::AnonymousPacker.json()); return Err(response.into_response()); } diff --git a/crates/web-plugins/didcomm-messaging/src/protocols.rs b/crates/web-plugins/didcomm-messaging/src/protocols.rs deleted file mode 100644 index e69de29b..00000000 From eaa55e22a3b303d4a5533f4921022036edd43106 Mon Sep 17 00:00:00 2001 From: ndefokou Date: Mon, 18 Nov 2024 14:17:59 +0100 Subject: [PATCH 05/17] Formatting the project for pipeline to pass --- crates/web-plugins/didcomm-messaging/src/lib.rs | 2 -- src/plugins.rs | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/web-plugins/didcomm-messaging/src/lib.rs b/crates/web-plugins/didcomm-messaging/src/lib.rs index 2c16146f..eb70cd10 100644 --- a/crates/web-plugins/didcomm-messaging/src/lib.rs +++ b/crates/web-plugins/didcomm-messaging/src/lib.rs @@ -1,8 +1,6 @@ mod did_rotation; mod error; -mod manager; mod midlw; -mod protocols; mod web; pub mod plugin; diff --git a/src/plugins.rs b/src/plugins.rs index d8e9ea98..75f75937 100644 --- a/src/plugins.rs +++ b/src/plugins.rs @@ -18,6 +18,8 @@ lazy_static! { #[cfg(feature = "plugin-oob_messages")] Arc::new(Mutex::new(oob_messages::plugin::OOBMessages {})), #[cfg(feature = "plugin-didcomm_messaging")] - Arc::new(Mutex::new(didcomm_messaging::plugin::MediatorCoordination::default())), + Arc::new(Mutex::new( + didcomm_messaging::plugin::MediatorCoordination::default() + )), ]; } From fdfc43932c020f81625872a9928e4ca9d39573dd Mon Sep 17 00:00:00 2001 From: ndefokou Date: Mon, 18 Nov 2024 14:26:20 +0100 Subject: [PATCH 06/17] Removing un used condition --- crates/web-plugins/didcomm-messaging/did-utils/src/jwk/prm.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/web-plugins/didcomm-messaging/did-utils/src/jwk/prm.rs b/crates/web-plugins/didcomm-messaging/did-utils/src/jwk/prm.rs index 569a12ac..bcf8eb84 100644 --- a/crates/web-plugins/didcomm-messaging/did-utils/src/jwk/prm.rs +++ b/crates/web-plugins/didcomm-messaging/did-utils/src/jwk/prm.rs @@ -27,7 +27,6 @@ pub struct Parameters { /// The URL of the X.509 certificate associated with this key. #[serde(skip_serializing_if = "Option::is_none", default)] - #[cfg(feature = "url")] pub x5u: Option, /// The X.509 certificate associated with this key. From da28b9342f4d665493693e4c311ddde13b9b6aeb Mon Sep 17 00:00:00 2001 From: ndefokou Date: Mon, 18 Nov 2024 14:37:50 +0100 Subject: [PATCH 07/17] adding stateless in the cargo.toml --- .../didcomm-messaging/protocols/mediator-coordination/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml index 983550f0..805759d1 100644 --- a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml +++ b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml @@ -34,3 +34,4 @@ shared = { workspace = true, features = ["test-utils"] } [features] default = ["stateful"] stateful = [] +stateless = [] From 3a7c11d2e7aa418876c79434fe6ee3cd5b8c5f38 Mon Sep 17 00:00:00 2001 From: ndefokou Date: Mon, 18 Nov 2024 14:43:23 +0100 Subject: [PATCH 08/17] removing stateless in the cargo.toml --- .../didcomm-messaging/protocols/mediator-coordination/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml index 805759d1..983550f0 100644 --- a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml +++ b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml @@ -34,4 +34,3 @@ shared = { workspace = true, features = ["test-utils"] } [features] default = ["stateful"] stateful = [] -stateless = [] From 3642b3b739aaf659aab18284ff784762f5de713f Mon Sep 17 00:00:00 2001 From: ndefokou Date: Mon, 18 Nov 2024 14:57:00 +0100 Subject: [PATCH 09/17] adding conditions --- .../protocols/mediator-coordination/src/model/coord.rs | 3 +++ .../protocols/mediator-coordination/src/model/mod.rs | 1 + .../protocols/mediator-coordination/src/web/handler/mod.rs | 1 + 3 files changed, 5 insertions(+) diff --git a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/coord.rs b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/coord.rs index eb4288a0..fc835929 100644 --- a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/coord.rs +++ b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/coord.rs @@ -2,6 +2,7 @@ use serde::{de::Error, Deserialize, Deserializer, Serialize}; use shared::constants::MEDIATE_REQUEST_2_0; +#[allow(unexpected_cfgs)] #[cfg(feature = "stateless")] use super::stateless::coord::MediationRequest as StatelessMediationRequest; @@ -17,12 +18,14 @@ pub enum MediationRequest { Stateful(StatefulMediationRequest), /// Format for stateless mode over DICs + #[allow(unexpected_cfgs)] #[cfg(feature = "stateless")] #[serde(deserialize_with = "MediationRequest::deserialize_stateless_variant")] Stateless(StatelessMediationRequest), } impl MediationRequest { + #[allow(unexpected_cfgs)] #[cfg(feature = "stateless")] fn deserialize_stateless_variant<'de, D>( deserializer: D, diff --git a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/mod.rs b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/mod.rs index 674fb3e8..1ab7a2fa 100644 --- a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/mod.rs +++ b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/mod.rs @@ -1,5 +1,6 @@ pub mod coord; #[cfg(feature = "stateful")] pub mod stateful; +#[allow(unexpected_cfgs)] #[cfg(feature = "stateless")] pub mod stateless; diff --git a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/web/handler/mod.rs b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/web/handler/mod.rs index 8cba1dcf..a56ed3c3 100644 --- a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/web/handler/mod.rs +++ b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/web/handler/mod.rs @@ -2,5 +2,6 @@ mod midlw; #[cfg(feature = "stateful")] pub mod stateful; +#[allow(unexpected_cfgs)] #[cfg(feature = "stateless")] mod stateless; From 33ed47b4e8b394b8c153b9715280b247b305c5b7 Mon Sep 17 00:00:00 2001 From: ndefokou Date: Mon, 18 Nov 2024 14:59:50 +0100 Subject: [PATCH 10/17] adding conditions --- .../protocols/mediator-coordination/src/model/coord.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/coord.rs b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/coord.rs index fc835929..6b5af70a 100644 --- a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/coord.rs +++ b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/coord.rs @@ -18,7 +18,7 @@ pub enum MediationRequest { Stateful(StatefulMediationRequest), /// Format for stateless mode over DICs - #[allow(unexpected_cfgs)] + #[allow(unexpected_cfgs)] #[cfg(feature = "stateless")] #[serde(deserialize_with = "MediationRequest::deserialize_stateless_variant")] Stateless(StatelessMediationRequest), From 0a5b0f2756f7697b14f48d5a4636ea1bc7b0c8b3 Mon Sep 17 00:00:00 2001 From: ndefokou Date: Mon, 18 Nov 2024 15:04:58 +0100 Subject: [PATCH 11/17] adding stateless in the cargo.toml --- .../didcomm-messaging/protocols/mediator-coordination/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml index 983550f0..805759d1 100644 --- a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml +++ b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml @@ -34,3 +34,4 @@ shared = { workspace = true, features = ["test-utils"] } [features] default = ["stateful"] stateful = [] +stateless = [] From 05f8b02f162b1e88b5b48c0053bd75906a5b8d8e Mon Sep 17 00:00:00 2001 From: ndefokou Date: Mon, 18 Nov 2024 15:16:08 +0100 Subject: [PATCH 12/17] removing stateless in the cargo.toml --- .../protocols/mediator-coordination/Cargo.toml | 1 - .../protocols/mediator-coordination/src/model/coord.rs | 3 --- 2 files changed, 4 deletions(-) diff --git a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml index 805759d1..983550f0 100644 --- a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml +++ b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/Cargo.toml @@ -34,4 +34,3 @@ shared = { workspace = true, features = ["test-utils"] } [features] default = ["stateful"] stateful = [] -stateless = [] diff --git a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/coord.rs b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/coord.rs index 6b5af70a..eb4288a0 100644 --- a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/coord.rs +++ b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/coord.rs @@ -2,7 +2,6 @@ use serde::{de::Error, Deserialize, Deserializer, Serialize}; use shared::constants::MEDIATE_REQUEST_2_0; -#[allow(unexpected_cfgs)] #[cfg(feature = "stateless")] use super::stateless::coord::MediationRequest as StatelessMediationRequest; @@ -18,14 +17,12 @@ pub enum MediationRequest { Stateful(StatefulMediationRequest), /// Format for stateless mode over DICs - #[allow(unexpected_cfgs)] #[cfg(feature = "stateless")] #[serde(deserialize_with = "MediationRequest::deserialize_stateless_variant")] Stateless(StatelessMediationRequest), } impl MediationRequest { - #[allow(unexpected_cfgs)] #[cfg(feature = "stateless")] fn deserialize_stateless_variant<'de, D>( deserializer: D, From e5a2212d253be689128e32111369fd390360aa45 Mon Sep 17 00:00:00 2001 From: ndefokou Date: Tue, 19 Nov 2024 10:18:22 +0100 Subject: [PATCH 13/17] removing stateless in the cargo.toml --- .../protocols/mediator-coordination/src/model/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/mod.rs b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/mod.rs index 1ab7a2fa..3296b1fe 100644 --- a/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/mod.rs +++ b/crates/web-plugins/didcomm-messaging/protocols/mediator-coordination/src/model/mod.rs @@ -1,6 +1,6 @@ pub mod coord; #[cfg(feature = "stateful")] pub mod stateful; -#[allow(unexpected_cfgs)] + #[cfg(feature = "stateless")] pub mod stateless; From 9434d65814927f8b314483b6cdbb99ad66c6dc2b Mon Sep 17 00:00:00 2001 From: ndefokou Date: Wed, 20 Nov 2024 00:20:22 +0100 Subject: [PATCH 14/17] Adding CD on the worklow --- .github/workflows/CD.yml | 21 +++++++++++++++ .github/workflows/{rust.yml => CI.yml} | 36 +++----------------------- 2 files changed, 24 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/CD.yml rename .github/workflows/{rust.yml => CI.yml} (56%) diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml new file mode 100644 index 00000000..84893f6b --- /dev/null +++ b/.github/workflows/CD.yml @@ -0,0 +1,21 @@ +name: CD + +on: + workflow_run: + workflows: ["Rust CI Pipeline"] # Trigger on successful CI completion + types: + - completed +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Rust + uses: actions/setup-rust@v1 + with: + rust-version: stable + + # Deploy to AWS EC2 Or another instance \ No newline at end of file diff --git a/.github/workflows/rust.yml b/.github/workflows/CI.yml similarity index 56% rename from .github/workflows/rust.yml rename to .github/workflows/CI.yml index da706b8e..288a337b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/CI.yml @@ -1,4 +1,4 @@ -name: Rust CI/CD +name: Rust CI on: push: @@ -12,9 +12,9 @@ env: CARGO_TERM_COLOR: always jobs: - # Continuous Integration Job + ci: - name: Continuous Integration + name: Build and test runs-on: ubuntu-latest steps: @@ -57,33 +57,3 @@ jobs: - name: Run Tests run: cargo nextest run --workspace --all-features - - # Continuous Deployment Job - cd: - name: Continuous Deployment - needs: ci - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Rust - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: stable - - - name: Build Release - run: cargo build --release --workspace --all-features - - - name: Deploy to Production - env: - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - HOST: ${{ secrets.PRODUCTION_HOST }} - USER: ${{ secrets.PRODUCTION_USER }} - run: | - echo "${{ secrets.SSH_PRIVATE_KEY }}" > ssh_key - chmod 600 ssh_key - scp -i ssh_key target/release/your_binary ${{ env.USER }}@${{ env.HOST }}:/path/to/your/binary - ssh -i ssh_key ${{ env.USER }}@${{ env.HOST }} 'systemctl restart your-service' - rm -f ssh_key From e0c1d5856d98eafbdd84d8d887d0cd1c44c28bbe Mon Sep 17 00:00:00 2001 From: ndefokou Date: Thu, 21 Nov 2024 11:38:00 +0100 Subject: [PATCH 15/17] fixe(): CI and CD --- .github/workflows/CD.yml | 13 ++++++------- .github/workflows/CI.yml | 8 +------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml index 84893f6b..a59e9d7c 100644 --- a/.github/workflows/CD.yml +++ b/.github/workflows/CD.yml @@ -1,13 +1,12 @@ -name: CD +name: CD on: - workflow_run: - workflows: ["Rust CI Pipeline"] # Trigger on successful CI completion - types: - - completed + push: + branches: [main] + jobs: deploy: - runs-on: ubuntu-latest + runs-on: ubuntu-latest steps: - name: Checkout code @@ -18,4 +17,4 @@ jobs: with: rust-version: stable - # Deploy to AWS EC2 Or another instance \ No newline at end of file + # Deploy to AWS EC2 Or another instance diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 288a337b..e900c28f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,12 +1,6 @@ name: Rust CI -on: - push: - branches: - - main - pull_request: - branches: - - main +on:[push, pull_request] env: CARGO_TERM_COLOR: always From d0bbd65ad40a8d8259c0073c52943a59444c50a5 Mon Sep 17 00:00:00 2001 From: ndefokou Date: Thu, 21 Nov 2024 12:58:52 +0100 Subject: [PATCH 16/17] fixe(): CI --- .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 e900c28f..298a2ed6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,6 +1,6 @@ name: Rust CI -on:[push, pull_request] +on:[pull_request] env: CARGO_TERM_COLOR: always From 273019b16c6eb76729e909386f0ee3c1e3602193 Mon Sep 17 00:00:00 2001 From: ndefokou Date: Thu, 21 Nov 2024 16:09:17 +0100 Subject: [PATCH 17/17] fixe(): CI --- .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 298a2ed6..44c0a12a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -36,7 +36,7 @@ jobs: rustflags: - name: Install Nextest test runner - run: cargo install cargo-nextest + uses: taiki-e/install-action@nextest - name: Create example env file run: |