From 13ac18018abf47d489e76a80885c2a9dfeee6ec3 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Fri, 12 May 2023 09:52:00 +0200 Subject: [PATCH 01/19] Split publish_local_revocations in BaseAnoncreds Signed-off-by: Miroslav Kovar --- aries_vcx/src/common/anoncreds.rs | 6 +-- aries_vcx/src/common/credentials/mod.rs | 5 ++- .../common/primitives/revocation_registry.rs | 35 +++++++++++++++-- aries_vcx/src/common/test_utils.rs | 4 +- .../src/core/profile/vdrtools_profile.rs | 2 +- .../utils/mockdata/profile/mock_anoncreds.rs | 8 +++- .../tests/test_creds_proofs_revocations.rs | 24 ++++++------ aries_vcx/tests/utils/scenarios.rs | 16 ++++---- .../src/anoncreds/base_anoncreds.rs | 5 ++- .../src/anoncreds/credx_anoncreds.rs | 9 +++-- .../src/anoncreds/indy_anoncreds.rs | 24 +++++------- .../indy/primitives/revocation_registry.rs | 38 ++----------------- .../api_vcx/api_handle/revocation_registry.rs | 9 ++--- 13 files changed, 93 insertions(+), 92 deletions(-) diff --git a/aries_vcx/src/common/anoncreds.rs b/aries_vcx/src/common/anoncreds.rs index 7fff8f5028..7648a5af6c 100644 --- a/aries_vcx/src/common/anoncreds.rs +++ b/aries_vcx/src/common/anoncreds.rs @@ -63,7 +63,7 @@ pub mod integration_tests { SetupProfile::run_indy(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; - let (_, _, _, _, _, _, _, _, rev_reg_id, cred_rev_id, _) = create_and_store_credential( + let (_, _, _, _, _, _, _, _, rev_reg_id, cred_rev_id, _, rev_reg) = create_and_store_credential( &setup.profile, &holder_setup.profile, &setup.institution_did, @@ -93,8 +93,8 @@ pub mod integration_tests { .await .unwrap(); - anoncreds - .publish_local_revocations(&setup.institution_did, &rev_reg_id) + rev_reg + .publish_local_revocations(&setup.profile, &setup.institution_did) .await .unwrap(); diff --git a/aries_vcx/src/common/credentials/mod.rs b/aries_vcx/src/common/credentials/mod.rs index 6a922981bb..c61bd5a8c3 100644 --- a/aries_vcx/src/common/credentials/mod.rs +++ b/aries_vcx/src/common/credentials/mod.rs @@ -121,6 +121,7 @@ mod integration_tests { let rev_reg_id = res.8; let cred_rev_id = res.9; let tails_file = res.10; + let rev_reg = res.11; assert!(!is_cred_revoked(&holder_setup.profile, &rev_reg_id, &cred_rev_id) .await @@ -132,8 +133,8 @@ mod integration_tests { .revoke_credential_local(&tails_file, &rev_reg_id, &cred_rev_id) .await .unwrap(); - anoncreds - .publish_local_revocations(&setup.institution_did, &rev_reg_id) + rev_reg + .publish_local_revocations(&setup.profile, &setup.institution_did) .await .unwrap(); diff --git a/aries_vcx/src/common/primitives/revocation_registry.rs b/aries_vcx/src/common/primitives/revocation_registry.rs index adfb35b14a..107d2769bd 100644 --- a/aries_vcx/src/common/primitives/revocation_registry.rs +++ b/aries_vcx/src/common/primitives/revocation_registry.rs @@ -196,11 +196,38 @@ impl RevocationRegistry { pub async fn publish_local_revocations(&self, profile: &Arc, submitter_did: &str) -> VcxResult<()> { let anoncreds = Arc::clone(profile).inject_anoncreds(); + let ledger = Arc::clone(profile).inject_ledger(); - anoncreds - .publish_local_revocations(submitter_did, &self.rev_reg_id) - .await - .map_err(|err| err.into()) + if let Some(delta) = anoncreds.get_rev_reg_delta(&self.rev_reg_id).await? { + ledger + .publish_rev_reg_delta(&self.rev_reg_id, &delta, submitter_did) + .await?; + + info!( + "publish_local_revocations >>> rev_reg_delta published for rev_reg_id {}", + self.rev_reg_id + ); + + match anoncreds.clear_rev_reg_delta(&self.rev_reg_id).await { + Ok(_) => { + info!( + "publish_local_revocations >>> rev_reg_delta storage cleared for rev_reg_id {}", + self.rev_reg_id + ); + Ok(()) + } + Err(err) => Err(AriesVcxError::from_msg( + AriesVcxErrorKind::RevDeltaFailedToClear, + format!( + "Failed to clear revocation delta storage for rev_reg_id: {}, error: {err}", + self.rev_reg_id + ), + )), + } + } else { + Err(AriesVcxError::from_msg(AriesVcxErrorKind::RevDeltaNotFound, + format!("Failed to publish revocation delta for revocation registry {}, no delta found. Possibly already published?", self.rev_reg_id))) + } } } diff --git a/aries_vcx/src/common/test_utils.rs b/aries_vcx/src/common/test_utils.rs index b2139779dd..ced9a42187 100644 --- a/aries_vcx/src/common/test_utils.rs +++ b/aries_vcx/src/common/test_utils.rs @@ -167,8 +167,9 @@ pub async fn create_and_store_credential( String, String, String, + RevocationRegistry, ) { - let (schema_id, schema_json, cred_def_id, cred_def_json, rev_reg_id, _, _) = + let (schema_id, schema_json, cred_def_id, cred_def_json, rev_reg_id, _, rev_reg) = create_and_store_credential_def(issuer, institution_did, attr_list).await; let (offer, req, req_meta) = @@ -210,6 +211,7 @@ pub async fn create_and_store_credential( rev_reg_id, cred_rev_id.unwrap(), tails_file, + rev_reg, ) } diff --git a/aries_vcx/src/core/profile/vdrtools_profile.rs b/aries_vcx/src/core/profile/vdrtools_profile.rs index 3b2d823b27..5c0bddc415 100644 --- a/aries_vcx/src/core/profile/vdrtools_profile.rs +++ b/aries_vcx/src/core/profile/vdrtools_profile.rs @@ -20,7 +20,7 @@ impl VdrtoolsProfile { pub fn new(indy_wallet_handle: WalletHandle, indy_pool_handle: PoolHandle) -> Self { let wallet = Arc::new(IndySdkWallet::new(indy_wallet_handle)); let ledger = Arc::new(IndySdkLedger::new(indy_wallet_handle, indy_pool_handle)); - let anoncreds = Arc::new(IndySdkAnonCreds::new(indy_wallet_handle, indy_pool_handle)); + let anoncreds = Arc::new(IndySdkAnonCreds::new(indy_wallet_handle)); VdrtoolsProfile { wallet, ledger, diff --git a/aries_vcx/src/utils/mockdata/profile/mock_anoncreds.rs b/aries_vcx/src/utils/mockdata/profile/mock_anoncreds.rs index fcb20154cb..9c441fe651 100644 --- a/aries_vcx/src/utils/mockdata/profile/mock_anoncreds.rs +++ b/aries_vcx/src/utils/mockdata/profile/mock_anoncreds.rs @@ -5,7 +5,7 @@ use crate::{ global::settings, utils::{ self, - constants::{LARGE_NONCE, LIBINDY_CRED_OFFER, REV_STATE_JSON}, + constants::{LARGE_NONCE, LIBINDY_CRED_OFFER, REV_REG_DELTA_JSON, REV_STATE_JSON}, mockdata::mock_settings::get_mock_creds_retrieved_for_proof_request, }, }; @@ -186,7 +186,11 @@ impl BaseAnonCreds for MockAnoncreds { Ok(()) } - async fn publish_local_revocations(&self, _submitter_did: &str, _rev_reg_id: &str) -> VcxCoreResult<()> { + async fn get_rev_reg_delta(&self, _rev_reg_id: &str) -> VcxCoreResult> { + Ok(Some(REV_REG_DELTA_JSON.to_string())) + } + + async fn clear_rev_reg_delta(&self, _rev_reg_id: &str) -> VcxCoreResult<()> { Ok(()) } diff --git a/aries_vcx/tests/test_creds_proofs_revocations.rs b/aries_vcx/tests/test_creds_proofs_revocations.rs index f1a18c3ef4..5bdd4719c6 100644 --- a/aries_vcx/tests/test_creds_proofs_revocations.rs +++ b/aries_vcx/tests/test_creds_proofs_revocations.rs @@ -48,7 +48,7 @@ mod integration_tests { let time_before_revocation = time::OffsetDateTime::now_utc().unix_timestamp() as u64; info!("test_basic_revocation :: verifier :: Going to revoke credential"); - revoke_credential_and_publish_accumulator(&mut institution, &issuer_credential, &rev_reg.rev_reg_id).await; + revoke_credential_and_publish_accumulator(&mut institution, &issuer_credential, &rev_reg).await; tokio::time::sleep(Duration::from_millis(1000)).await; let time_after_revocation = time::OffsetDateTime::now_utc().unix_timestamp() as u64; @@ -121,7 +121,7 @@ mod integration_tests { assert!(!issuer_credential.is_revoked(&institution.profile).await.unwrap()); info!("test_revocation_notification :: verifier :: Going to revoke credential"); - revoke_credential_and_publish_accumulator(&mut institution, &issuer_credential, &rev_reg.rev_reg_id).await; + revoke_credential_and_publish_accumulator(&mut institution, &issuer_credential, &rev_reg).await; tokio::time::sleep(Duration::from_millis(1000)).await; assert!(issuer_credential.is_revoked(&institution.profile).await.unwrap()); @@ -206,7 +206,7 @@ mod integration_tests { assert!(!issuer_credential.is_revoked(&institution.profile).await.unwrap()); - publish_revocation(&mut institution, rev_reg.rev_reg_id.clone()).await; + publish_revocation(&mut institution, &rev_reg).await; let request_name2 = Some("request2"); let mut verifier = verifier_create_proof_and_send_request( &mut institution, @@ -255,7 +255,7 @@ mod integration_tests { create_connected_connections(&mut consumer3, &mut institution).await; // Issue and send three credentials of the same schema - let (schema_id, _schema_json, cred_def_id, _cred_def_json, cred_def, rev_reg, rev_reg_id) = + let (schema_id, _schema_json, cred_def_id, _cred_def_json, cred_def, rev_reg, _rev_reg_id) = _create_address_schema(&institution.profile, &institution.config_issuer.institution_did).await; let (address1, address2, city, state, zip) = attr_names(); let credential_data1 = json!({address1.clone(): "123 Main St", address2.clone(): "Suite 3", city.clone(): "Draper", state.clone(): "UT", zip.clone(): "84000"}).to_string(); @@ -369,7 +369,7 @@ mod integration_tests { ); // Publish revocations and verify the two are invalid, third still valid - publish_revocation(&mut institution, rev_reg_id.clone().unwrap()).await; + publish_revocation(&mut institution, &rev_reg).await; tokio::time::sleep(Duration::from_millis(1000)).await; assert!(issuer_credential1.is_revoked(&institution.profile).await.unwrap()); @@ -472,7 +472,7 @@ mod integration_tests { let time_before_revocation = time::OffsetDateTime::now_utc().unix_timestamp() as u64; tokio::time::sleep(Duration::from_millis(1000)).await; info!("test_revoked_credential_might_still_work :: verifier :: Going to revoke credential"); - revoke_credential_and_publish_accumulator(&mut institution, &issuer_credential, &rev_reg.rev_reg_id).await; + revoke_credential_and_publish_accumulator(&mut institution, &issuer_credential, &rev_reg).await; tokio::time::sleep(Duration::from_millis(1000)).await; let from = time_before_revocation - 100; @@ -556,7 +556,7 @@ mod integration_tests { create_connected_connections(&mut consumer, &mut verifier).await; let (consumer_to_issuer, issuer_to_consumer) = create_connected_connections(&mut consumer, &mut issuer).await; - let (schema_id, _schema_json, cred_def_id, _cred_def_json, cred_def, rev_reg, rev_reg_id) = + let (schema_id, _schema_json, cred_def_id, _cred_def_json, cred_def, rev_reg, _rev_reg_id) = _create_address_schema(&issuer.profile, &issuer.config_issuer.institution_did).await; let (address1, address2, city, state, zip) = attr_names(); let (req1, req2) = (Some("request1"), Some("request2")); @@ -588,7 +588,7 @@ mod integration_tests { assert!(!issuer_credential1.is_revoked(&issuer.profile).await.unwrap()); assert!(!issuer_credential2.is_revoked(&issuer.profile).await.unwrap()); - revoke_credential_and_publish_accumulator(&mut issuer, &issuer_credential1, &rev_reg_id.unwrap()).await; + revoke_credential_and_publish_accumulator(&mut issuer, &issuer_credential1, &rev_reg).await; let mut proof_verifier = verifier_create_proof_and_send_request( &mut verifier, @@ -649,7 +649,7 @@ mod integration_tests { create_connected_connections(&mut consumer, &mut verifier).await; let (consumer_to_issuer, issuer_to_consumer) = create_connected_connections(&mut consumer, &mut issuer).await; - let (schema_id, _schema_json, cred_def_id, _cred_def_json, cred_def, rev_reg, rev_reg_id) = + let (schema_id, _schema_json, cred_def_id, _cred_def_json, cred_def, rev_reg, _rev_reg_id) = _create_address_schema(&issuer.profile, &issuer.config_issuer.institution_did).await; let (address1, address2, city, state, zip) = attr_names(); let (req1, req2) = (Some("request1"), Some("request2")); @@ -681,7 +681,7 @@ mod integration_tests { assert!(!issuer_credential1.is_revoked(&issuer.profile).await.unwrap()); assert!(!issuer_credential2.is_revoked(&issuer.profile).await.unwrap()); - revoke_credential_and_publish_accumulator(&mut issuer, &issuer_credential2, &rev_reg_id.unwrap()).await; + revoke_credential_and_publish_accumulator(&mut issuer, &issuer_credential2, &rev_reg).await; let mut proof_verifier = verifier_create_proof_and_send_request( &mut verifier, @@ -857,7 +857,7 @@ mod integration_tests { assert!(!issuer_credential1.is_revoked(&issuer.profile).await.unwrap()); assert!(!issuer_credential2.is_revoked(&issuer.profile).await.unwrap()); - revoke_credential_and_publish_accumulator(&mut issuer, &issuer_credential1, &rev_reg.rev_reg_id).await; + revoke_credential_and_publish_accumulator(&mut issuer, &issuer_credential1, &rev_reg).await; let mut proof_verifier = verifier_create_proof_and_send_request( &mut verifier, @@ -947,7 +947,7 @@ mod integration_tests { assert!(!issuer_credential1.is_revoked(&issuer.profile).await.unwrap()); assert!(!issuer_credential2.is_revoked(&issuer.profile).await.unwrap()); - revoke_credential_and_publish_accumulator(&mut issuer, &issuer_credential2, &rev_reg_2.rev_reg_id).await; + revoke_credential_and_publish_accumulator(&mut issuer, &issuer_credential2, &rev_reg_2).await; let mut proof_verifier = verifier_create_proof_and_send_request( &mut verifier, diff --git a/aries_vcx/tests/utils/scenarios.rs b/aries_vcx/tests/utils/scenarios.rs index 759f1235c8..fe729d8573 100644 --- a/aries_vcx/tests/utils/scenarios.rs +++ b/aries_vcx/tests/utils/scenarios.rs @@ -759,12 +759,11 @@ pub mod test_utils { pub async fn revoke_credential_and_publish_accumulator( faber: &mut Faber, issuer_credential: &Issuer, - rev_reg_id: &str, + rev_reg: &RevocationRegistry, ) { - revoke_credential_local(faber, issuer_credential, &rev_reg_id).await; - let anoncreds = Arc::clone(&faber.profile).inject_anoncreds(); - anoncreds - .publish_local_revocations(&faber.config_issuer.institution_did, &rev_reg_id) + revoke_credential_local(faber, issuer_credential, &rev_reg.rev_reg_id).await; + rev_reg + .publish_local_revocations(&faber.profile, &faber.config_issuer.institution_did) .await .unwrap(); } @@ -803,10 +802,9 @@ pub mod test_utils { rev_reg_new } - pub async fn publish_revocation(institution: &mut Faber, rev_reg_id: String) { - let anoncreds = Arc::clone(&institution.profile).inject_anoncreds(); - anoncreds - .publish_local_revocations(&institution.config_issuer.institution_did, rev_reg_id.as_str()) + pub async fn publish_revocation(institution: &mut Faber, rev_reg: &RevocationRegistry) { + rev_reg + .publish_local_revocations(&institution.profile, &institution.config_issuer.institution_did) .await .unwrap(); } diff --git a/aries_vcx_core/src/anoncreds/base_anoncreds.rs b/aries_vcx_core/src/anoncreds/base_anoncreds.rs index 6d2dbc2731..e7d979175f 100644 --- a/aries_vcx_core/src/anoncreds/base_anoncreds.rs +++ b/aries_vcx_core/src/anoncreds/base_anoncreds.rs @@ -103,8 +103,9 @@ pub trait BaseAnonCreds: std::fmt::Debug + Send + Sync { // TODO - FUTURE - think about moving this to somewhere else, as it aggregates other calls (not PURE Anoncreds) async fn revoke_credential_local(&self, tails_dir: &str, rev_reg_id: &str, cred_rev_id: &str) -> VcxCoreResult<()>; - // TODO - FUTURE - think about moving this to somewhere else, as it aggregates other calls (not PURE Anoncreds) - async fn publish_local_revocations(&self, submitter_did: &str, rev_reg_id: &str) -> VcxCoreResult<()>; + async fn get_rev_reg_delta(&self, rev_reg_id: &str) -> VcxCoreResult>; + + async fn clear_rev_reg_delta(&self, rev_reg_id: &str) -> VcxCoreResult<()>; async fn generate_nonce(&self) -> VcxCoreResult; } diff --git a/aries_vcx_core/src/anoncreds/credx_anoncreds.rs b/aries_vcx_core/src/anoncreds/credx_anoncreds.rs index 30208d1d3f..e59d279757 100644 --- a/aries_vcx_core/src/anoncreds/credx_anoncreds.rs +++ b/aries_vcx_core/src/anoncreds/credx_anoncreds.rs @@ -688,9 +688,12 @@ impl BaseAnonCreds for IndyCredxAnonCreds { Err(unimplemented_method_err("credx revoke_credential_local")) } - async fn publish_local_revocations(&self, submitter_did: &str, rev_reg_id: &str) -> VcxCoreResult<()> { - let _ = (submitter_did, rev_reg_id); - Err(unimplemented_method_err("credx publish_local_revocations")) + async fn get_rev_reg_delta(&self, rev_reg_id: &str) -> VcxCoreResult> { + Err(unimplemented_method_err("credx get_rev_reg_delta")) + } + + async fn clear_rev_reg_delta(&self, rev_reg_id: &str) -> VcxCoreResult<()> { + Err(unimplemented_method_err("credx clear_rev_reg_delta")) } async fn generate_nonce(&self) -> VcxCoreResult { diff --git a/aries_vcx_core/src/anoncreds/indy_anoncreds.rs b/aries_vcx_core/src/anoncreds/indy_anoncreds.rs index 7215690555..505f3c91d7 100644 --- a/aries_vcx_core/src/anoncreds/indy_anoncreds.rs +++ b/aries_vcx_core/src/anoncreds/indy_anoncreds.rs @@ -1,6 +1,7 @@ use async_trait::async_trait; use crate::errors::error::VcxCoreResult; +use crate::indy::wallet_non_secrets::{clear_rev_reg_delta, get_rev_reg_delta}; use crate::{indy, PoolHandle, WalletHandle}; use super::base_anoncreds::BaseAnonCreds; @@ -8,15 +9,11 @@ use super::base_anoncreds::BaseAnonCreds; #[derive(Debug)] pub struct IndySdkAnonCreds { indy_wallet_handle: WalletHandle, - indy_pool_handle: PoolHandle, } impl IndySdkAnonCreds { - pub fn new(indy_wallet_handle: WalletHandle, indy_pool_handle: PoolHandle) -> Self { - IndySdkAnonCreds { - indy_wallet_handle, - indy_pool_handle, - } + pub fn new(indy_wallet_handle: WalletHandle) -> Self { + IndySdkAnonCreds { indy_wallet_handle } } } @@ -219,14 +216,13 @@ impl BaseAnonCreds for IndySdkAnonCreds { .await } - async fn publish_local_revocations(&self, submitter_did: &str, rev_reg_id: &str) -> VcxCoreResult<()> { - indy::primitives::revocation_registry::publish_local_revocations( - self.indy_wallet_handle, - self.indy_pool_handle, - submitter_did, - rev_reg_id, - ) - .await + async fn get_rev_reg_delta(&self, rev_reg_id: &str) -> VcxCoreResult> { + Ok(get_rev_reg_delta(self.indy_wallet_handle, rev_reg_id).await) + } + + async fn clear_rev_reg_delta(&self, rev_reg_id: &str) -> VcxCoreResult<()> { + clear_rev_reg_delta(self.indy_wallet_handle, rev_reg_id).await?; + Ok(()) } async fn generate_nonce(&self) -> VcxCoreResult { diff --git a/aries_vcx_core/src/indy/primitives/revocation_registry.rs b/aries_vcx_core/src/indy/primitives/revocation_registry.rs index 60dc2ba1ad..2dd6e47840 100644 --- a/aries_vcx_core/src/indy/primitives/revocation_registry.rs +++ b/aries_vcx_core/src/indy/primitives/revocation_registry.rs @@ -1,5 +1,8 @@ +use std::sync::Arc; + use vdrtools::{DidValue, Locator}; +use crate::anoncreds::base_anoncreds::BaseAnonCreds; use crate::errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult}; use crate::global::settings; use crate::indy::anoncreds; @@ -8,6 +11,7 @@ use crate::indy::ledger::transactions::{ }; use crate::indy::utils::parse_and_validate; use crate::indy::wallet_non_secrets::{clear_rev_reg_delta, get_rev_reg_delta, set_rev_reg_delta}; +use crate::ledger::base_ledger::BaseLedger; use crate::{PoolHandle, WalletHandle}; pub const BLOB_STORAGE_TYPE: &str = "default"; @@ -150,37 +154,3 @@ pub async fn revoke_credential_local( set_rev_reg_delta(wallet_handle, rev_reg_id, &new_delta_json).await } - -// consider moving out of indy dir as this aggregates multiple calls -pub async fn publish_local_revocations( - wallet_handle: WalletHandle, - pool_handle: PoolHandle, - submitter_did: &str, - rev_reg_id: &str, -) -> VcxCoreResult<()> { - if let Some(delta) = get_rev_reg_delta(wallet_handle, rev_reg_id).await { - publish_rev_reg_delta(wallet_handle, pool_handle, submitter_did, rev_reg_id, &delta).await?; - - info!( - "publish_local_revocations >>> rev_reg_delta published for rev_reg_id {}", - rev_reg_id - ); - - match clear_rev_reg_delta(wallet_handle, rev_reg_id).await { - Ok(_) => { - info!( - "publish_local_revocations >>> rev_reg_delta storage cleared for rev_reg_id {}", - rev_reg_id - ); - Ok(()) - } - Err(err) => Err(AriesVcxCoreError::from_msg( - AriesVcxCoreErrorKind::RevDeltaFailedToClear, - format!("Failed to clear revocation delta storage for rev_reg_id: {rev_reg_id}, error: {err}"), - )), - } - } else { - Err(AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::RevDeltaNotFound, - format!("Failed to publish revocation delta for revocation registry {rev_reg_id}, no delta found. Possibly already published?"))) - } -} diff --git a/libvcx_core/src/api_vcx/api_handle/revocation_registry.rs b/libvcx_core/src/api_vcx/api_handle/revocation_registry.rs index a41886dc14..499a3ab084 100644 --- a/libvcx_core/src/api_vcx/api_handle/revocation_registry.rs +++ b/libvcx_core/src/api_vcx/api_handle/revocation_registry.rs @@ -46,12 +46,11 @@ pub async fn publish_revocations(handle: u32) -> LibvcxResult<()> { let submitter_did = get_config_value(CONFIG_INSTITUTION_DID)?; let rev_reg = REV_REG_MAP.get_cloned(handle)?; - let rev_reg_id = rev_reg.get_rev_reg_id(); - // TODO: Check result - let profile = get_main_profile()?; - let anoncreds = profile.inject_anoncreds(); - anoncreds.publish_local_revocations(&submitter_did, &rev_reg_id).await?; + rev_reg + .publish_local_revocations(&get_main_profile()?, &submitter_did) + .await?; + Ok(()) } From 4a501b9ca65e47e93dbea8f4a9abde51fcb2f6ec Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Fri, 12 May 2023 10:39:54 +0200 Subject: [PATCH 02/19] Run full CI Signed-off-by: Miroslav Kovar --- aries_vcx/TUTORIAL.md | 1 - 1 file changed, 1 deletion(-) diff --git a/aries_vcx/TUTORIAL.md b/aries_vcx/TUTORIAL.md index 6a5a743248..d91f767db0 100644 --- a/aries_vcx/TUTORIAL.md +++ b/aries_vcx/TUTORIAL.md @@ -1,4 +1,3 @@ - # Run ### Stage 1 - unit tests - First we need to get unit tests passing on your machine. These don't require any external services to run. From 8d858c60a23449377c698df3cf94c439f95ec5ad Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Fri, 12 May 2023 17:12:27 +0200 Subject: [PATCH 03/19] Relaxed alpine docker img nodejs installation Signed-off-by: Miroslav Kovar --- ci/libvcx.dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/libvcx.dockerfile b/ci/libvcx.dockerfile index f8c41ad3ed..c3239db32b 100644 --- a/ci/libvcx.dockerfile +++ b/ci/libvcx.dockerfile @@ -30,6 +30,6 @@ RUN cp /usr/share/zoneinfo/UTC /etc/localtime && echo UTC > /etc/timezone ENV TZ=UTC RUN echo 'https://dl-cdn.alpinelinux.org/alpine/v3.17/main' >> /etc/apk/repositories -RUN apk add --no-cache nodejs=18.14.2-r0 +RUN apk add --no-cache nodejs~=18 USER node From d7b88fd48a07c10fd68ad789eae36c2d76866d88 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Wed, 10 May 2023 11:46:08 +0200 Subject: [PATCH 04/19] Initial work Signed-off-by: Miroslav Kovar --- Cargo.lock | 35 +- aries_vcx/Cargo.toml | 2 +- aries_vcx/src/common/ledger/transactions.rs | 3 +- aries_vcx/src/core/profile/mod.rs | 2 + .../src/core/profile/vdr_proxy_profile.rs | 45 +++ aries_vcx/src/utils/devsetup.rs | 35 +- aries_vcx_core/Cargo.toml | 2 + aries_vcx_core/src/anoncreds/mod.rs | 2 +- .../src/errors/mapping_indyvdr_proxy.rs | 12 + aries_vcx_core/src/errors/mod.rs | 6 +- aries_vcx_core/src/ledger/mod.rs | 2 + aries_vcx_core/src/ledger/vdr_proxy_ledger.rs | 360 ++++++++++++++++++ aries_vcx_core/src/lib.rs | 3 + 13 files changed, 501 insertions(+), 8 deletions(-) create mode 100644 aries_vcx/src/core/profile/vdr_proxy_profile.rs create mode 100644 aries_vcx_core/src/errors/mapping_indyvdr_proxy.rs create mode 100644 aries_vcx_core/src/ledger/vdr_proxy_ledger.rs diff --git a/Cargo.lock b/Cargo.lock index 73b6837af0..bf381ea83d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -242,6 +242,7 @@ dependencies = [ "futures", "indy-credx", "indy-vdr", + "indy-vdr-proxy-client", "lazy_static", "libvdrtools", "log", @@ -848,6 +849,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + [[package]] name = "codespan-reporting" version = "0.11.1" @@ -2392,6 +2402,17 @@ dependencies = [ "zmq", ] +[[package]] +name = "indy-vdr-proxy-client" +version = "0.1.0" +source = "git+https://github.com/mirgee/indy-vdr.git?rev=fab0535#fab0535832d87f8194cf49acc897ac6b004c38c4" +dependencies = [ + "indy-vdr", + "reqwest", + "serde_json", + "url", +] + [[package]] name = "indy-wallet" version = "0.1.0" @@ -3645,9 +3666,9 @@ checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "reqwest" -version = "0.11.16" +version = "0.11.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b71749df584b7f4cac2c426c127a7c785a5106cc98f7a8feb044115f0fa254" +checksum = "13293b639a097af28fc8a90f22add145a9c954e49d77da06263d58cf44d5fb91" dependencies = [ "base64 0.21.0", "bytes", @@ -5393,6 +5414,15 @@ dependencies = [ "syn 2.0.15", ] +[[package]] +name = "zeromq-src" +version = "0.1.10+4.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9133d366817fcffe22e4356043ba187ae122ec5db63d7ce73d1e6a18efa2f1" +dependencies = [ + "cmake", +] + [[package]] name = "zmq" version = "0.9.2" @@ -5413,4 +5443,5 @@ checksum = "d33a2c51dde24d5b451a2ed4b488266df221a5eaee2ee519933dc46b9a9b3648" dependencies = [ "libc", "metadeps", + "zeromq-src", ] diff --git a/aries_vcx/Cargo.toml b/aries_vcx/Cargo.toml index 21fc777819..6b7d99dd99 100644 --- a/aries_vcx/Cargo.toml +++ b/aries_vcx/Cargo.toml @@ -15,7 +15,7 @@ default = ["vdrtools"] vdrtools = ["aries_vcx_core/vdrtools"] # Feature flag to include the 'modular library' dependencies (vdrtools alternatives; indy-vdr, indy-credx) modular_libs = ["aries_vcx_core/modular_libs"] - +vdr_proxy_ledger = ["aries_vcx_core/vdr_proxy_ledger"] [dependencies] agency_client = { path = "../agency_client" } diff --git a/aries_vcx/src/common/ledger/transactions.rs b/aries_vcx/src/common/ledger/transactions.rs index 56516f61bb..c42fb34df5 100644 --- a/aries_vcx/src/common/ledger/transactions.rs +++ b/aries_vcx/src/common/ledger/transactions.rs @@ -80,9 +80,10 @@ pub async fn add_new_did( let ledger = Arc::clone(profile).inject_ledger(); - ledger + let res = ledger .publish_nym(submitter_did, &did, Some(&verkey), None, role) .await?; + check_response(&res)?; Ok((did, verkey)) } diff --git a/aries_vcx/src/core/profile/mod.rs b/aries_vcx/src/core/profile/mod.rs index c7a8be0061..2264c82d07 100644 --- a/aries_vcx/src/core/profile/mod.rs +++ b/aries_vcx/src/core/profile/mod.rs @@ -1,5 +1,7 @@ #[cfg(feature = "modular_libs")] pub mod modular_libs_profile; pub mod profile; +#[cfg(feature = "vdr_proxy_ledger")] +pub mod vdr_proxy_profile; #[cfg(feature = "vdrtools")] pub mod vdrtools_profile; diff --git a/aries_vcx/src/core/profile/vdr_proxy_profile.rs b/aries_vcx/src/core/profile/vdr_proxy_profile.rs new file mode 100644 index 0000000000..05a2044e76 --- /dev/null +++ b/aries_vcx/src/core/profile/vdr_proxy_profile.rs @@ -0,0 +1,45 @@ +use std::sync::Arc; + +use aries_vcx_core::{ + anoncreds::{base_anoncreds::BaseAnonCreds, credx_anoncreds::IndyCredxAnonCreds, indy_anoncreds::IndySdkAnonCreds}, + ledger::{base_ledger::BaseLedger, indy_ledger::IndySdkLedger, vdr_proxy_ledger::VdrProxyLedger}, + wallet::{base_wallet::BaseWallet, indy_wallet::IndySdkWallet}, + PoolHandle, VdrProxyClient, WalletHandle, +}; + +use crate::errors::error::VcxResult; + +use super::profile::Profile; + +#[derive(Debug)] +pub struct VdrProxyProfile { + wallet: Arc, + ledger: Arc, + anoncreds: Arc, +} + +impl VdrProxyProfile { + pub fn new(wallet: Arc, client: VdrProxyClient) -> Self { + let ledger = Arc::new(VdrProxyLedger::new(wallet.clone(), client)); + let anoncreds = Arc::new(IndyCredxAnonCreds::new(Arc::clone(&wallet))); + VdrProxyProfile { + wallet, + ledger, + anoncreds, + } + } +} + +impl Profile for VdrProxyProfile { + fn inject_ledger(self: Arc) -> Arc { + Arc::clone(&self.ledger) + } + + fn inject_anoncreds(self: Arc) -> Arc { + Arc::clone(&self.anoncreds) + } + + fn inject_wallet(&self) -> Arc { + Arc::clone(&self.wallet) + } +} diff --git a/aries_vcx/src/utils/devsetup.rs b/aries_vcx/src/utils/devsetup.rs index 10be78beb0..6bf310ab5c 100644 --- a/aries_vcx/src/utils/devsetup.rs +++ b/aries_vcx/src/utils/devsetup.rs @@ -380,6 +380,12 @@ impl SetupProfile { SetupProfile::init_modular().await }; + #[cfg(feature = "vdr_proxy_ledger")] + return { + info!("SetupProfile >> using vdr proxy profile"); + SetupProfile::init_vdr_proxy_ledger().await + }; + #[cfg(feature = "vdrtools")] return { info!("SetupProfile >> using indy profile"); @@ -445,7 +451,34 @@ impl SetupProfile { } } - #[cfg(any(feature = "modular_libs", feature = "vdrtools"))] + #[cfg(feature = "vdr_proxy_ledger")] + async fn init_vdr_proxy_ledger() -> SetupProfile { + use std::env; + + use crate::core::profile::vdr_proxy_profile::VdrProxyProfile; + use aries_vcx_core::VdrProxyClient; + + let (institution_did, wallet_handle) = setup_issuer_wallet().await; + + // TODO: Test configuration should be handled uniformly + let client_url = env::var("VDR_PROXY_CLIENT_URL").unwrap_or_else(|_| "http://127.0.0.1:3030".to_string()); + let wallet = IndySdkWallet::new(wallet_handle); + let client = VdrProxyClient::new(&client_url).unwrap(); + + let profile: Arc = Arc::new(VdrProxyProfile::new(Arc::new(wallet), client)); + + async fn vdr_proxy_teardown() { + // nothing to do + } + + SetupProfile { + institution_did, + profile, + teardown: Arc::new(move || Box::pin(vdr_proxy_teardown())), + } + } + + #[cfg(any(feature = "modular_libs", feature = "vdrtools", feature = "vdr_proxy_ledger"))] pub async fn run(f: impl FnOnce(Self) -> F) where F: Future, diff --git a/aries_vcx_core/Cargo.toml b/aries_vcx_core/Cargo.toml index 121e2440e5..97373d9d56 100644 --- a/aries_vcx_core/Cargo.toml +++ b/aries_vcx_core/Cargo.toml @@ -9,6 +9,7 @@ edition = "2021" vdrtools = ["dep:libvdrtools"] # Feature flag to include the 'modular library' dependencies (vdrtools alternatives; indy-vdr, indy-credx) modular_libs = ["dep:indy-vdr", "dep:indy-credx"] +vdr_proxy_ledger = ["dep:indy-vdr", "dep:indy-credx", "dep:indy-vdr-proxy-client"] [dependencies] agency_client = { path = "../agency_client" } @@ -39,6 +40,7 @@ lazy_static = "1.4.0" derive_builder = "0.12.0" uuid = { version = "1.3.0", default-features = false, features = ["v4"] } tokio = { version = "1.20" } +indy-vdr-proxy-client = { git = "https://github.com/mirgee/indy-vdr.git", rev = "fab0535", optional = true } [dev-dependencies] tokio = { version = "1.20", features = ["rt", "macros", "rt-multi-thread"] } diff --git a/aries_vcx_core/src/anoncreds/mod.rs b/aries_vcx_core/src/anoncreds/mod.rs index fec6fc4aed..d8a16ba8b4 100644 --- a/aries_vcx_core/src/anoncreds/mod.rs +++ b/aries_vcx_core/src/anoncreds/mod.rs @@ -1,5 +1,5 @@ pub mod base_anoncreds; -#[cfg(feature = "modular_libs")] +#[cfg(any(feature = "modular_libs", feature = "vdr_proxy_ledger"))] pub mod credx_anoncreds; #[cfg(feature = "vdrtools")] pub mod indy_anoncreds; diff --git a/aries_vcx_core/src/errors/mapping_indyvdr_proxy.rs b/aries_vcx_core/src/errors/mapping_indyvdr_proxy.rs new file mode 100644 index 0000000000..0a441b1f32 --- /dev/null +++ b/aries_vcx_core/src/errors/mapping_indyvdr_proxy.rs @@ -0,0 +1,12 @@ +use indy_vdr_proxy_client::error::VdrProxyClientError; + +use super::error::{AriesVcxCoreError, AriesVcxCoreErrorKind}; + +impl From for AriesVcxCoreError { + fn from(err: VdrProxyClientError) -> Self { + AriesVcxCoreError::from_msg( + AriesVcxCoreErrorKind::InvalidLedgerResponse, + format!("VdrProxyClient error: {:?}", err), + ) + } +} diff --git a/aries_vcx_core/src/errors/mod.rs b/aries_vcx_core/src/errors/mod.rs index 765403d8dc..abdf7777b6 100644 --- a/aries_vcx_core/src/errors/mod.rs +++ b/aries_vcx_core/src/errors/mod.rs @@ -1,9 +1,11 @@ pub mod error; mod mapping_agency_client; -#[cfg(feature = "modular_libs")] +#[cfg(any(feature = "modular_libs", feature = "vdr_proxy_ledger"))] mod mapping_credx; -#[cfg(feature = "modular_libs")] +#[cfg(any(feature = "modular_libs", feature = "vdr_proxy_ledger"))] mod mapping_indyvdr; +#[cfg(feature = "vdr_proxy_ledger")] +mod mapping_indyvdr_proxy; mod mapping_others; #[cfg(feature = "vdrtools")] mod mapping_vdrtools; diff --git a/aries_vcx_core/src/ledger/mod.rs b/aries_vcx_core/src/ledger/mod.rs index 911d544c08..6d78556904 100644 --- a/aries_vcx_core/src/ledger/mod.rs +++ b/aries_vcx_core/src/ledger/mod.rs @@ -3,3 +3,5 @@ pub mod base_ledger; pub mod indy_ledger; #[cfg(feature = "modular_libs")] pub mod indy_vdr_ledger; +#[cfg(feature = "vdr_proxy_ledger")] +pub mod vdr_proxy_ledger; diff --git a/aries_vcx_core/src/ledger/vdr_proxy_ledger.rs b/aries_vcx_core/src/ledger/vdr_proxy_ledger.rs new file mode 100644 index 0000000000..a498781c6a --- /dev/null +++ b/aries_vcx_core/src/ledger/vdr_proxy_ledger.rs @@ -0,0 +1,360 @@ +use indy_vdr as vdr; +use indy_vdr_proxy_client::VdrProxyClient; +use std::collections::hash_map::RandomState; +use std::collections::HashMap; +use std::fmt::{Debug, Formatter}; +use std::sync::Arc; +use time::OffsetDateTime; +use vdr::ledger::requests::schema::{AttributeNames, Schema, SchemaV1}; + +use async_trait::async_trait; +use serde_json::Value; +use tokio::sync::oneshot; +use vdr::common::error::VdrError; +use vdr::config::PoolConfig as IndyVdrPoolConfig; +use vdr::ledger::identifiers::{CredentialDefinitionId, RevocationRegistryId, SchemaId}; +use vdr::ledger::requests::author_agreement::TxnAuthrAgrmtAcceptanceData; +use vdr::ledger::RequestBuilder; +use vdr::pool::{PoolBuilder, PoolTransactions}; +use vdr::pool::{PoolRunner, PreparedRequest, ProtocolVersion, RequestResult}; +use vdr::utils::did::DidValue; +use vdr::utils::Qualifiable; + +use crate::errors::error::VcxCoreResult; +use crate::errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind}; +use crate::global::author_agreement::get_txn_author_agreement; +use crate::global::settings; +use crate::utils::json::{AsTypeOrDeserializationError, TryGetIndex}; +use crate::wallet::base_wallet::BaseWallet; + +use super::base_ledger::BaseLedger; + +pub struct VdrProxyLedger { + wallet: Arc, + client: VdrProxyClient, +} + +impl Debug for VdrProxyLedger { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.write_str("VdrProxyLedger") + } +} + +fn unimplemented_method_err(method_name: &str) -> AriesVcxCoreError { + AriesVcxCoreError::from_msg( + AriesVcxCoreErrorKind::UnimplementedFeature, + format!("method called '{}' is not yet implemented in AriesVCX", method_name), + ) +} + +fn _get_response_json_data_field(response_json: &str) -> VcxCoreResult { + let res: Value = serde_json::from_str(response_json)?; + let result = (&res).try_get("result")?; + Ok(result.try_get("data")?.to_owned()) +} + +async fn _append_txn_author_agreement_to_request(request: PreparedRequest) -> VcxCoreResult { + if let Some(taa) = get_txn_author_agreement()? { + let mut request = request; + let acceptance = TxnAuthrAgrmtAcceptanceData { + mechanism: taa.acceptance_mechanism_type, + // TODO - investigate default digest + taa_digest: taa.taa_digest.map_or(String::from(""), |v| v), + time: taa.time_of_acceptance, + }; + request.set_txn_author_agreement_acceptance(&acceptance)?; + + Ok(request) + } else { + Ok(request) + } +} + +impl VdrProxyLedger { + pub fn new(wallet: Arc, client: VdrProxyClient) -> Self { + Self { wallet, client } + } + + pub fn request_builder(&self) -> VcxCoreResult { + let v = settings::get_protocol_version(); + let version = ProtocolVersion::from_id(v as u64)?; + Ok(RequestBuilder::new(version)) + } + + async fn _sign_request(&self, submitter_did: &str, request: PreparedRequest) -> VcxCoreResult { + let to_sign = request.get_signature_input()?; + let signer_verkey = self.wallet.key_for_local_did(submitter_did).await?; + let signature = self.wallet.sign(&signer_verkey, to_sign.as_bytes()).await?; + + let request = { + let mut request = request; + request.set_signature(&signature)?; + request + }; + + Ok(request) + } + + async fn _build_get_cred_def_request( + &self, + submitter_did: Option<&str>, + cred_def_id: &str, + ) -> VcxCoreResult { + todo!() + } + + async fn _build_get_attr_request( + &self, + submitter_did: Option<&str>, + target_did: &str, + attribute_name: &str, + ) -> VcxCoreResult { + todo!() + } + + fn _build_attrib_request( + &self, + submitter_did: &str, + target_did: &str, + attrib_json_str: Option<&str>, + ) -> VcxCoreResult { + let identifier = DidValue::from_str(submitter_did)?; + let dest = DidValue::from_str(target_did)?; + let attrib_json = if let Some(attrib) = attrib_json_str { + Some(serde_json::from_str::(attrib)?) + } else { + None + }; + + Ok(self + .request_builder()? + .build_attrib_request(&identifier, &dest, None, attrib_json.as_ref(), None)?) + } + + fn _process_schema_response(response: &str) -> VcxCoreResult { + let response_json: Value = serde_json::from_str(response)?; + let result_json = (&response_json).try_get("result")?; + let data_json = result_json.try_get("data")?; + + let seq_no = result_json.get("seqNo").and_then(|x| x.as_u64().map(|x| x as u32)); + + let name = data_json.try_get("name")?; + let name = name.try_as_str()?; + let version = data_json.try_get("version")?; + let version = version.try_as_str()?; + let dest = result_json.try_get("dest")?; + let dest = dest.try_as_str()?; + let schema_id = SchemaId::new(&DidValue::from_str(dest)?, name, version); + + let attr_names = data_json.try_get("attr_names")?; + let attr_names: AttributeNames = serde_json::from_value(attr_names.to_owned())?; + + let schema = SchemaV1 { + id: schema_id, + name: name.to_string(), + version: version.to_string(), + attr_names, + seq_no, + }; + + Ok(Schema::SchemaV1(schema)) + } + + fn _process_rev_reg_delta_response(response: &str, rev_reg_id: &str) -> VcxCoreResult<(String, String, u64)> { + let res_data = _get_response_json_data_field(&response)?; + let response_value = (&res_data).try_get("value")?; + + let empty_json_list = json!([]); + + let mut delta_value = json!({ + "accum": response_value.try_get("accum_to")?.try_get("value")?.try_get("accum")?, + "issued": if let Some(v) = response_value.get("issued") { v } else { &empty_json_list }, + "revoked": if let Some(v) = response_value.get("revoked") { v } else { &empty_json_list } + }); + + if let Some(accum_from) = response_value + .get("accum_from") + .and_then(|val| (!val.is_null()).then_some(val)) + { + let prev_accum = accum_from.try_get("value")?.try_get("accum")?; + // to check - should this be 'prevAccum'? + delta_value["prev_accum"] = prev_accum.to_owned(); + } + + let reg_delta = json!({"ver": "1.0", "value": delta_value}); + + let delta_timestamp = + response_value + .try_get("accum_to")? + .try_get("txnTime")? + .as_u64() + .ok_or(AriesVcxCoreError::from_msg( + AriesVcxCoreErrorKind::InvalidJson, + "Error parsing accum_to.txnTime value as u64", + ))?; + + let response_reg_def_id = (&res_data) + .try_get("revocRegDefId")? + .as_str() + .ok_or(AriesVcxCoreError::from_msg( + AriesVcxCoreErrorKind::InvalidJson, + "Erroring parsing revocRegDefId value as string", + ))?; + if response_reg_def_id != rev_reg_id { + return Err(AriesVcxCoreError::from_msg( + AriesVcxCoreErrorKind::InvalidRevocationDetails, + "ID of revocation registry response does not match requested ID", + )); + } + + Ok(( + rev_reg_id.to_string(), + serde_json::to_string(®_delta)?, + delta_timestamp, + )) + } +} + +#[async_trait] +impl BaseLedger for VdrProxyLedger { + async fn sign_and_submit_request(&self, submitter_did: &str, request_json: &str) -> VcxCoreResult { + let request = self + ._sign_request(submitter_did, PreparedRequest::from_request_json(request_json)?) + .await?; + self.client.post(request).await.map_err(|err| err.into()) + } + + async fn submit_request(&self, request_json: &str) -> VcxCoreResult { + let request = PreparedRequest::from_request_json(request_json)?; + self.client.post(request).await.map_err(|err| err.into()) + } + + async fn endorse_transaction(&self, endorser_did: &str, request_json: &str) -> VcxCoreResult<()> { + Err(unimplemented_method_err("indy_vdr endorse_transaction")) + } + + async fn set_endorser(&self, submitter_did: &str, request_json: &str, endorser: &str) -> VcxCoreResult { + Err(unimplemented_method_err("indy_vdr set_endorser")) + } + + async fn get_txn_author_agreement(&self) -> VcxCoreResult { + self.client.get_txn_author_agreement().await.map_err(|err| err.into()) + } + + async fn get_nym(&self, did: &str) -> VcxCoreResult { + self.client.get_nym(did).await.map_err(|err| err.into()) + } + + async fn publish_nym( + &self, + submitter_did: &str, + target_did: &str, + verkey: Option<&str>, + data: Option<&str>, + role: Option<&str>, + ) -> VcxCoreResult { + let request = self + ._sign_request( + submitter_did, + self.request_builder()?.build_nym_request( + &DidValue(submitter_did.to_string()), + &DidValue(target_did.to_string()), + verkey.map(String::from), + data.map(String::from), + role.map(String::from), + )?, + ) + .await?; + self.client.post(request).await.map_err(|err| err.into()) + } + + async fn get_schema(&self, schema_id: &str, submitter_did: Option<&str>) -> VcxCoreResult { + let response = self.client.get_schema(schema_id).await?; + + let schema = Self::_process_schema_response(&response)?; + + Ok(serde_json::to_string(&schema)?) + } + + async fn get_cred_def(&self, cred_def_id: &str, submitter_did: Option<&str>) -> VcxCoreResult { + self.client.get_cred_def(cred_def_id).await.map_err(|err| err.into()) + } + + async fn get_attr(&self, target_did: &str, attr_name: &str) -> VcxCoreResult { + self.client + .get_attrib(target_did, attr_name) + .await + .map_err(|err| err.into()) + } + + async fn add_attr(&self, target_did: &str, attrib_json: &str) -> VcxCoreResult { + let request = self._build_attrib_request(target_did, target_did, Some(attrib_json))?; + let request = _append_txn_author_agreement_to_request(request).await?; + let request = self._sign_request(target_did, request).await?; + self.client.post(request).await.map_err(|err| err.into()) + } + + async fn get_rev_reg_def_json(&self, rev_reg_id: &str) -> VcxCoreResult { + self.client.get_rev_reg_def(rev_reg_id).await.map_err(|err| err.into()) + } + + async fn get_rev_reg_delta_json( + &self, + rev_reg_id: &str, + from: Option, + to: Option, + ) -> VcxCoreResult<(String, String, u64)> { + let request = self.request_builder()?.build_get_revoc_reg_delta_request( + None, + &RevocationRegistryId::from_str(rev_reg_id)?, + from.map(|x| x as i64), + to.map_or(OffsetDateTime::now_utc().unix_timestamp() as i64, |x| x as i64), + )?; + + let response = self.client.post(request).await?; + + Self::_process_rev_reg_delta_response(&response, rev_reg_id) + } + + async fn get_rev_reg(&self, rev_reg_id: &str, timestamp: u64) -> VcxCoreResult<(String, String, u64)> { + Err(unimplemented_method_err("indy_vdr get_rev_reg")) + } + + async fn get_ledger_txn(&self, seq_no: i32, submitter_did: Option<&str>) -> VcxCoreResult { + // self.client.get_txn(subledger, seq_no).await?; + Err(unimplemented_method_err("indy_vdr get_ledger_txn")) + } + + async fn build_schema_request(&self, submitter_did: &str, schema_json: &str) -> VcxCoreResult { + Err(unimplemented_method_err("indy_vdr build_schema_request")) + } + + async fn publish_schema( + &self, + schema_json: &str, + submitter_did: &str, + endorser_did: Option, + ) -> VcxCoreResult<()> { + Err(unimplemented_method_err("indy_vdr publish_cred_def")) + } + + async fn publish_cred_def(&self, cred_def_json: &str, submitter_did: &str) -> VcxCoreResult<()> { + Err(unimplemented_method_err("indy_vdr publish_rev_reg_def")) + } + + async fn publish_rev_reg_def(&self, rev_reg_def: &str, submitter_did: &str) -> VcxCoreResult<()> { + Err(unimplemented_method_err("indy_vdr publish_rev_reg_def")) + } + + async fn publish_rev_reg_delta( + &self, + rev_reg_id: &str, + rev_reg_entry_json: &str, + submitter_did: &str, + ) -> VcxCoreResult<()> { + Err(unimplemented_method_err("indy_vdr publish_rev_reg_delta")) + } +} + +#[cfg(test)] +mod unit_tests {} diff --git a/aries_vcx_core/src/lib.rs b/aries_vcx_core/src/lib.rs index 252dbf6eb1..ca95cbe6d6 100644 --- a/aries_vcx_core/src/lib.rs +++ b/aries_vcx_core/src/lib.rs @@ -40,3 +40,6 @@ pub mod wallet; pub use vdrtools::{ PoolHandle, SearchHandle, WalletHandle, INVALID_POOL_HANDLE, INVALID_SEARCH_HANDLE, INVALID_WALLET_HANDLE, }; + +#[cfg(feature = "vdr_proxy_ledger")] +pub use indy_vdr_proxy_client::VdrProxyClient; From e959db882ed3f4b11aeecec751c09ca3a22af3a7 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Wed, 10 May 2023 14:32:56 +0200 Subject: [PATCH 05/19] Remove vdr_proxy_ledger and reuse indy_vdr_ledger Signed-off-by: Miroslav Kovar --- .../src/core/profile/modular_libs_profile.rs | 6 +- .../src/core/profile/vdr_proxy_profile.rs | 15 +- aries_vcx/src/utils/devsetup.rs | 2 +- aries_vcx/tests/utils/devsetup_agent.rs | 2 +- aries_vcx_core/src/ledger/indy_vdr_ledger.rs | 142 ++----- aries_vcx_core/src/ledger/mod.rs | 6 +- .../src/ledger/request_submitter/mod.rs | 14 + .../ledger/request_submitter/vdr_ledger.rs | 101 +++++ .../src/ledger/request_submitter/vdr_proxy.rs | 26 ++ aries_vcx_core/src/ledger/vdr_proxy_ledger.rs | 360 ------------------ 10 files changed, 183 insertions(+), 491 deletions(-) create mode 100644 aries_vcx_core/src/ledger/request_submitter/mod.rs create mode 100644 aries_vcx_core/src/ledger/request_submitter/vdr_ledger.rs create mode 100644 aries_vcx_core/src/ledger/request_submitter/vdr_proxy.rs delete mode 100644 aries_vcx_core/src/ledger/vdr_proxy_ledger.rs diff --git a/aries_vcx/src/core/profile/modular_libs_profile.rs b/aries_vcx/src/core/profile/modular_libs_profile.rs index 0481b3c631..0fd20e637f 100644 --- a/aries_vcx/src/core/profile/modular_libs_profile.rs +++ b/aries_vcx/src/core/profile/modular_libs_profile.rs @@ -3,7 +3,8 @@ use std::sync::Arc; use aries_vcx_core::anoncreds::base_anoncreds::BaseAnonCreds; use aries_vcx_core::anoncreds::credx_anoncreds::IndyCredxAnonCreds; use aries_vcx_core::ledger::base_ledger::BaseLedger; -use aries_vcx_core::ledger::indy_vdr_ledger::{IndyVdrLedger, IndyVdrLedgerPool, LedgerPoolConfig}; +use aries_vcx_core::ledger::indy_vdr_ledger::IndyVdrLedger; +use aries_vcx_core::ledger::request_submitter::vdr_ledger::{IndyVdrLedgerPool, IndyVdrSubmitter, LedgerPoolConfig}; use aries_vcx_core::wallet::base_wallet::BaseWallet; use crate::errors::error::VcxResult; @@ -21,7 +22,8 @@ pub struct ModularLibsProfile { impl ModularLibsProfile { pub fn new(wallet: Arc, ledger_pool_config: LedgerPoolConfig) -> VcxResult { let ledger_pool = Arc::new(IndyVdrLedgerPool::new(ledger_pool_config)?); - let ledger = Arc::new(IndyVdrLedger::new(Arc::clone(&wallet), ledger_pool)); + let submitter = Arc::new(IndyVdrSubmitter::new(ledger_pool)); + let ledger = Arc::new(IndyVdrLedger::new(Arc::clone(&wallet), submitter)); let anoncreds = Arc::new(IndyCredxAnonCreds::new(Arc::clone(&wallet))); Ok(ModularLibsProfile { wallet, diff --git a/aries_vcx/src/core/profile/vdr_proxy_profile.rs b/aries_vcx/src/core/profile/vdr_proxy_profile.rs index 05a2044e76..79bf65d06d 100644 --- a/aries_vcx/src/core/profile/vdr_proxy_profile.rs +++ b/aries_vcx/src/core/profile/vdr_proxy_profile.rs @@ -1,14 +1,14 @@ use std::sync::Arc; use aries_vcx_core::{ - anoncreds::{base_anoncreds::BaseAnonCreds, credx_anoncreds::IndyCredxAnonCreds, indy_anoncreds::IndySdkAnonCreds}, - ledger::{base_ledger::BaseLedger, indy_ledger::IndySdkLedger, vdr_proxy_ledger::VdrProxyLedger}, - wallet::{base_wallet::BaseWallet, indy_wallet::IndySdkWallet}, - PoolHandle, VdrProxyClient, WalletHandle, + anoncreds::{base_anoncreds::BaseAnonCreds, credx_anoncreds::IndyCredxAnonCreds}, + ledger::{ + base_ledger::BaseLedger, indy_vdr_ledger::IndyVdrLedger, request_submitter::vdr_proxy::VdrProxySubmitter, + }, + wallet::base_wallet::BaseWallet, + VdrProxyClient, }; -use crate::errors::error::VcxResult; - use super::profile::Profile; #[derive(Debug)] @@ -20,7 +20,8 @@ pub struct VdrProxyProfile { impl VdrProxyProfile { pub fn new(wallet: Arc, client: VdrProxyClient) -> Self { - let ledger = Arc::new(VdrProxyLedger::new(wallet.clone(), client)); + let submitter = Arc::new(VdrProxySubmitter::new(Arc::new(client))); + let ledger = Arc::new(IndyVdrLedger::new(wallet.clone(), submitter)); let anoncreds = Arc::new(IndyCredxAnonCreds::new(Arc::clone(&wallet))); VdrProxyProfile { wallet, diff --git a/aries_vcx/src/utils/devsetup.rs b/aries_vcx/src/utils/devsetup.rs index 6bf310ab5c..50f351aeba 100644 --- a/aries_vcx/src/utils/devsetup.rs +++ b/aries_vcx/src/utils/devsetup.rs @@ -17,7 +17,7 @@ use aries_vcx_core::indy::wallet::{ }; #[cfg(feature = "modular_libs")] -use aries_vcx_core::ledger::indy_vdr_ledger::LedgerPoolConfig; +use aries_vcx_core::ledger::request_submitter::vdr_ledger::LedgerPoolConfig; use aries_vcx_core::wallet::base_wallet::BaseWallet; use aries_vcx_core::wallet::indy_wallet::IndySdkWallet; use aries_vcx_core::{PoolHandle, WalletHandle}; diff --git a/aries_vcx/tests/utils/devsetup_agent.rs b/aries_vcx/tests/utils/devsetup_agent.rs index b54fcd96c1..7406137449 100644 --- a/aries_vcx/tests/utils/devsetup_agent.rs +++ b/aries_vcx/tests/utils/devsetup_agent.rs @@ -16,7 +16,7 @@ pub mod test_utils { IssuerConfig, WalletConfig, }; #[cfg(feature = "modular_libs")] - use aries_vcx_core::ledger::indy_vdr_ledger::LedgerPoolConfig; + use aries_vcx_core::ledger::request_submitter::vdr_ledger::LedgerPoolConfig; use aries_vcx_core::wallet::base_wallet::BaseWallet; use aries_vcx_core::wallet::indy_wallet::IndySdkWallet; use aries_vcx_core::{PoolHandle, WalletHandle}; diff --git a/aries_vcx_core/src/ledger/indy_vdr_ledger.rs b/aries_vcx_core/src/ledger/indy_vdr_ledger.rs index 0c2e90294c..b24f82b00f 100644 --- a/aries_vcx_core/src/ledger/indy_vdr_ledger.rs +++ b/aries_vcx_core/src/ledger/indy_vdr_ledger.rs @@ -1,6 +1,4 @@ use indy_vdr as vdr; -use std::collections::hash_map::RandomState; -use std::collections::HashMap; use std::fmt::{Debug, Formatter}; use std::sync::Arc; use time::OffsetDateTime; @@ -8,14 +6,10 @@ use vdr::ledger::requests::schema::{AttributeNames, Schema, SchemaV1}; use async_trait::async_trait; use serde_json::Value; -use tokio::sync::oneshot; -use vdr::common::error::VdrError; -use vdr::config::PoolConfig as IndyVdrPoolConfig; use vdr::ledger::identifiers::{CredentialDefinitionId, RevocationRegistryId, SchemaId}; use vdr::ledger::requests::author_agreement::TxnAuthrAgrmtAcceptanceData; use vdr::ledger::RequestBuilder; -use vdr::pool::{PoolBuilder, PoolTransactions}; -use vdr::pool::{PoolRunner, PreparedRequest, ProtocolVersion, RequestResult}; +use vdr::pool::{PreparedRequest, ProtocolVersion}; use vdr::utils::did::DidValue; use vdr::utils::Qualifiable; @@ -27,47 +21,25 @@ use crate::utils::json::{AsTypeOrDeserializationError, TryGetIndex}; use crate::wallet::base_wallet::BaseWallet; use super::base_ledger::BaseLedger; +use super::request_submitter::RequestSubmitter; -pub struct LedgerPoolConfig { - pub genesis_file_path: String, -} - -pub struct IndyVdrLedgerPool { - // visibility strictly for internal unit testing - pub(self) runner: Option, -} - -impl IndyVdrLedgerPool { - pub fn new_from_runner(runner: PoolRunner) -> Self { - IndyVdrLedgerPool { runner: Some(runner) } - } - - pub fn new(config: LedgerPoolConfig) -> VcxCoreResult { - let vdr_config = IndyVdrPoolConfig::default(); - let txns = PoolTransactions::from_json_file(config.genesis_file_path)?; - - let runner = PoolBuilder::from(vdr_config).transactions(txns)?.into_runner()?; - - Ok(IndyVdrLedgerPool { runner: Some(runner) }) - } -} - -impl Debug for IndyVdrLedgerPool { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.debug_struct("IndyVdrLedgerPool") - .field("runner", &"PoolRunner") - .finish() - } -} - -pub struct IndyVdrLedger { +pub struct IndyVdrLedger +where + T: RequestSubmitter + Send + Sync, +{ wallet: Arc, - pool: Arc, + request_submitter: Arc, } -impl IndyVdrLedger { - pub fn new(wallet: Arc, pool: Arc) -> Self { - IndyVdrLedger { wallet, pool } +impl IndyVdrLedger +where + T: RequestSubmitter + Send + Sync, +{ + pub fn new(wallet: Arc, request_submitter: Arc) -> Self { + IndyVdrLedger { + wallet, + request_submitter, + } } pub fn request_builder(&self) -> VcxCoreResult { @@ -78,40 +50,7 @@ impl IndyVdrLedger { } async fn _submit_request(&self, request: PreparedRequest) -> VcxCoreResult { - // indyvdr send_request is Async via a callback. - // Use oneshot channel to send result from callback, converting the fn to future. - type VdrSendRequestResult = - Result<(RequestResult, Option>), VdrError>; - let (sender, recv) = oneshot::channel::(); - self.pool - .runner - .as_ref() - .ok_or( - // should not happen - strictly for unit testing - AriesVcxCoreError::from_msg( - AriesVcxCoreErrorKind::NoPoolOpen, - "IndyVdrLedgerPool runner was not provided", - ), - )? - .send_request( - request, - Box::new(move |result| { - // unable to handle a failure from `send` here - sender.send(result).ok(); - }), - )?; - - let send_req_result: VdrSendRequestResult = recv - .await - .map_err(|e| AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::InvalidState, e))?; - let (result, _) = send_req_result?; - - let reply = match result { - RequestResult::Reply(reply) => Ok(reply), - RequestResult::Failed(failed) => Err(failed), - }; - - Ok(reply?) + self.request_submitter.submit(request).await } async fn _sign_and_submit_request(&self, submitter_did: &str, request: PreparedRequest) -> VcxCoreResult { @@ -184,14 +123,20 @@ impl IndyVdrLedger { } } -impl Debug for IndyVdrLedger { +impl Debug for IndyVdrLedger +where + T: RequestSubmitter + Send + Sync, +{ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "IndyVdrLedger instance") } } #[async_trait] -impl BaseLedger for IndyVdrLedger { +impl BaseLedger for IndyVdrLedger +where + T: RequestSubmitter + Send + Sync, +{ async fn sign_and_submit_request(&self, submitter_did: &str, request_json: &str) -> VcxCoreResult { let request = PreparedRequest::from_request_json(request_json)?; @@ -510,40 +455,3 @@ fn _get_response_json_data_field(response_json: &str) -> VcxCoreResult { let result = (&res).try_get("result")?; Ok(result.try_get("data")?.to_owned()) } - -#[cfg(test)] -mod unit_tests { - use std::sync::Arc; - - use crate::errors::error::{AriesVcxCoreErrorKind, VcxCoreResult}; - use crate::{ - common::test_utils::mock_profile, - plugins::ledger::{base_ledger::BaseLedger, indy_vdr_ledger::IndyVdrLedgerPool}, - }; - - use super::IndyVdrLedger; - - #[tokio::test] - #[ignore] - async fn test_pool_unimplemented_methods() { - // test used to assert which methods are unimplemented currently, can be removed after all methods implemented - - fn assert_unimplemented(result: VcxCoreResult) { - assert_eq!(result.unwrap_err().kind(), AriesVcxCoreErrorKind::UnimplementedFeature) - } - - let profile = mock_profile(); - let pool = Arc::new(IndyVdrLedgerPool { runner: None }); - let ledger: Box = Box::new(IndyVdrLedger::new(profile.inject_wallet(), pool)); - - assert_unimplemented(ledger.endorse_transaction("", "").await); - assert_unimplemented(ledger.set_endorser("", "", "").await); - assert_unimplemented(ledger.get_txn_author_agreement().await); - assert_unimplemented(ledger.get_rev_reg("", 0).await); - assert_unimplemented(ledger.get_ledger_txn(0, None).await); - assert_unimplemented(ledger.build_schema_request("", "").await); - assert_unimplemented(ledger.publish_schema("", "", None).await); - assert_unimplemented(ledger.publish_cred_def("", "").await); - assert_unimplemented(ledger.publish_rev_reg_def("", "").await); - } -} diff --git a/aries_vcx_core/src/ledger/mod.rs b/aries_vcx_core/src/ledger/mod.rs index 6d78556904..3b3296a77a 100644 --- a/aries_vcx_core/src/ledger/mod.rs +++ b/aries_vcx_core/src/ledger/mod.rs @@ -1,7 +1,7 @@ pub mod base_ledger; #[cfg(feature = "vdrtools")] pub mod indy_ledger; -#[cfg(feature = "modular_libs")] +#[cfg(any(feature = "modular_libs", feature = "vdr_proxy_ledger"))] pub mod indy_vdr_ledger; -#[cfg(feature = "vdr_proxy_ledger")] -pub mod vdr_proxy_ledger; +#[cfg(any(feature = "modular_libs", feature = "vdr_proxy_ledger"))] +pub mod request_submitter; diff --git a/aries_vcx_core/src/ledger/request_submitter/mod.rs b/aries_vcx_core/src/ledger/request_submitter/mod.rs new file mode 100644 index 0000000000..8d26b3afc7 --- /dev/null +++ b/aries_vcx_core/src/ledger/request_submitter/mod.rs @@ -0,0 +1,14 @@ +use async_trait::async_trait; +use indy_vdr::pool::PreparedRequest; + +use crate::errors::error::VcxCoreResult; + +#[cfg(feature = "modular_libs")] +pub mod vdr_ledger; +#[cfg(feature = "vdr_proxy_ledger")] +pub mod vdr_proxy; + +#[async_trait] +pub trait RequestSubmitter { + async fn submit(&self, request: PreparedRequest) -> VcxCoreResult; +} diff --git a/aries_vcx_core/src/ledger/request_submitter/vdr_ledger.rs b/aries_vcx_core/src/ledger/request_submitter/vdr_ledger.rs new file mode 100644 index 0000000000..1a105ab9e6 --- /dev/null +++ b/aries_vcx_core/src/ledger/request_submitter/vdr_ledger.rs @@ -0,0 +1,101 @@ +use std::{ + collections::{hash_map::RandomState, HashMap}, + fmt::{Debug, Formatter}, + sync::Arc, +}; + +use async_trait::async_trait; +use indy_vdr::{ + common::error::VdrError, + pool::{PoolTransactions, RequestResult}, +}; +use indy_vdr::{ + config::PoolConfig, + pool::{PoolBuilder, PoolRunner, PreparedRequest}, +}; +use tokio::sync::oneshot; + +use crate::errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult}; + +use super::RequestSubmitter; + +pub struct LedgerPoolConfig { + pub genesis_file_path: String, +} + +pub struct IndyVdrLedgerPool { + pub(self) runner: Option, +} + +impl IndyVdrLedgerPool { + pub fn new_from_runner(runner: PoolRunner) -> Self { + IndyVdrLedgerPool { runner: Some(runner) } + } + + pub fn new(config: LedgerPoolConfig) -> VcxCoreResult { + let vdr_config = PoolConfig::default(); + let txns = PoolTransactions::from_json_file(config.genesis_file_path)?; + + let runner = PoolBuilder::from(vdr_config).transactions(txns)?.into_runner()?; + + Ok(IndyVdrLedgerPool { runner: Some(runner) }) + } +} + +impl Debug for IndyVdrLedgerPool { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("IndyVdrLedgerPool") + .field("runner", &"PoolRunner") + .finish() + } +} + +pub struct IndyVdrSubmitter { + pool: Arc, +} + +impl IndyVdrSubmitter { + pub fn new(pool: Arc) -> Self { + Self { pool } + } +} + +#[async_trait] +impl RequestSubmitter for IndyVdrSubmitter { + async fn submit(&self, request: PreparedRequest) -> VcxCoreResult { + // indyvdr send_request is Async via a callback. + // Use oneshot channel to send result from callback, converting the fn to future. + type VdrSendRequestResult = + Result<(RequestResult, Option>), VdrError>; + let (sender, recv) = oneshot::channel::(); + self.pool + .runner + .as_ref() + .ok_or( + // should not happen - strictly for unit testing + AriesVcxCoreError::from_msg( + AriesVcxCoreErrorKind::NoPoolOpen, + "IndyVdrLedgerPool runner was not provided", + ), + )? + .send_request( + request, + Box::new(move |result| { + // unable to handle a failure from `send` here + sender.send(result).ok(); + }), + )?; + + let send_req_result: VdrSendRequestResult = recv + .await + .map_err(|e| AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::InvalidState, e))?; + let (result, _) = send_req_result?; + + let reply = match result { + RequestResult::Reply(reply) => Ok(reply), + RequestResult::Failed(failed) => Err(failed), + }; + + Ok(reply?) + } +} diff --git a/aries_vcx_core/src/ledger/request_submitter/vdr_proxy.rs b/aries_vcx_core/src/ledger/request_submitter/vdr_proxy.rs new file mode 100644 index 0000000000..efe28ded33 --- /dev/null +++ b/aries_vcx_core/src/ledger/request_submitter/vdr_proxy.rs @@ -0,0 +1,26 @@ +use std::sync::Arc; + +use async_trait::async_trait; +use indy_vdr::pool::PreparedRequest; +use indy_vdr_proxy_client::VdrProxyClient; + +use crate::errors::error::VcxCoreResult; + +use super::RequestSubmitter; + +pub struct VdrProxySubmitter { + client: Arc, +} + +impl VdrProxySubmitter { + pub fn new(client: Arc) -> Self { + Self { client } + } +} + +#[async_trait] +impl RequestSubmitter for VdrProxySubmitter { + async fn submit(&self, request: PreparedRequest) -> VcxCoreResult { + self.client.post(request).await.map_err(|e| e.into()) + } +} diff --git a/aries_vcx_core/src/ledger/vdr_proxy_ledger.rs b/aries_vcx_core/src/ledger/vdr_proxy_ledger.rs deleted file mode 100644 index a498781c6a..0000000000 --- a/aries_vcx_core/src/ledger/vdr_proxy_ledger.rs +++ /dev/null @@ -1,360 +0,0 @@ -use indy_vdr as vdr; -use indy_vdr_proxy_client::VdrProxyClient; -use std::collections::hash_map::RandomState; -use std::collections::HashMap; -use std::fmt::{Debug, Formatter}; -use std::sync::Arc; -use time::OffsetDateTime; -use vdr::ledger::requests::schema::{AttributeNames, Schema, SchemaV1}; - -use async_trait::async_trait; -use serde_json::Value; -use tokio::sync::oneshot; -use vdr::common::error::VdrError; -use vdr::config::PoolConfig as IndyVdrPoolConfig; -use vdr::ledger::identifiers::{CredentialDefinitionId, RevocationRegistryId, SchemaId}; -use vdr::ledger::requests::author_agreement::TxnAuthrAgrmtAcceptanceData; -use vdr::ledger::RequestBuilder; -use vdr::pool::{PoolBuilder, PoolTransactions}; -use vdr::pool::{PoolRunner, PreparedRequest, ProtocolVersion, RequestResult}; -use vdr::utils::did::DidValue; -use vdr::utils::Qualifiable; - -use crate::errors::error::VcxCoreResult; -use crate::errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind}; -use crate::global::author_agreement::get_txn_author_agreement; -use crate::global::settings; -use crate::utils::json::{AsTypeOrDeserializationError, TryGetIndex}; -use crate::wallet::base_wallet::BaseWallet; - -use super::base_ledger::BaseLedger; - -pub struct VdrProxyLedger { - wallet: Arc, - client: VdrProxyClient, -} - -impl Debug for VdrProxyLedger { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.write_str("VdrProxyLedger") - } -} - -fn unimplemented_method_err(method_name: &str) -> AriesVcxCoreError { - AriesVcxCoreError::from_msg( - AriesVcxCoreErrorKind::UnimplementedFeature, - format!("method called '{}' is not yet implemented in AriesVCX", method_name), - ) -} - -fn _get_response_json_data_field(response_json: &str) -> VcxCoreResult { - let res: Value = serde_json::from_str(response_json)?; - let result = (&res).try_get("result")?; - Ok(result.try_get("data")?.to_owned()) -} - -async fn _append_txn_author_agreement_to_request(request: PreparedRequest) -> VcxCoreResult { - if let Some(taa) = get_txn_author_agreement()? { - let mut request = request; - let acceptance = TxnAuthrAgrmtAcceptanceData { - mechanism: taa.acceptance_mechanism_type, - // TODO - investigate default digest - taa_digest: taa.taa_digest.map_or(String::from(""), |v| v), - time: taa.time_of_acceptance, - }; - request.set_txn_author_agreement_acceptance(&acceptance)?; - - Ok(request) - } else { - Ok(request) - } -} - -impl VdrProxyLedger { - pub fn new(wallet: Arc, client: VdrProxyClient) -> Self { - Self { wallet, client } - } - - pub fn request_builder(&self) -> VcxCoreResult { - let v = settings::get_protocol_version(); - let version = ProtocolVersion::from_id(v as u64)?; - Ok(RequestBuilder::new(version)) - } - - async fn _sign_request(&self, submitter_did: &str, request: PreparedRequest) -> VcxCoreResult { - let to_sign = request.get_signature_input()?; - let signer_verkey = self.wallet.key_for_local_did(submitter_did).await?; - let signature = self.wallet.sign(&signer_verkey, to_sign.as_bytes()).await?; - - let request = { - let mut request = request; - request.set_signature(&signature)?; - request - }; - - Ok(request) - } - - async fn _build_get_cred_def_request( - &self, - submitter_did: Option<&str>, - cred_def_id: &str, - ) -> VcxCoreResult { - todo!() - } - - async fn _build_get_attr_request( - &self, - submitter_did: Option<&str>, - target_did: &str, - attribute_name: &str, - ) -> VcxCoreResult { - todo!() - } - - fn _build_attrib_request( - &self, - submitter_did: &str, - target_did: &str, - attrib_json_str: Option<&str>, - ) -> VcxCoreResult { - let identifier = DidValue::from_str(submitter_did)?; - let dest = DidValue::from_str(target_did)?; - let attrib_json = if let Some(attrib) = attrib_json_str { - Some(serde_json::from_str::(attrib)?) - } else { - None - }; - - Ok(self - .request_builder()? - .build_attrib_request(&identifier, &dest, None, attrib_json.as_ref(), None)?) - } - - fn _process_schema_response(response: &str) -> VcxCoreResult { - let response_json: Value = serde_json::from_str(response)?; - let result_json = (&response_json).try_get("result")?; - let data_json = result_json.try_get("data")?; - - let seq_no = result_json.get("seqNo").and_then(|x| x.as_u64().map(|x| x as u32)); - - let name = data_json.try_get("name")?; - let name = name.try_as_str()?; - let version = data_json.try_get("version")?; - let version = version.try_as_str()?; - let dest = result_json.try_get("dest")?; - let dest = dest.try_as_str()?; - let schema_id = SchemaId::new(&DidValue::from_str(dest)?, name, version); - - let attr_names = data_json.try_get("attr_names")?; - let attr_names: AttributeNames = serde_json::from_value(attr_names.to_owned())?; - - let schema = SchemaV1 { - id: schema_id, - name: name.to_string(), - version: version.to_string(), - attr_names, - seq_no, - }; - - Ok(Schema::SchemaV1(schema)) - } - - fn _process_rev_reg_delta_response(response: &str, rev_reg_id: &str) -> VcxCoreResult<(String, String, u64)> { - let res_data = _get_response_json_data_field(&response)?; - let response_value = (&res_data).try_get("value")?; - - let empty_json_list = json!([]); - - let mut delta_value = json!({ - "accum": response_value.try_get("accum_to")?.try_get("value")?.try_get("accum")?, - "issued": if let Some(v) = response_value.get("issued") { v } else { &empty_json_list }, - "revoked": if let Some(v) = response_value.get("revoked") { v } else { &empty_json_list } - }); - - if let Some(accum_from) = response_value - .get("accum_from") - .and_then(|val| (!val.is_null()).then_some(val)) - { - let prev_accum = accum_from.try_get("value")?.try_get("accum")?; - // to check - should this be 'prevAccum'? - delta_value["prev_accum"] = prev_accum.to_owned(); - } - - let reg_delta = json!({"ver": "1.0", "value": delta_value}); - - let delta_timestamp = - response_value - .try_get("accum_to")? - .try_get("txnTime")? - .as_u64() - .ok_or(AriesVcxCoreError::from_msg( - AriesVcxCoreErrorKind::InvalidJson, - "Error parsing accum_to.txnTime value as u64", - ))?; - - let response_reg_def_id = (&res_data) - .try_get("revocRegDefId")? - .as_str() - .ok_or(AriesVcxCoreError::from_msg( - AriesVcxCoreErrorKind::InvalidJson, - "Erroring parsing revocRegDefId value as string", - ))?; - if response_reg_def_id != rev_reg_id { - return Err(AriesVcxCoreError::from_msg( - AriesVcxCoreErrorKind::InvalidRevocationDetails, - "ID of revocation registry response does not match requested ID", - )); - } - - Ok(( - rev_reg_id.to_string(), - serde_json::to_string(®_delta)?, - delta_timestamp, - )) - } -} - -#[async_trait] -impl BaseLedger for VdrProxyLedger { - async fn sign_and_submit_request(&self, submitter_did: &str, request_json: &str) -> VcxCoreResult { - let request = self - ._sign_request(submitter_did, PreparedRequest::from_request_json(request_json)?) - .await?; - self.client.post(request).await.map_err(|err| err.into()) - } - - async fn submit_request(&self, request_json: &str) -> VcxCoreResult { - let request = PreparedRequest::from_request_json(request_json)?; - self.client.post(request).await.map_err(|err| err.into()) - } - - async fn endorse_transaction(&self, endorser_did: &str, request_json: &str) -> VcxCoreResult<()> { - Err(unimplemented_method_err("indy_vdr endorse_transaction")) - } - - async fn set_endorser(&self, submitter_did: &str, request_json: &str, endorser: &str) -> VcxCoreResult { - Err(unimplemented_method_err("indy_vdr set_endorser")) - } - - async fn get_txn_author_agreement(&self) -> VcxCoreResult { - self.client.get_txn_author_agreement().await.map_err(|err| err.into()) - } - - async fn get_nym(&self, did: &str) -> VcxCoreResult { - self.client.get_nym(did).await.map_err(|err| err.into()) - } - - async fn publish_nym( - &self, - submitter_did: &str, - target_did: &str, - verkey: Option<&str>, - data: Option<&str>, - role: Option<&str>, - ) -> VcxCoreResult { - let request = self - ._sign_request( - submitter_did, - self.request_builder()?.build_nym_request( - &DidValue(submitter_did.to_string()), - &DidValue(target_did.to_string()), - verkey.map(String::from), - data.map(String::from), - role.map(String::from), - )?, - ) - .await?; - self.client.post(request).await.map_err(|err| err.into()) - } - - async fn get_schema(&self, schema_id: &str, submitter_did: Option<&str>) -> VcxCoreResult { - let response = self.client.get_schema(schema_id).await?; - - let schema = Self::_process_schema_response(&response)?; - - Ok(serde_json::to_string(&schema)?) - } - - async fn get_cred_def(&self, cred_def_id: &str, submitter_did: Option<&str>) -> VcxCoreResult { - self.client.get_cred_def(cred_def_id).await.map_err(|err| err.into()) - } - - async fn get_attr(&self, target_did: &str, attr_name: &str) -> VcxCoreResult { - self.client - .get_attrib(target_did, attr_name) - .await - .map_err(|err| err.into()) - } - - async fn add_attr(&self, target_did: &str, attrib_json: &str) -> VcxCoreResult { - let request = self._build_attrib_request(target_did, target_did, Some(attrib_json))?; - let request = _append_txn_author_agreement_to_request(request).await?; - let request = self._sign_request(target_did, request).await?; - self.client.post(request).await.map_err(|err| err.into()) - } - - async fn get_rev_reg_def_json(&self, rev_reg_id: &str) -> VcxCoreResult { - self.client.get_rev_reg_def(rev_reg_id).await.map_err(|err| err.into()) - } - - async fn get_rev_reg_delta_json( - &self, - rev_reg_id: &str, - from: Option, - to: Option, - ) -> VcxCoreResult<(String, String, u64)> { - let request = self.request_builder()?.build_get_revoc_reg_delta_request( - None, - &RevocationRegistryId::from_str(rev_reg_id)?, - from.map(|x| x as i64), - to.map_or(OffsetDateTime::now_utc().unix_timestamp() as i64, |x| x as i64), - )?; - - let response = self.client.post(request).await?; - - Self::_process_rev_reg_delta_response(&response, rev_reg_id) - } - - async fn get_rev_reg(&self, rev_reg_id: &str, timestamp: u64) -> VcxCoreResult<(String, String, u64)> { - Err(unimplemented_method_err("indy_vdr get_rev_reg")) - } - - async fn get_ledger_txn(&self, seq_no: i32, submitter_did: Option<&str>) -> VcxCoreResult { - // self.client.get_txn(subledger, seq_no).await?; - Err(unimplemented_method_err("indy_vdr get_ledger_txn")) - } - - async fn build_schema_request(&self, submitter_did: &str, schema_json: &str) -> VcxCoreResult { - Err(unimplemented_method_err("indy_vdr build_schema_request")) - } - - async fn publish_schema( - &self, - schema_json: &str, - submitter_did: &str, - endorser_did: Option, - ) -> VcxCoreResult<()> { - Err(unimplemented_method_err("indy_vdr publish_cred_def")) - } - - async fn publish_cred_def(&self, cred_def_json: &str, submitter_did: &str) -> VcxCoreResult<()> { - Err(unimplemented_method_err("indy_vdr publish_rev_reg_def")) - } - - async fn publish_rev_reg_def(&self, rev_reg_def: &str, submitter_did: &str) -> VcxCoreResult<()> { - Err(unimplemented_method_err("indy_vdr publish_rev_reg_def")) - } - - async fn publish_rev_reg_delta( - &self, - rev_reg_id: &str, - rev_reg_entry_json: &str, - submitter_did: &str, - ) -> VcxCoreResult<()> { - Err(unimplemented_method_err("indy_vdr publish_rev_reg_delta")) - } -} - -#[cfg(test)] -mod unit_tests {} From b4b35ef7071a4079e51dc13b34fd178480f48abb Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Wed, 10 May 2023 18:16:45 +0200 Subject: [PATCH 06/19] Run vdrproxy tests in CI Signed-off-by: Miroslav Kovar --- .github/actions/setup-testing-rust/action.yml | 9 +++ .github/workflows/main.yml | 69 ++++++++++++++++++- ci/vdrproxy.dockerfile | 18 +++++ 3 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 ci/vdrproxy.dockerfile diff --git a/.github/actions/setup-testing-rust/action.yml b/.github/actions/setup-testing-rust/action.yml index 5809850d3c..3b652e2327 100644 --- a/.github/actions/setup-testing-rust/action.yml +++ b/.github/actions/setup-testing-rust/action.yml @@ -6,6 +6,10 @@ inputs: description: 'If true, skip spinning up docker containers' required: false default: false + skip-vdrproxy-setup: + description: 'If true, skip spinning up vdrproxy' + required: false + default: true runs: using: "composite" @@ -27,3 +31,8 @@ runs: docker run --rm -d --name indypool --network host ${{ env.DOCKER_IMAGE_POOL }} sleep 5 docker-compose -f ./ci/agency/docker-compose.yml up -d + - name: "Start vdrproxy" + if: ${{ inputs.skip-vdrproxy-setup != 'false' }} + shell: bash + run: | + docker run --rm -d --name vdrproxy --network host -e GENESIS=${{ env.GENESIS_URL }} -e PORT=${{ env.VDR_PROXY_PORT }} ${{ env.DOCKER_IMAGE_VDRPROXY }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7942cb88b6..e19404c628 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -79,10 +79,9 @@ jobs: HASH_SRC_AGENCYCLIENT=${{ hashFiles('agency_client') }} HASH_SRC_DIDDOC=${{ hashFiles('diddoc') }} HASH_SRC_MESSAGES=${{ hashFiles('messages') }} - HASH_SRC_MESSAGES_2=${{ hashFiles('messages2') }} HASH_SRC_WRAPPER_JAVA=${{ hashFiles('wrappers/java') }} - SEED_HASH_ARIESVCX=${HASH_SRC_LIBVDRTOOLS:0:11}-${HASH_SRC_ARIESVCX_CORE:0:11}-${HASH_SRC_ARIESVCX:0:11}-${HASH_SRC_AGENCYCLIENT:0:11}-${HASH_SRC_DIDDOC:0:11}-${HASH_SRC_MESSAGES:0:11}-${HASH_SRC_MESSAGES_2:0:11} + SEED_HASH_ARIESVCX=${HASH_SRC_LIBVDRTOOLS:0:11}-${HASH_SRC_ARIESVCX_CORE:0:11}-${HASH_SRC_ARIESVCX:0:11}-${HASH_SRC_AGENCYCLIENT:0:11}-${HASH_SRC_DIDDOC:0:11}-${HASH_SRC_MESSAGES:0:11}} HASH_ARIESVCX=$(echo -n "$SEED_HASH_ARIESVCX" | sha256sum | awk '{print $1}') SEED_HASH_DOCKER_LIBVCX=${HASH_ARIESVCX:0:11}-${HASH_DOCKERFILE_LIBVCX:0:11}-${HASH_SRC_LIBVCX:0:11} @@ -256,6 +255,53 @@ jobs: branch-main: ${{ env.MAIN_BRANCH }} docker-repo-local-name: ${{ env.DOCKER_REPO_LOCAL_ANDROID }} + build-docker-vdrproxy: + needs: [ workflow-setup, build-docker-alpine-core ] + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + runs-on: ubuntu-20.04 + env: + DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_VDRPROXY }} + DOCKER_IMG_CACHED_ALPINE_CORE: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ALPINE_CORE }} + BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }} + outputs: + image-name: ${{ steps.meta.outputs.tags }} + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=semver,pattern={{version}},value=${{ needs.workflow-setup.outputs.publish-version }} + flavor: | + latest=false + + # TODO: Is this step necessary? + # TODO: This step would be definitely unnecessary if alpine image was published + - name: "Load alpine core image" + uses: ./.github/actions/load-image + with: + docker-img: ${{ env.DOCKER_IMG_CACHED_ALPINE_CORE }} + + - name: Build and publish docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./ci/vdrproxy.dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + ALPINE_CORE_IMAGE=${{ env.DOCKER_IMG_CACHED_ALPINE_CORE }} ########################################################################################## ############################## DOCKER PUBLISH ######################################## @@ -420,6 +466,25 @@ jobs: - name: "Run aries-vcx tests: mysql_test" run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" test_mysql -- --include-ignored; + test-integration-aries-vcx-vdrproxy: + needs: [workflow-setup, build-docker-vdrproxy] + runs-on: ubuntu-20.04 + env: + RUST_TEST_THREADS: 1 + VDR_PROXY_CLIENT_URL: http://127.0.0.1:3030 + DOCKER_IMAGE_VDRPROXY: ${{ needs.build-docker-vdrproxy.outputs.image-name }} + GENESIS_URL: //raw.githubusercontent.com/AbsaOSS/sovrin-networks/master/genesis/127.0.0.1 + VDR_PROXY_PORT: 3030 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Setup rust testing environment" + uses: ./.github/actions/setup-testing-rust + with: + skip-vdrproxy-setup: false + - name: "Run aries-vcx tests: vdrproxy_test" + run: cargo test --manifest-path="aries_vcx/Cargo.toml" --test test_pool -F vdr_proxy_ledger -- --ignored + test-integration-libvcx: needs: workflow-setup if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} diff --git a/ci/vdrproxy.dockerfile b/ci/vdrproxy.dockerfile new file mode 100644 index 0000000000..bd0bc9d47a --- /dev/null +++ b/ci/vdrproxy.dockerfile @@ -0,0 +1,18 @@ +ARG ALPINE_CORE_IMAGE +FROM ${ALPINE_CORE_IMAGE} AS builder + +USER root +RUN apk update && apk upgrade && \ + apk add --no-cache \ + git + +USER indy +RUN git clone https://github.com/hyperledger/indy-vdr.git +WORKDIR /home/indy/indy-vdr/indy-vdr-proxy +RUN cargo build --release + +FROM alpine:3.18 +ENV PORT 3030 +ENV GENESIS genesis.txn +COPY --from=builder /home/indy/indy-vdr/target/release/indy-vdr-proxy indy-vdr-proxy +ENTRYPOINT ["./indy-vdr-proxy", "-p", "${PORT}", "-g", "${GENESIS}"] From a4e934d3d7a6e586b974698fce6c256329e8be18 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Thu, 11 May 2023 09:59:04 +0200 Subject: [PATCH 07/19] Run only relevant jobs Signed-off-by: Miroslav Kovar --- .github/actions/setup-testing-rust/action.yml | 2 +- .github/workflows/main.yml | 1804 ++++++++--------- ci/vdrproxy.dockerfile | 8 +- 3 files changed, 907 insertions(+), 907 deletions(-) diff --git a/.github/actions/setup-testing-rust/action.yml b/.github/actions/setup-testing-rust/action.yml index 3b652e2327..5952e0236b 100644 --- a/.github/actions/setup-testing-rust/action.yml +++ b/.github/actions/setup-testing-rust/action.yml @@ -32,7 +32,7 @@ runs: sleep 5 docker-compose -f ./ci/agency/docker-compose.yml up -d - name: "Start vdrproxy" - if: ${{ inputs.skip-vdrproxy-setup != 'false' }} + if: ${{ inputs.skip-vdrproxy-setup != 'true' }} shell: bash run: | docker run --rm -d --name vdrproxy --network host -e GENESIS=${{ env.GENESIS_URL }} -e PORT=${{ env.VDR_PROXY_PORT }} ${{ env.DOCKER_IMAGE_VDRPROXY }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e19404c628..b3904c706f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,7 @@ name: CI on: push: branches: - - main + - "**" pull_request: branches: - "**" @@ -18,23 +18,24 @@ env: DOCKER_REPO_LOCAL_ALPINE_CORE: alpine-core DOCKER_REPO_LOCAL_LIBVCX: libvcx DOCKER_REPO_LOCAL_ANDROID: android-test + DOCKER_REPO_LOCAL_VDRPROXY: vdrproxy RUST_TOOLCHAIN_VERSON: 1.65.0 NODE_VERSION: 18.x jobs: - verify-code-formatting: - runs-on: ubuntu-20.04 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.65.0 - components: rustfmt, clippy - - name: "Verify code formatting" - run: | - cargo fmt --check +# verify-code-formatting: +# runs-on: ubuntu-20.04 +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - uses: actions-rs/toolchain@v1 +# with: +# toolchain: 1.65.0 +# components: rustfmt, clippy +# - name: "Verify code formatting" +# run: | +# cargo fmt --check workflow-setup: runs-on: ubuntu-20.04 @@ -53,6 +54,7 @@ jobs: DOCKER_IMG_CACHED_ALPINE_CORE: ${{ steps.docker-imgs.outputs.DOCKER_IMG_CACHED_ALPINE_CORE }} DOCKER_IMG_CACHED_LIBVCX: ${{ steps.docker-imgs.outputs.DOCKER_IMG_CACHED_LIBVCX }} DOCKER_IMG_CACHED_ANDROID: ${{ steps.docker-imgs.outputs.DOCKER_IMG_CACHED_ANDROID }} + DOCKER_IMG_CACHED_VDRPROXY: ${{ steps.docker-imgs.outputs.DOCKER_IMG_CACHED_VDRPROXY }} steps: - name: "Git checkout" uses: actions/checkout@v1 @@ -72,6 +74,7 @@ jobs: HASH_DOCKERFILE_ALPINE_CORE=${{ hashFiles('ci/alpine_core.dockerfile')}} HASH_DOCKERFILE_LIBVCX=${{ hashFiles('ci/libvcx.dockerfile') }} + HASH_DOCKERFILE_VDRPROXY=${{ hashFiles('ci/vdrproxy.dockerfile') }} HASH_SRC_LIBVDRTOOLS=${{ hashFiles('libvdrtools') }} HASH_SRC_LIBVCX=${{ hashFiles('libvcx') }} HASH_SRC_ARIESVCX=${{ hashFiles('aries_vcx') }} @@ -93,6 +96,7 @@ jobs: echo "DOCKER_IMG_CACHED_ALPINE_CORE=$DOCKER_REPO_LOCAL_ALPINE_CORE:$HASH_DOCKERFILE_ALPINE_CORE" >> $GITHUB_OUTPUT echo "DOCKER_IMG_CACHED_LIBVCX=$DOCKER_REPO_LOCAL_LIBVCX:$HASH_DOCKER_LIBVCX" >> $GITHUB_OUTPUT echo "DOCKER_IMG_CACHED_ANDROID=$DOCKER_REPO_LOCAL_ANDROID:$HASH_DOCKER_ANDROID" >> $GITHUB_OUTPUT + echo "DOCKER_IMG_CACHED_VDRPROXY=$DOCKER_REPO_LOCAL_VDRPROXY:$HASH_DOCKERFILE_VDRPROXY" >> $GITHUB_OUTPUT workflow-setup-check: runs-on: ubuntu-20.04 @@ -112,67 +116,68 @@ jobs: echo "DOCKER_IMG_CACHED_ALPINE_CORE ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ALPINE_CORE }}" echo "DOCKER_IMG_CACHED_LIBVCX ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_LIBVCX }}" echo "DOCKER_IMG_CACHED_ANDROID ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }}" - - clippy-aries-vcx: - runs-on: ubuntu-20.04 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.65.0 - components: rustfmt, clippy - - name: "Install dependencies" - shell: bash - run: | - sudo apt-get update -y - sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev - - name: "Verify clippy warnings" - run: | - cd aries_vcx && cargo clippy - - clippy-libvcx: - runs-on: ubuntu-20.04 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.65.0 - components: rustfmt, clippy - - name: "Install dependencies" - shell: bash - run: | - sudo apt-get update -y - sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev - - name: "Verify clippy warnings" - run: | - cd libvcx && cargo clippy - - check-aries-vcx-feature-variants: - runs-on: ubuntu-20.04 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.65.0 - components: rustfmt, clippy - - name: "Install dependencies" - shell: bash - run: | - sudo apt-get update -y - sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev - - name: "Verify aries_vcx compiles with different dependency feature variants" - run: | - cd aries_vcx - cargo check - cargo check --no-default-features - cargo check --features vdrtools --no-default-features - cargo check --features modular_libs --no-default-features - - ########################################################################################## - ############################## DOCKER BUILD ########################################## + echo "DOCKER_IMG_CACHED_VDRPROXY ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_VDRPROXY }}" + +# clippy-aries-vcx: +# runs-on: ubuntu-20.04 +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - uses: actions-rs/toolchain@v1 +# with: +# toolchain: 1.65.0 +# components: rustfmt, clippy +# - name: "Install dependencies" +# shell: bash +# run: | +# sudo apt-get update -y +# sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev +# - name: "Verify clippy warnings" +# run: | +# cd aries_vcx && cargo clippy +# +# clippy-libvcx: +# runs-on: ubuntu-20.04 +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - uses: actions-rs/toolchain@v1 +# with: +# toolchain: 1.65.0 +# components: rustfmt, clippy +# - name: "Install dependencies" +# shell: bash +# run: | +# sudo apt-get update -y +# sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev +# - name: "Verify clippy warnings" +# run: | +# cd libvcx && cargo clippy +# +# check-aries-vcx-feature-variants: +# runs-on: ubuntu-20.04 +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - uses: actions-rs/toolchain@v1 +# with: +# toolchain: 1.65.0 +# components: rustfmt, clippy +# - name: "Install dependencies" +# shell: bash +# run: | +# sudo apt-get update -y +# sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev +# - name: "Verify aries_vcx compiles with different dependency feature variants" +# run: | +# cd aries_vcx +# cargo check +# cargo check --no-default-features +# cargo check --features vdrtools --no-default-features +# cargo check --features modular_libs --no-default-features +# +# ########################################################################################## +# ############################## DOCKER BUILD ########################################## build-docker-alpine-core: needs: workflow-setup @@ -199,69 +204,69 @@ jobs: branch-main: ${{ env.MAIN_BRANCH }} docker-repo-local-name: ${{ env.DOCKER_REPO_LOCAL_ALPINE_CORE }} - build-docker-libvcx: - needs: [ workflow-setup, build-docker-alpine-core ] - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - runs-on: ubuntu-20.04 - env: - DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_LIBVCX }} - DOCKER_IMG_CACHED_ALPINE_CORE: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ALPINE_CORE }} - BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }} - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Docker Login" - uses: azure/docker-login@v1 - with: - login-server: ${{ env.URL_DOCKER_REGISTRY }} - username: $GITHUB_ACTOR - password: ${{ secrets.GITHUB_TOKEN }} - - name: "Load alpine core image" - uses: ./.github/actions/load-image - with: - docker-img: ${{ env.DOCKER_IMG_CACHED_ALPINE_CORE }} - - name: "Build and cache image" - uses: ./.github/actions/build-image - with: - docker-img: ${{ env.DOCKER_IMG_CACHED }} - build-arg: "ALPINE_CORE_IMAGE=$DOCKER_IMG_CACHED_ALPINE_CORE" - dockerfile-path: "ci/libvcx.dockerfile" - branch-name: ${{ env.BRANCH_NAME }} - branch-main: ${{ env.MAIN_BRANCH }} - docker-repo-local-name: ${{ env.DOCKER_REPO_LOCAL_LIBVCX }} - - build-docker-android: - needs: workflow-setup - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true'}} - runs-on: ubuntu-20.04 - env: - DOCKER_IMG_CACHED: ${{needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID}} - BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }} - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Docker Login" - uses: azure/docker-login@v1 - with: - login-server: ${{ env.URL_DOCKER_REGISTRY }} - username: $GITHUB_ACTOR - password: ${{ secrets.GITHUB_TOKEN }} - - name: "Build and cache image" - uses: ./.github/actions/build-image - with: - docker-img: ${{ env.DOCKER_IMG_CACHED }} - dockerfile-path: "wrappers/java/ci/android.dockerfile" - branch-name: ${{ env.BRANCH_NAME }} - branch-main: ${{ env.MAIN_BRANCH }} - docker-repo-local-name: ${{ env.DOCKER_REPO_LOCAL_ANDROID }} +# build-docker-libvcx: +# needs: [ workflow-setup, build-docker-alpine-core ] +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# runs-on: ubuntu-20.04 +# env: +# DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_LIBVCX }} +# DOCKER_IMG_CACHED_ALPINE_CORE: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ALPINE_CORE }} +# BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }} +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Docker Login" +# uses: azure/docker-login@v1 +# with: +# login-server: ${{ env.URL_DOCKER_REGISTRY }} +# username: $GITHUB_ACTOR +# password: ${{ secrets.GITHUB_TOKEN }} +# - name: "Load alpine core image" +# uses: ./.github/actions/load-image +# with: +# docker-img: ${{ env.DOCKER_IMG_CACHED_ALPINE_CORE }} +# - name: "Build and cache image" +# uses: ./.github/actions/build-image +# with: +# docker-img: ${{ env.DOCKER_IMG_CACHED }} +# build-arg: "ALPINE_CORE_IMAGE=$DOCKER_IMG_CACHED_ALPINE_CORE" +# dockerfile-path: "ci/libvcx.dockerfile" +# branch-name: ${{ env.BRANCH_NAME }} +# branch-main: ${{ env.MAIN_BRANCH }} +# docker-repo-local-name: ${{ env.DOCKER_REPO_LOCAL_LIBVCX }} +# +# build-docker-android: +# needs: workflow-setup +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true'}} +# runs-on: ubuntu-20.04 +# env: +# DOCKER_IMG_CACHED: ${{needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID}} +# BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }} +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Docker Login" +# uses: azure/docker-login@v1 +# with: +# login-server: ${{ env.URL_DOCKER_REGISTRY }} +# username: $GITHUB_ACTOR +# password: ${{ secrets.GITHUB_TOKEN }} +# - name: "Build and cache image" +# uses: ./.github/actions/build-image +# with: +# docker-img: ${{ env.DOCKER_IMG_CACHED }} +# dockerfile-path: "wrappers/java/ci/android.dockerfile" +# branch-name: ${{ env.BRANCH_NAME }} +# branch-main: ${{ env.MAIN_BRANCH }} +# docker-repo-local-name: ${{ env.DOCKER_REPO_LOCAL_ANDROID }} build-docker-vdrproxy: needs: [ workflow-setup, build-docker-alpine-core ] if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} runs-on: ubuntu-20.04 env: - DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_VDRPROXY }} DOCKER_IMG_CACHED_ALPINE_CORE: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ALPINE_CORE }} + DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_VDRPROXY }} BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }} outputs: image-name: ${{ steps.meta.outputs.tags }} @@ -274,197 +279,182 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ github.repository }} - tags: | - type=semver,pattern={{version}},value=${{ needs.workflow-setup.outputs.publish-version }} - flavor: | - latest=false - - # TODO: Is this step necessary? - # TODO: This step would be definitely unnecessary if alpine image was published - name: "Load alpine core image" uses: ./.github/actions/load-image with: docker-img: ${{ env.DOCKER_IMG_CACHED_ALPINE_CORE }} - - - name: Build and publish docker image - uses: docker/build-push-action@v4 - with: - context: . - file: ./ci/vdrproxy.dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - cache-from: type=gha - cache-to: type=gha,mode=max - build-args: | - ALPINE_CORE_IMAGE=${{ env.DOCKER_IMG_CACHED_ALPINE_CORE }} - - ########################################################################################## - ############################## DOCKER PUBLISH ######################################## - - publish-docker-libvcx: - runs-on: ubuntu-20.04 - needs: [ workflow-setup, build-docker-libvcx ] - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - env: - DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_LIBVCX }} - PUBLISH_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} - BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }} - IS_FORK: ${{ needs.workflow-setup.outputs.IS_FORK }} - steps: - - name: "Git checkout" - if: ${{ env.IS_FORK == 'false' }} - uses: actions/checkout@v3 - - name: "Docker Login" - uses: azure/docker-login@v1 - with: - login-server: ${{ env.URL_DOCKER_REGISTRY }} - username: $GITHUB_ACTOR - password: ${{ secrets.GITHUB_TOKEN }} - - name: "Publish versioned image" - if: ${{ env.IS_FORK == 'false' }} - uses: ./.github/actions/publish-image + - name: "Build and cache image" + uses: ./.github/actions/build-image with: docker-img: ${{ env.DOCKER_IMG_CACHED }} - publish-version: ${{ env.PUBLISH_VERSION }} - - ########################################################################################## - ############################### CODECOV ########################################### - - code-coverage-aries-vcx-unit-tests: - needs: workflow-setup - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - runs-on: ubuntu-20.04 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Setup rust codecov environment" - uses: ./.github/actions/setup-codecov-rust - with: - skip-docker-setup: true - - name: "Run workspace tests: general_test" - run: | - RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ - RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ - RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --package aries-vcx; - - mkdir -p /tmp/artifacts/coverage - grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o /tmp/artifacts/coverage/coverage.lcov - - name: "Upload coverage to Codecov" - uses: codecov/codecov-action@v2 - with: - directory: /tmp/artifacts/coverage - flags: unittests-aries-vcx - name: codecov-unit-aries-vcx - fail_ci_if_error: true - path_to_write_report: /tmp/artifacts/coverage/codecov_report.gz - - uses: actions/upload-artifact@v3 - with: - name: code-coverage-report-unit-aries-vcx - path: /tmp/artifacts/coverage - - code-coverage-aries-vcx-integration-tests: - needs: workflow-setup - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - runs-on: ubuntu-20.04 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Setup rust codecov environment" - uses: ./.github/actions/setup-codecov-rust - - name: "Run workspace tests: pool_tests agency_pool_tests" - run: | - RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ - RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ - RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --package aries-vcx -- --ignored; - - mkdir -p /tmp/artifacts/coverage - grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o /tmp/artifacts/coverage/coverage.lcov - - name: "Upload coverage to Codecov" - uses: codecov/codecov-action@v2 - with: - directory: /tmp/artifacts/coverage - flags: unittests-aries-vcx - name: codecov-unit-aries-vcx - fail_ci_if_error: true - path_to_write_report: /tmp/artifacts/coverage/codecov_report.gz - - uses: actions/upload-artifact@v3 - with: - name: code-coverage-report-unit-aries-vcx - path: /tmp/artifacts/coverage - - #TODO - can this be included within code-coverage-aries-vcx-integration-tests? - code-coverage-aries-vcx-modular-dependencies-integration-tests: - needs: workflow-setup - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - runs-on: ubuntu-20.04 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Setup rust codecov environment" - uses: ./.github/actions/setup-codecov-rust - - name: "Run workspace tests: modular_libs_tests pool_tests agency_pool_tests" - run: | - RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ - RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ - RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --package aries-vcx -F 'modular_libs' -- --ignored; - - mkdir -p /tmp/artifacts/coverage - grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o /tmp/artifacts/coverage/coverage.lcov - - name: "Upload coverage to Codecov" - uses: codecov/codecov-action@v2 - with: - directory: /tmp/artifacts/coverage - flags: unittests-aries-vcx - name: codecov-unit-aries-vcx - fail_ci_if_error: true - path_to_write_report: /tmp/artifacts/coverage/codecov_report.gz - - uses: actions/upload-artifact@v3 - with: - name: code-coverage-report-unit-aries-vcx - path: /tmp/artifacts/coverage + dockerfile-path: "ci/vdrproxy.dockerfile" + build-arg: "ALPINE_CORE_IMAGE=$DOCKER_IMG_CACHED_ALPINE_CORE" + branch-name: ${{ env.BRANCH_NAME }} + branch-main: ${{ env.MAIN_BRANCH }} + docker-repo-local-name: ${{ env.DOCKER_REPO_LOCAL_VDRPROXY }} ########################################################################################## - ############################### TESTING ########################################### - - test-unit-workspace: - needs: workflow-setup - runs-on: ubuntu-20.04 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Setup rust testing environment" - uses: ./.github/actions/setup-testing-rust - with: - skip-docker-setup: true - - name: "Run workspace tests: general_test" - run: RUST_TEST_THREADS=1 cargo test --workspace --lib --exclude aries-vcx-agent --exclude libvdrtools - - test-integration-aries-vcx: - needs: workflow-setup - runs-on: ubuntu-20.04 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Setup rust testing environment" - uses: ./.github/actions/setup-testing-rust - - name: "Run aries-vcx tests: pool_tests agency_pool_tests" - run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" -- --ignored; + ############################## DOCKER PUBLISH ######################################## - test-integration-aries-vcx-mysql: - needs: workflow-setup - runs-on: ubuntu-20.04 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Setup rust testing environment" - uses: ./.github/actions/setup-testing-rust - - name: "Run aries-vcx tests: mysql_test" - run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" test_mysql -- --include-ignored; +# publish-docker-libvcx: +# runs-on: ubuntu-20.04 +# needs: [ workflow-setup, build-docker-libvcx ] +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# env: +# DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_LIBVCX }} +# PUBLISH_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} +# BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }} +# IS_FORK: ${{ needs.workflow-setup.outputs.IS_FORK }} +# steps: +# - name: "Git checkout" +# if: ${{ env.IS_FORK == 'false' }} +# uses: actions/checkout@v3 +# - name: "Docker Login" +# uses: azure/docker-login@v1 +# with: +# login-server: ${{ env.URL_DOCKER_REGISTRY }} +# username: $GITHUB_ACTOR +# password: ${{ secrets.GITHUB_TOKEN }} +# - name: "Publish versioned image" +# if: ${{ env.IS_FORK == 'false' }} +# uses: ./.github/actions/publish-image +# with: +# docker-img: ${{ env.DOCKER_IMG_CACHED }} +# publish-version: ${{ env.PUBLISH_VERSION }} +# +# ########################################################################################## +# ############################### CODECOV ########################################### +# +# code-coverage-aries-vcx-unit-tests: +# needs: workflow-setup +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# runs-on: ubuntu-20.04 +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Setup rust codecov environment" +# uses: ./.github/actions/setup-codecov-rust +# with: +# skip-docker-setup: true +# - name: "Run workspace tests: general_test" +# run: | +# RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ +# RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ +# RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --package aries-vcx; +# +# mkdir -p /tmp/artifacts/coverage +# grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o /tmp/artifacts/coverage/coverage.lcov +# - name: "Upload coverage to Codecov" +# uses: codecov/codecov-action@v2 +# with: +# directory: /tmp/artifacts/coverage +# flags: unittests-aries-vcx +# name: codecov-unit-aries-vcx +# fail_ci_if_error: true +# path_to_write_report: /tmp/artifacts/coverage/codecov_report.gz +# - uses: actions/upload-artifact@v3 +# with: +# name: code-coverage-report-unit-aries-vcx +# path: /tmp/artifacts/coverage +# +# code-coverage-aries-vcx-integration-tests: +# needs: workflow-setup +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# runs-on: ubuntu-20.04 +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Setup rust codecov environment" +# uses: ./.github/actions/setup-codecov-rust +# - name: "Run workspace tests: pool_tests agency_pool_tests" +# run: | +# RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ +# RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ +# RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --package aries-vcx -- --ignored; +# +# mkdir -p /tmp/artifacts/coverage +# grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o /tmp/artifacts/coverage/coverage.lcov +# - name: "Upload coverage to Codecov" +# uses: codecov/codecov-action@v2 +# with: +# directory: /tmp/artifacts/coverage +# flags: unittests-aries-vcx +# name: codecov-unit-aries-vcx +# fail_ci_if_error: true +# path_to_write_report: /tmp/artifacts/coverage/codecov_report.gz +# - uses: actions/upload-artifact@v3 +# with: +# name: code-coverage-report-unit-aries-vcx +# path: /tmp/artifacts/coverage +# +# #TODO - can this be included within code-coverage-aries-vcx-integration-tests? +# code-coverage-aries-vcx-modular-dependencies-integration-tests: +# needs: workflow-setup +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# runs-on: ubuntu-20.04 +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Setup rust codecov environment" +# uses: ./.github/actions/setup-codecov-rust +# - name: "Run workspace tests: modular_libs_tests pool_tests agency_pool_tests" +# run: | +# RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ +# RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ +# RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --package aries-vcx -F 'modular_libs' -- --ignored; +# +# mkdir -p /tmp/artifacts/coverage +# grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o /tmp/artifacts/coverage/coverage.lcov +# - name: "Upload coverage to Codecov" +# uses: codecov/codecov-action@v2 +# with: +# directory: /tmp/artifacts/coverage +# flags: unittests-aries-vcx +# name: codecov-unit-aries-vcx +# fail_ci_if_error: true +# path_to_write_report: /tmp/artifacts/coverage/codecov_report.gz +# - uses: actions/upload-artifact@v3 +# with: +# name: code-coverage-report-unit-aries-vcx +# path: /tmp/artifacts/coverage +# +# ########################################################################################## +# ############################### TESTING ########################################### +# +# test-unit-workspace: +# needs: workflow-setup +# runs-on: ubuntu-20.04 +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Setup rust testing environment" +# uses: ./.github/actions/setup-testing-rust +# with: +# skip-docker-setup: true +# - name: "Run workspace tests: general_test" +# run: RUST_TEST_THREADS=1 cargo test --workspace --lib --exclude aries-vcx-agent --exclude libvdrtools +# +# test-integration-aries-vcx: +# needs: workflow-setup +# runs-on: ubuntu-20.04 +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Setup rust testing environment" +# uses: ./.github/actions/setup-testing-rust +# - name: "Run aries-vcx tests: pool_tests agency_pool_tests" +# run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" -- --ignored; +# +# test-integration-aries-vcx-mysql: +# needs: workflow-setup +# runs-on: ubuntu-20.04 +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Setup rust testing environment" +# uses: ./.github/actions/setup-testing-rust +# - name: "Run aries-vcx tests: mysql_test" +# run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" test_mysql -- --include-ignored; test-integration-aries-vcx-vdrproxy: needs: [workflow-setup, build-docker-vdrproxy] @@ -472,12 +462,16 @@ jobs: env: RUST_TEST_THREADS: 1 VDR_PROXY_CLIENT_URL: http://127.0.0.1:3030 - DOCKER_IMAGE_VDRPROXY: ${{ needs.build-docker-vdrproxy.outputs.image-name }} - GENESIS_URL: //raw.githubusercontent.com/AbsaOSS/sovrin-networks/master/genesis/127.0.0.1 + DOCKER_IMAGE_VDRPROXY: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_VDRPROXY }} + GENESIS_URL: https://raw.githubusercontent.com/AbsaOSS/sovrin-networks/master/genesis/127.0.0.1 VDR_PROXY_PORT: 3030 steps: - name: "Git checkout" uses: actions/checkout@v3 + - name: "Load android image" + uses: ./.github/actions/load-image + with: + docker-img: ${{ env.DOCKER_IMAGE_VDRPROXY }} - name: "Setup rust testing environment" uses: ./.github/actions/setup-testing-rust with: @@ -485,594 +479,594 @@ jobs: - name: "Run aries-vcx tests: vdrproxy_test" run: cargo test --manifest-path="aries_vcx/Cargo.toml" --test test_pool -F vdr_proxy_ledger -- --ignored - test-integration-libvcx: - needs: workflow-setup - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - runs-on: ubuntu-20.04 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Setup rust testing environment" - uses: ./.github/actions/setup-testing-rust - - name: "Run libvcx tests: pool_tests" - run: | - RUST_TEST_THREADS=1 cargo test --manifest-path="libvcx/Cargo.toml" -F "pool_tests"; - - test-integration-resolver: - needs: workflow-setup - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - runs-on: ubuntu-20.04 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Setup rust testing environment" - uses: ./.github/actions/setup-testing-rust - - name: "Run resolver tests" - run: | - RUST_TEST_THREADS=1 cargo test -p did_doc_builder -p did_parser -p did_resolver -p did_resolver_registry -p did_resolver_sov -p did_resolver_web --test "*" - - test-node-wrapper: - needs: workflow-setup - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - runs-on: ubuntu-22.04 - strategy: - matrix: - node-version: [18.x] - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Setup NodeJS libvcx testing environment" - uses: ./.github/actions/setup-testing-nodejs - with: - skip-docker-setup: true - node-version: ${{ matrix.node-version }} - - name: "Run tests" - run: cd wrappers/node && RUST_LOG=vcx=trace npm run test - - test-integration-node-wrapper: - needs: workflow-setup - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - runs-on: ubuntu-22.04 - strategy: - matrix: - node-version: [18.x] - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Setup NodeJS libvcx testing environment" - uses: ./.github/actions/setup-testing-nodejs - with: - node-version: ${{ matrix.node-version }} - - name: "Install vcxagent-core dependencies" - run: (cd agents/node/vcxagent-core && npm install) - - name: "Run demo" - run: (cd agents/node/vcxagent-core && AGENCY_URL=http://localhost:8080 npm run demo) - - name: "Run demo with revocation" - run: (cd agents/node/vcxagent-core && AGENCY_URL=http://localhost:8080 npm run demo:revocation) - - name: "Run integration tests" - run: (cd agents/node/vcxagent-core && AGENCY_URL=http://localhost:8080 npm run test:integration) - - test-android-build: - runs-on: ubuntu-20.04 - needs: [ workflow-setup, build-docker-android ] - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true' }} - env: - DOCKER_IMG_CACHED_ANDROID: ${{needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID}} - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Docker Login" - uses: azure/docker-login@v1 - with: - login-server: ${{ env.URL_DOCKER_REGISTRY }} - username: $GITHUB_ACTOR - password: ${{ secrets.GITHUB_TOKEN }} - - name: "Load android image" - uses: ./.github/actions/load-image - with: - docker-img: ${{ env.DOCKER_IMG_CACHED_ANDROID }} - - name: "Run android tests" - run: | - rm -rf /tmp/imgcache - docker run --rm -i $DOCKER_IMG_CACHED_ANDROID \ - sh -c '(cd $HOME/aries-vcx && ./wrappers/java/ci/android.test.sh armv7)' - - build-and-publish-ios-wrapper: - needs: workflow-setup - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_IOS != 'true' }} - runs-on: macos-11 - env: - LIBVCX_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} - PUBLISH_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} - steps: - - name: "Git checkout" - uses: actions/checkout@v2 - - name: Switch to xcode version 12.4 - run: | - sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer - xcodebuild -version - - name: "Build iOS wrapper" - run: | - ./wrappers/ios/ci/build.sh - - uses: actions/upload-artifact@v3 - with: - name: libvcx-ios-${{ env.PUBLISH_VERSION }}-device - path: /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-device.zip - - uses: actions/upload-artifact@v3 - with: - name: libvcx-ios-${{ env.PUBLISH_VERSION }}-universal - path: /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-universal.zip - - build-and-publish-ios-legacy-wrapper: - needs: workflow-setup - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_IOS != 'true' }} - runs-on: macos-11 - env: - LIBVCX_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} - PUBLISH_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} - steps: - - name: "Git checkout" - uses: actions/checkout@v2 - - name: Switch to xcode version 12.4 - run: | - sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer - xcodebuild -version - - name: "Build Legacy iOS wrapper" - run: | - ./wrappers/ios_legacy/ci/build.sh - - name: "Rename device as legacy" - run: | - mv /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-device.zip /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-device.zip - - name: "Rename universal as legacy" - run: | - mv /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-universal.zip /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-universal.zip - - uses: actions/upload-artifact@v3 - with: - name: libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-device - path: /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-device.zip - - uses: actions/upload-artifact@v3 - with: - name: libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-universal - path: /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-universal.zip - - build-and-publish-android-device: - runs-on: ubuntu-20.04 - needs: [ workflow-setup, build-docker-android ] - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true' }} - env: - FULL_VERSION_NAME: libvcx-android-${{needs.workflow-setup.outputs.PUBLISH_VERSION}}-device - DOCKER_IMG_CACHED_ANDROID: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Docker Login" - uses: azure/docker-login@v1 - with: - login-server: ${{ env.URL_DOCKER_REGISTRY }} - username: $GITHUB_ACTOR - password: ${{ secrets.GITHUB_TOKEN }} - - name: "Load android image" - uses: ./.github/actions/load-image - with: - docker-img: ${{ env.DOCKER_IMG_CACHED_ANDROID }} - - name: "Build, run android wrapper tests, and publish artifacts" - uses: ./.github/actions/publish-android - with: - abis: "arm arm64" - docker-img-name: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} - full-version-name: ${{ env.FULL_VERSION_NAME }} - - name: "Publish aar artifact" - uses: actions/upload-artifact@v3 - with: - name: ${{ env.FULL_VERSION_NAME }} - path: /tmp/artifacts/aar/${{ env.FULL_VERSION_NAME }}.aar - - build-and-publish-android-emulator: - runs-on: ubuntu-20.04 - needs: [ workflow-setup, build-docker-android ] - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true' }} - env: - FULL_VERSION_NAME: libvcx-android-${{needs.workflow-setup.outputs.PUBLISH_VERSION}}-emulator - DOCKER_IMG_CACHED_ANDROID: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Docker Login" - uses: azure/docker-login@v1 - with: - login-server: ${{ env.URL_DOCKER_REGISTRY }} - username: $GITHUB_ACTOR - password: ${{ secrets.GITHUB_TOKEN }} - - name: "Load android image" - uses: ./.github/actions/load-image - with: - docker-img: ${{ env.DOCKER_IMG_CACHED_ANDROID }} - - name: "Build, run android wrapper tests, and publish artifacts" - uses: ./.github/actions/publish-android - with: - abis: "x86 x86_64" - docker-img-name: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} - full-version-name: ${{ env.FULL_VERSION_NAME }} - - uses: actions/upload-artifact@v3 - with: - name: ${{ env.FULL_VERSION_NAME }} - path: /tmp/artifacts/aar/${{ env.FULL_VERSION_NAME }}.aar - - build-and-publish-ubuntu-lib: - needs: workflow-setup - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - runs-on: ubuntu-20.04 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.65.0 - - uses: Swatinem/rust-cache@v2 - with: - key: "11" - - name: "Install dependencies" - shell: bash - run: | - sudo apt-get update -y - sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev - - name: "Build libvcx.so" - run: cargo build --release - - name: "Publish artifact libvcx.so" - uses: actions/upload-artifact@v3 - with: - name: libvcx.so - path: target/release/libvcx.so - - build-and-publish-darwin-lib: - needs: workflow-setup - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - runs-on: macos-11 - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.65.0 - - uses: Swatinem/rust-cache@v2 - with: - key: "11" - - name: "Install dependencies" - shell: bash - run: | - brew install openssl - brew install zeromq - brew install libsodium - brew install pkg-config - - name: "Build libvcx.dylib" - run: cargo build --release - - name: "Publish artifact libvcx.dylib" - uses: actions/upload-artifact@v3 - with: - name: libvcx.dylib - path: target/release/libvcx.dylib - - ########################################################################################## - ############################ NPMJS PUBLISHING ####################################### - - publish-node-wrapper: - runs-on: ubuntu-20.04 - needs: - - workflow-setup - - test-unit-workspace - - test-integration-libvcx - - test-integration-aries-vcx - - test-integration-aries-vcx-mysql - - test-node-wrapper - - test-integration-node-wrapper - - publish-napi - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - env: - PUBLISH_VERSION: ${{needs.workflow-setup.outputs.PUBLISH_VERSION}} - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Use Node.js 18" - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - - name: "Publish package" - run: | - if [[ "$PUBLISH_VERSION" ]] - then - NPMJS_TOKEN=${{ secrets.NPMJS_TOKEN }} PUBLISH_VERSION=${{ env.PUBLISH_VERSION }} ./wrappers/node/publish.sh - else - echo "New version was not defined, skipping release." - fi - - publish-agent-core: - runs-on: ubuntu-20.04 - needs: - - workflow-setup - - test-unit-workspace - - test-integration-libvcx - - test-integration-aries-vcx - - test-integration-aries-vcx-mysql - - test-node-wrapper - - test-integration-node-wrapper - - publish-napi - - publish-node-wrapper - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - env: - NPMJS_TOKEN: ${{ secrets.NPMJS_TOKEN }} - PUBLISH_VERSION: ${{needs.workflow-setup.outputs.PUBLISH_VERSION}} - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - name: "Use Node.js 18" - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - - name: "Release agent-core package" - run: | - if [[ "$PUBLISH_VERSION" ]] - then - NPMJS_TOKEN=${{ secrets.NPMJS_TOKEN }} PUBLISH_VERSION=${{ env.PUBLISH_VERSION }} ./agents/node/vcxagent-core/publish.sh - else - echo "New version was not defined, skipping release." - fi - - build-napi: - needs: - - workflow-setup - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - strategy: - fail-fast: false - matrix: - settings: - - host: ubuntu-20.04 - target: x86_64-unknown-linux-gnu - build: |- - set -e - sudo apt-get update -y - sudo apt-get install -y libssl-dev libzmq3-dev - npm run build:napi -- --target x86_64-unknown-linux-gnu - strip *.node - - host: ubuntu-20.04 - target: x86_64-unknown-linux-musl - docker: ghcr.io/hyperledger/aries-vcx/napi-rs-alpine - build: |- - set -e - cd wrappers/vcx-napi-rs - npm run build:napi - strip *.node - - host: macos-latest - target: x86_64-apple-darwin - build: | - brew install openssl zmq pkg-config - npm run build:napi - strip -x *.node - - host: macos-latest - target: aarch64-apple-darwin - skip: ${{ needs.workflow-setup.outputs.SKIP_NAPI_M1 }} - build: | - wget https://github.com/macports/macports-base/releases/download/v2.8.0/MacPorts-2.8.0-12-Monterey.pkg - sudo installer -pkg ./MacPorts-2.8.0-12-Monterey.pkg -target / - export PATH=/opt/local/bin:/opt/local/sbin:$PATH - - sudo port install openssl +universal zmq +universal - export OPENSSL_DIR=/opt/local - export OPENSSL_INCLUDE_DIR=/opt/local/include/ - export OPENSSL_LIB_DIR=/opt/local/lib/ - - export SODIUM_LIB_DIR=/opt/local/lib/ - export SODIUM_INCLUDE_DIR=/opt/local/include - - export LIBZMQ_LIB_DIR=/opt/local/lib/ - export LIBZMQ_INCLUDE_DIR=/opt/local/include - - export PKG_CONFIG_ALLOW_CROSS=1 - export PKG_CONFIG_SYSROOT_DIR=/ - export RUST_BACKTRACE=1 - npm run build:napi -- --target aarch64-apple-darwin - strip -x *.node - name: ${{ matrix.settings.target }} - runs-on: ${{ matrix.settings.host }} - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/build-napi - if: ${{ matrix.settings.skip != 'true' }} - with: - docker: ${{ matrix.settings.docker }} - target: ${{ matrix.settings.target }} - build: ${{ matrix.settings.build }} - node-version: ${{ env.NODE_VERSION }} - rust-version: ${{ env.RUST_TOOLCHAIN_VERSON }} - - publish-napi: - runs-on: ubuntu-20.04 - needs: - - workflow-setup - - build-napi - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/publish-napi - with: - publish-version: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} - npmjs-token: ${{ secrets.NPMJS_TOKEN }} - node-version: ${{ env.NODE_VERSION }} - - ########################################################################################## - ############################## RELEASE ######################################### - - make-release: - runs-on: ubuntu-20.04 - needs: - - workflow-setup - - build-and-publish-ios-wrapper - - build-and-publish-ios-legacy-wrapper - - build-and-publish-android-device - - build-and-publish-android-emulator - - test-unit-workspace - - test-integration-libvcx - - test-integration-aries-vcx - - test-integration-aries-vcx-mysql - - test-android-build - - test-node-wrapper - - test-integration-node-wrapper - if: ${{ needs.workflow-setup.outputs.RELEASE == 'true' || needs.workflow-setup.outputs.PRERELEASE == 'true' }} - outputs: - RELEASE_UPLOAD_URL: ${{ steps.create-release.outputs.upload_url }} - steps: - - name: "Git checkout" - uses: actions/checkout@v2 - - name: "Generate changelog" - uses: heinrichreimer/action-github-changelog-generator@v2.3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - futureRelease: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} - releaseBranch: main - pullRequests: true - unreleased: false - unreleasedOnly: false - issuesWoLabels: true - prWoLabels: true - stripGeneratorNotice: true - stripHeaders: false - maxIssues: 50 - excludeLabels: duplicate,question,invalid,wontfix,changelog-excluded - breakingLabels: backwards-incompatible,breaking - deprecatedLabels: deprecated - headerLabel: "# Changelog" - breakingLabel: '### Breaking changes' - enhancementLabel: '### Enhancements' - bugsLabel: '### Bug fixes' - deprecatedLabel: '### Deprecations' - removedLabel: '### Removals' - securityLabel: '### Security fixes' - issuesLabel: '### Other issues' - prLabel: '### Other pull requests' - addSections: '{"ci":{"prefix":"### CI changes","labels":["ci"]},"wrappers":{"prefix":"### Wrapper changes","labels":["wrappers"]},"agents":{"prefix":"### Changes to agents","labels":["agents"]},"features":{"prefix":"### Features","labels":["features"]},"hotfix":{"prefix":"### Hotfixes","labels":["hotfix"]},"security":{"prefix":"### Security fixes","labels":["security"]},"refactoring":{"prefix":"### Refactoring","labels":["refactoring"]},"tests":{"prefix":"### Tests","labels":["tests"]},"update":{"prefix":"### Updates","labels":["update"]}}' - excludeTagsRegex: '^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))+)?)$' - - - name: "Create a new release" - id: create-release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} - release_name: Release ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} - body_path: ./CHANGELOG.md - draft: ${{ needs.workflow-setup.outputs.PRERELEASE == 'true' }} - prerelease: ${{ needs.workflow-setup.outputs.PRERELEASE == 'true' }} - - release-android-device: - runs-on: ubuntu-20.04 - needs: [ workflow-setup, make-release ] - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - steps: - - name: "Fetch android device build from artifacts" - uses: actions/download-artifact@v2 - with: - name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device - - name: "Upload release assets" - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} - asset_path: ./libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.aar - asset_name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.aar - asset_content_type: application/aar - - release-android-emulator: - runs-on: ubuntu-20.04 - needs: [ workflow-setup, make-release ] - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - steps: - - name: "Fetch android emulator build from artifacts" - uses: actions/download-artifact@v2 - with: - name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-emulator - - name: "Upload release assets" - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} - asset_path: ./libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-emulator.aar - asset_name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-emulator.aar - asset_content_type: application/aar - - release-ios-device: - runs-on: ubuntu-20.04 - needs: [ workflow-setup, make-release ] - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - steps: - - name: "Fetch iOS device build from artifacts" - uses: actions/download-artifact@v2 - with: - name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device - - name: "Upload release assets" - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} - asset_path: ./libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip - asset_name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip - asset_content_type: application/zip - - release-ios-legacy-device: - runs-on: ubuntu-20.04 - needs: [ workflow-setup, make-release ] - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - steps: - - name: "Fetch iOS device build from artifacts" - uses: actions/download-artifact@v2 - with: - name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device - - name: "Upload release assets" - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} - asset_path: ./libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip - asset_name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip - asset_content_type: application/zip - - release-ios-universal: - runs-on: ubuntu-20.04 - needs: [ workflow-setup, make-release ] - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - steps: - - name: "Fetch iOS universal build from artifacts" - uses: actions/download-artifact@v2 - with: - name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal - - name: "Upload release assets" - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} - asset_path: ./libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip - asset_name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip - asset_content_type: application/zip - - release-ios-legacy-universal: - runs-on: ubuntu-20.04 - needs: [ workflow-setup, make-release ] - if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} - steps: - - name: "Fetch iOS universal build from artifacts" - uses: actions/download-artifact@v2 - with: - name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal - - name: "Upload release assets" - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} - asset_path: ./libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip - asset_name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip - asset_content_type: application/zip +# test-integration-libvcx: +# needs: workflow-setup +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# runs-on: ubuntu-20.04 +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Setup rust testing environment" +# uses: ./.github/actions/setup-testing-rust +# - name: "Run libvcx tests: pool_tests" +# run: | +# RUST_TEST_THREADS=1 cargo test --manifest-path="libvcx/Cargo.toml" -F "pool_tests"; +# +# test-integration-resolver: +# needs: workflow-setup +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# runs-on: ubuntu-20.04 +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Setup rust testing environment" +# uses: ./.github/actions/setup-testing-rust +# - name: "Run resolver tests" +# run: | +# RUST_TEST_THREADS=1 cargo test -p did_doc_builder -p did_parser -p did_resolver -p did_resolver_registry -p did_resolver_sov --test "*" +# +# test-node-wrapper: +# needs: workflow-setup +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# runs-on: ubuntu-22.04 +# strategy: +# matrix: +# node-version: [18.x] +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Setup NodeJS libvcx testing environment" +# uses: ./.github/actions/setup-testing-nodejs +# with: +# skip-docker-setup: true +# node-version: ${{ matrix.node-version }} +# - name: "Run tests" +# run: cd wrappers/node && RUST_LOG=vcx=trace npm run test +# +# test-integration-node-wrapper: +# needs: workflow-setup +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# runs-on: ubuntu-22.04 +# strategy: +# matrix: +# node-version: [18.x] +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Setup NodeJS libvcx testing environment" +# uses: ./.github/actions/setup-testing-nodejs +# with: +# node-version: ${{ matrix.node-version }} +# - name: "Install vcxagent-core dependencies" +# run: (cd agents/node/vcxagent-core && npm install) +# - name: "Run demo" +# run: (cd agents/node/vcxagent-core && AGENCY_URL=http://localhost:8080 npm run demo) +# - name: "Run demo with revocation" +# run: (cd agents/node/vcxagent-core && AGENCY_URL=http://localhost:8080 npm run demo:revocation) +# - name: "Run integration tests" +# run: (cd agents/node/vcxagent-core && AGENCY_URL=http://localhost:8080 npm run test:integration) +# +# test-android-build: +# runs-on: ubuntu-20.04 +# needs: [ workflow-setup, build-docker-android ] +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true' }} +# env: +# DOCKER_IMG_CACHED_ANDROID: ${{needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID}} +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Docker Login" +# uses: azure/docker-login@v1 +# with: +# login-server: ${{ env.URL_DOCKER_REGISTRY }} +# username: $GITHUB_ACTOR +# password: ${{ secrets.GITHUB_TOKEN }} +# - name: "Load android image" +# uses: ./.github/actions/load-image +# with: +# docker-img: ${{ env.DOCKER_IMG_CACHED_ANDROID }} +# - name: "Run android tests" +# run: | +# rm -rf /tmp/imgcache +# docker run --rm -i $DOCKER_IMG_CACHED_ANDROID \ +# sh -c '(cd $HOME/aries-vcx && ./wrappers/java/ci/android.test.sh armv7)' +# +# build-and-publish-ios-wrapper: +# needs: workflow-setup +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_IOS != 'true' }} +# runs-on: macos-11 +# env: +# LIBVCX_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} +# PUBLISH_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v2 +# - name: Switch to xcode version 12.4 +# run: | +# sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer +# xcodebuild -version +# - name: "Build iOS wrapper" +# run: | +# ./wrappers/ios/ci/build.sh +# - uses: actions/upload-artifact@v3 +# with: +# name: libvcx-ios-${{ env.PUBLISH_VERSION }}-device +# path: /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-device.zip +# - uses: actions/upload-artifact@v3 +# with: +# name: libvcx-ios-${{ env.PUBLISH_VERSION }}-universal +# path: /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-universal.zip +# +# build-and-publish-ios-legacy-wrapper: +# needs: workflow-setup +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_IOS != 'true' }} +# runs-on: macos-11 +# env: +# LIBVCX_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} +# PUBLISH_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v2 +# - name: Switch to xcode version 12.4 +# run: | +# sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer +# xcodebuild -version +# - name: "Build Legacy iOS wrapper" +# run: | +# ./wrappers/ios_legacy/ci/build.sh +# - name: "Rename device as legacy" +# run: | +# mv /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-device.zip /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-device.zip +# - name: "Rename universal as legacy" +# run: | +# mv /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-universal.zip /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-universal.zip +# - uses: actions/upload-artifact@v3 +# with: +# name: libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-device +# path: /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-device.zip +# - uses: actions/upload-artifact@v3 +# with: +# name: libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-universal +# path: /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-universal.zip +# +# build-and-publish-android-device: +# runs-on: ubuntu-20.04 +# needs: [ workflow-setup, build-docker-android ] +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true' }} +# env: +# FULL_VERSION_NAME: libvcx-android-${{needs.workflow-setup.outputs.PUBLISH_VERSION}}-device +# DOCKER_IMG_CACHED_ANDROID: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Docker Login" +# uses: azure/docker-login@v1 +# with: +# login-server: ${{ env.URL_DOCKER_REGISTRY }} +# username: $GITHUB_ACTOR +# password: ${{ secrets.GITHUB_TOKEN }} +# - name: "Load android image" +# uses: ./.github/actions/load-image +# with: +# docker-img: ${{ env.DOCKER_IMG_CACHED_ANDROID }} +# - name: "Build, run android wrapper tests, and publish artifacts" +# uses: ./.github/actions/publish-android +# with: +# abis: "arm arm64" +# docker-img-name: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} +# full-version-name: ${{ env.FULL_VERSION_NAME }} +# - name: "Publish aar artifact" +# uses: actions/upload-artifact@v3 +# with: +# name: ${{ env.FULL_VERSION_NAME }} +# path: /tmp/artifacts/aar/${{ env.FULL_VERSION_NAME }}.aar +# +# build-and-publish-android-emulator: +# runs-on: ubuntu-20.04 +# needs: [ workflow-setup, build-docker-android ] +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true' }} +# env: +# FULL_VERSION_NAME: libvcx-android-${{needs.workflow-setup.outputs.PUBLISH_VERSION}}-emulator +# DOCKER_IMG_CACHED_ANDROID: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Docker Login" +# uses: azure/docker-login@v1 +# with: +# login-server: ${{ env.URL_DOCKER_REGISTRY }} +# username: $GITHUB_ACTOR +# password: ${{ secrets.GITHUB_TOKEN }} +# - name: "Load android image" +# uses: ./.github/actions/load-image +# with: +# docker-img: ${{ env.DOCKER_IMG_CACHED_ANDROID }} +# - name: "Build, run android wrapper tests, and publish artifacts" +# uses: ./.github/actions/publish-android +# with: +# abis: "x86 x86_64" +# docker-img-name: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} +# full-version-name: ${{ env.FULL_VERSION_NAME }} +# - uses: actions/upload-artifact@v3 +# with: +# name: ${{ env.FULL_VERSION_NAME }} +# path: /tmp/artifacts/aar/${{ env.FULL_VERSION_NAME }}.aar +# +# build-and-publish-ubuntu-lib: +# needs: workflow-setup +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# runs-on: ubuntu-20.04 +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - uses: actions-rs/toolchain@v1 +# with: +# toolchain: 1.65.0 +# - uses: Swatinem/rust-cache@v2 +# with: +# key: "11" +# - name: "Install dependencies" +# shell: bash +# run: | +# sudo apt-get update -y +# sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev +# - name: "Build libvcx.so" +# run: cargo build --release +# - name: "Publish artifact libvcx.so" +# uses: actions/upload-artifact@v3 +# with: +# name: libvcx.so +# path: target/release/libvcx.so +# +# build-and-publish-darwin-lib: +# needs: workflow-setup +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# runs-on: macos-11 +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - uses: actions-rs/toolchain@v1 +# with: +# toolchain: 1.65.0 +# - uses: Swatinem/rust-cache@v2 +# with: +# key: "11" +# - name: "Install dependencies" +# shell: bash +# run: | +# brew install openssl +# brew install zeromq +# brew install libsodium +# brew install pkg-config +# - name: "Build libvcx.dylib" +# run: cargo build --release +# - name: "Publish artifact libvcx.dylib" +# uses: actions/upload-artifact@v3 +# with: +# name: libvcx.dylib +# path: target/release/libvcx.dylib +# +# ########################################################################################## +# ############################ NPMJS PUBLISHING ####################################### +# +# publish-node-wrapper: +# runs-on: ubuntu-20.04 +# needs: +# - workflow-setup +# - test-unit-workspace +# - test-integration-libvcx +# - test-integration-aries-vcx +# - test-integration-aries-vcx-mysql +# - test-node-wrapper +# - test-integration-node-wrapper +# - publish-napi +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# env: +# PUBLISH_VERSION: ${{needs.workflow-setup.outputs.PUBLISH_VERSION}} +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Use Node.js 18" +# uses: actions/setup-node@v3 +# with: +# node-version: ${{ env.NODE_VERSION }} +# - name: "Publish package" +# run: | +# if [[ "$PUBLISH_VERSION" ]] +# then +# NPMJS_TOKEN=${{ secrets.NPMJS_TOKEN }} PUBLISH_VERSION=${{ env.PUBLISH_VERSION }} ./wrappers/node/publish.sh +# else +# echo "New version was not defined, skipping release." +# fi +# +# publish-agent-core: +# runs-on: ubuntu-20.04 +# needs: +# - workflow-setup +# - test-unit-workspace +# - test-integration-libvcx +# - test-integration-aries-vcx +# - test-integration-aries-vcx-mysql +# - test-node-wrapper +# - test-integration-node-wrapper +# - publish-napi +# - publish-node-wrapper +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# env: +# NPMJS_TOKEN: ${{ secrets.NPMJS_TOKEN }} +# PUBLISH_VERSION: ${{needs.workflow-setup.outputs.PUBLISH_VERSION}} +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v3 +# - name: "Use Node.js 18" +# uses: actions/setup-node@v3 +# with: +# node-version: ${{ env.NODE_VERSION }} +# - name: "Release agent-core package" +# run: | +# if [[ "$PUBLISH_VERSION" ]] +# then +# NPMJS_TOKEN=${{ secrets.NPMJS_TOKEN }} PUBLISH_VERSION=${{ env.PUBLISH_VERSION }} ./agents/node/vcxagent-core/publish.sh +# else +# echo "New version was not defined, skipping release." +# fi +# +# build-napi: +# needs: +# - workflow-setup +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# strategy: +# fail-fast: false +# matrix: +# settings: +# - host: ubuntu-20.04 +# target: x86_64-unknown-linux-gnu +# build: |- +# set -e +# sudo apt-get update -y +# sudo apt-get install -y libssl-dev libzmq3-dev +# npm run build:napi -- --target x86_64-unknown-linux-gnu +# strip *.node +# - host: ubuntu-20.04 +# target: x86_64-unknown-linux-musl +# docker: ghcr.io/hyperledger/aries-vcx/napi-rs-alpine +# build: |- +# set -e +# cd wrappers/vcx-napi-rs +# npm run build:napi +# strip *.node +# - host: macos-latest +# target: x86_64-apple-darwin +# build: | +# brew install openssl zmq pkg-config +# npm run build:napi +# strip -x *.node +# - host: macos-latest +# target: aarch64-apple-darwin +# skip: ${{ needs.workflow-setup.outputs.SKIP_NAPI_M1 }} +# build: | +# wget https://github.com/macports/macports-base/releases/download/v2.8.0/MacPorts-2.8.0-12-Monterey.pkg +# sudo installer -pkg ./MacPorts-2.8.0-12-Monterey.pkg -target / +# export PATH=/opt/local/bin:/opt/local/sbin:$PATH +# +# sudo port install openssl +universal zmq +universal +# export OPENSSL_DIR=/opt/local +# export OPENSSL_INCLUDE_DIR=/opt/local/include/ +# export OPENSSL_LIB_DIR=/opt/local/lib/ +# +# export SODIUM_LIB_DIR=/opt/local/lib/ +# export SODIUM_INCLUDE_DIR=/opt/local/include +# +# export LIBZMQ_LIB_DIR=/opt/local/lib/ +# export LIBZMQ_INCLUDE_DIR=/opt/local/include +# +# export PKG_CONFIG_ALLOW_CROSS=1 +# export PKG_CONFIG_SYSROOT_DIR=/ +# export RUST_BACKTRACE=1 +# npm run build:napi -- --target aarch64-apple-darwin +# strip -x *.node +# name: ${{ matrix.settings.target }} +# runs-on: ${{ matrix.settings.host }} +# steps: +# - uses: actions/checkout@v3 +# - uses: ./.github/actions/build-napi +# if: ${{ matrix.settings.skip != 'true' }} +# with: +# docker: ${{ matrix.settings.docker }} +# target: ${{ matrix.settings.target }} +# build: ${{ matrix.settings.build }} +# node-version: ${{ env.NODE_VERSION }} +# rust-version: ${{ env.RUST_TOOLCHAIN_VERSON }} +# +# publish-napi: +# runs-on: ubuntu-20.04 +# needs: +# - workflow-setup +# - build-napi +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# steps: +# - uses: actions/checkout@v3 +# - uses: ./.github/actions/publish-napi +# with: +# publish-version: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} +# npmjs-token: ${{ secrets.NPMJS_TOKEN }} +# node-version: ${{ env.NODE_VERSION }} +# +# ########################################################################################## +# ############################## RELEASE ######################################### +# +# make-release: +# runs-on: ubuntu-20.04 +# needs: +# - workflow-setup +# - build-and-publish-ios-wrapper +# - build-and-publish-ios-legacy-wrapper +# - build-and-publish-android-device +# - build-and-publish-android-emulator +# - test-unit-workspace +# - test-integration-libvcx +# - test-integration-aries-vcx +# - test-integration-aries-vcx-mysql +# - test-android-build +# - test-node-wrapper +# - test-integration-node-wrapper +# if: ${{ needs.workflow-setup.outputs.RELEASE == 'true' || needs.workflow-setup.outputs.PRERELEASE == 'true' }} +# outputs: +# RELEASE_UPLOAD_URL: ${{ steps.create-release.outputs.upload_url }} +# steps: +# - name: "Git checkout" +# uses: actions/checkout@v2 +# - name: "Generate changelog" +# uses: heinrichreimer/action-github-changelog-generator@v2.3 +# with: +# token: ${{ secrets.GITHUB_TOKEN }} +# futureRelease: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} +# releaseBranch: main +# pullRequests: true +# unreleased: false +# unreleasedOnly: false +# issuesWoLabels: true +# prWoLabels: true +# stripGeneratorNotice: true +# stripHeaders: false +# maxIssues: 50 +# excludeLabels: duplicate,question,invalid,wontfix,changelog-excluded +# breakingLabels: backwards-incompatible,breaking +# deprecatedLabels: deprecated +# headerLabel: "# Changelog" +# breakingLabel: '### Breaking changes' +# enhancementLabel: '### Enhancements' +# bugsLabel: '### Bug fixes' +# deprecatedLabel: '### Deprecations' +# removedLabel: '### Removals' +# securityLabel: '### Security fixes' +# issuesLabel: '### Other issues' +# prLabel: '### Other pull requests' +# addSections: '{"ci":{"prefix":"### CI changes","labels":["ci"]},"wrappers":{"prefix":"### Wrapper changes","labels":["wrappers"]},"agents":{"prefix":"### Changes to agents","labels":["agents"]},"features":{"prefix":"### Features","labels":["features"]},"hotfix":{"prefix":"### Hotfixes","labels":["hotfix"]},"security":{"prefix":"### Security fixes","labels":["security"]},"refactoring":{"prefix":"### Refactoring","labels":["refactoring"]},"tests":{"prefix":"### Tests","labels":["tests"]},"update":{"prefix":"### Updates","labels":["update"]}}' +# excludeTagsRegex: '^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))+)?)$' +# +# - name: "Create a new release" +# id: create-release +# uses: actions/create-release@v1 +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# with: +# tag_name: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} +# release_name: Release ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} +# body_path: ./CHANGELOG.md +# draft: ${{ needs.workflow-setup.outputs.PRERELEASE == 'true' }} +# prerelease: ${{ needs.workflow-setup.outputs.PRERELEASE == 'true' }} +# +# release-android-device: +# runs-on: ubuntu-20.04 +# needs: [ workflow-setup, make-release ] +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# steps: +# - name: "Fetch android device build from artifacts" +# uses: actions/download-artifact@v2 +# with: +# name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device +# - name: "Upload release assets" +# uses: actions/upload-release-asset@v1 +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# with: +# upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} +# asset_path: ./libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.aar +# asset_name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.aar +# asset_content_type: application/aar +# +# release-android-emulator: +# runs-on: ubuntu-20.04 +# needs: [ workflow-setup, make-release ] +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# steps: +# - name: "Fetch android emulator build from artifacts" +# uses: actions/download-artifact@v2 +# with: +# name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-emulator +# - name: "Upload release assets" +# uses: actions/upload-release-asset@v1 +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# with: +# upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} +# asset_path: ./libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-emulator.aar +# asset_name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-emulator.aar +# asset_content_type: application/aar +# +# release-ios-device: +# runs-on: ubuntu-20.04 +# needs: [ workflow-setup, make-release ] +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# steps: +# - name: "Fetch iOS device build from artifacts" +# uses: actions/download-artifact@v2 +# with: +# name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device +# - name: "Upload release assets" +# uses: actions/upload-release-asset@v1 +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# with: +# upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} +# asset_path: ./libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip +# asset_name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip +# asset_content_type: application/zip +# +# release-ios-legacy-device: +# runs-on: ubuntu-20.04 +# needs: [ workflow-setup, make-release ] +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# steps: +# - name: "Fetch iOS device build from artifacts" +# uses: actions/download-artifact@v2 +# with: +# name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device +# - name: "Upload release assets" +# uses: actions/upload-release-asset@v1 +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# with: +# upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} +# asset_path: ./libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip +# asset_name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip +# asset_content_type: application/zip +# +# release-ios-universal: +# runs-on: ubuntu-20.04 +# needs: [ workflow-setup, make-release ] +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# steps: +# - name: "Fetch iOS universal build from artifacts" +# uses: actions/download-artifact@v2 +# with: +# name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal +# - name: "Upload release assets" +# uses: actions/upload-release-asset@v1 +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# with: +# upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} +# asset_path: ./libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip +# asset_name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip +# asset_content_type: application/zip +# +# release-ios-legacy-universal: +# runs-on: ubuntu-20.04 +# needs: [ workflow-setup, make-release ] +# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} +# steps: +# - name: "Fetch iOS universal build from artifacts" +# uses: actions/download-artifact@v2 +# with: +# name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal +# - name: "Upload release assets" +# uses: actions/upload-release-asset@v1 +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# with: +# upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} +# asset_path: ./libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip +# asset_name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip +# asset_content_type: application/zip diff --git a/ci/vdrproxy.dockerfile b/ci/vdrproxy.dockerfile index bd0bc9d47a..c7c13f7f66 100644 --- a/ci/vdrproxy.dockerfile +++ b/ci/vdrproxy.dockerfile @@ -12,7 +12,13 @@ WORKDIR /home/indy/indy-vdr/indy-vdr-proxy RUN cargo build --release FROM alpine:3.18 +RUN apk update && apk upgrade && \ + apk add --no-cache \ + libstdc++ \ + libgcc + ENV PORT 3030 ENV GENESIS genesis.txn + COPY --from=builder /home/indy/indy-vdr/target/release/indy-vdr-proxy indy-vdr-proxy -ENTRYPOINT ["./indy-vdr-proxy", "-p", "${PORT}", "-g", "${GENESIS}"] +ENTRYPOINT ./indy-vdr-proxy -p ${PORT} -g ${GENESIS} From 88abf94ad68a56b616577e759f84dd9607c87b1f Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Thu, 11 May 2023 15:33:13 +0200 Subject: [PATCH 08/19] Revert CI changes Signed-off-by: Miroslav Kovar --- .github/workflows/main.yml | 1756 ++++++++++++++++++------------------ 1 file changed, 878 insertions(+), 878 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b3904c706f..fcdb03cab3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,7 @@ name: CI on: push: branches: - - "**" + - main pull_request: branches: - "**" @@ -24,18 +24,18 @@ env: NODE_VERSION: 18.x jobs: -# verify-code-formatting: -# runs-on: ubuntu-20.04 -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - uses: actions-rs/toolchain@v1 -# with: -# toolchain: 1.65.0 -# components: rustfmt, clippy -# - name: "Verify code formatting" -# run: | -# cargo fmt --check + verify-code-formatting: + runs-on: ubuntu-20.04 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.65.0 + components: rustfmt, clippy + - name: "Verify code formatting" + run: | + cargo fmt --check workflow-setup: runs-on: ubuntu-20.04 @@ -118,66 +118,66 @@ jobs: echo "DOCKER_IMG_CACHED_ANDROID ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }}" echo "DOCKER_IMG_CACHED_VDRPROXY ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_VDRPROXY }}" -# clippy-aries-vcx: -# runs-on: ubuntu-20.04 -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - uses: actions-rs/toolchain@v1 -# with: -# toolchain: 1.65.0 -# components: rustfmt, clippy -# - name: "Install dependencies" -# shell: bash -# run: | -# sudo apt-get update -y -# sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev -# - name: "Verify clippy warnings" -# run: | -# cd aries_vcx && cargo clippy -# -# clippy-libvcx: -# runs-on: ubuntu-20.04 -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - uses: actions-rs/toolchain@v1 -# with: -# toolchain: 1.65.0 -# components: rustfmt, clippy -# - name: "Install dependencies" -# shell: bash -# run: | -# sudo apt-get update -y -# sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev -# - name: "Verify clippy warnings" -# run: | -# cd libvcx && cargo clippy -# -# check-aries-vcx-feature-variants: -# runs-on: ubuntu-20.04 -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - uses: actions-rs/toolchain@v1 -# with: -# toolchain: 1.65.0 -# components: rustfmt, clippy -# - name: "Install dependencies" -# shell: bash -# run: | -# sudo apt-get update -y -# sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev -# - name: "Verify aries_vcx compiles with different dependency feature variants" -# run: | -# cd aries_vcx -# cargo check -# cargo check --no-default-features -# cargo check --features vdrtools --no-default-features -# cargo check --features modular_libs --no-default-features -# -# ########################################################################################## -# ############################## DOCKER BUILD ########################################## + clippy-aries-vcx: + runs-on: ubuntu-20.04 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.65.0 + components: rustfmt, clippy + - name: "Install dependencies" + shell: bash + run: | + sudo apt-get update -y + sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev + - name: "Verify clippy warnings" + run: | + cd aries_vcx && cargo clippy + + clippy-libvcx: + runs-on: ubuntu-20.04 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.65.0 + components: rustfmt, clippy + - name: "Install dependencies" + shell: bash + run: | + sudo apt-get update -y + sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev + - name: "Verify clippy warnings" + run: | + cd libvcx && cargo clippy + + check-aries-vcx-feature-variants: + runs-on: ubuntu-20.04 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.65.0 + components: rustfmt, clippy + - name: "Install dependencies" + shell: bash + run: | + sudo apt-get update -y + sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev + - name: "Verify aries_vcx compiles with different dependency feature variants" + run: | + cd aries_vcx + cargo check + cargo check --no-default-features + cargo check --features vdrtools --no-default-features + cargo check --features modular_libs --no-default-features + + ########################################################################################## + ############################## DOCKER BUILD ########################################## build-docker-alpine-core: needs: workflow-setup @@ -204,61 +204,61 @@ jobs: branch-main: ${{ env.MAIN_BRANCH }} docker-repo-local-name: ${{ env.DOCKER_REPO_LOCAL_ALPINE_CORE }} -# build-docker-libvcx: -# needs: [ workflow-setup, build-docker-alpine-core ] -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# runs-on: ubuntu-20.04 -# env: -# DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_LIBVCX }} -# DOCKER_IMG_CACHED_ALPINE_CORE: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ALPINE_CORE }} -# BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }} -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Docker Login" -# uses: azure/docker-login@v1 -# with: -# login-server: ${{ env.URL_DOCKER_REGISTRY }} -# username: $GITHUB_ACTOR -# password: ${{ secrets.GITHUB_TOKEN }} -# - name: "Load alpine core image" -# uses: ./.github/actions/load-image -# with: -# docker-img: ${{ env.DOCKER_IMG_CACHED_ALPINE_CORE }} -# - name: "Build and cache image" -# uses: ./.github/actions/build-image -# with: -# docker-img: ${{ env.DOCKER_IMG_CACHED }} -# build-arg: "ALPINE_CORE_IMAGE=$DOCKER_IMG_CACHED_ALPINE_CORE" -# dockerfile-path: "ci/libvcx.dockerfile" -# branch-name: ${{ env.BRANCH_NAME }} -# branch-main: ${{ env.MAIN_BRANCH }} -# docker-repo-local-name: ${{ env.DOCKER_REPO_LOCAL_LIBVCX }} -# -# build-docker-android: -# needs: workflow-setup -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true'}} -# runs-on: ubuntu-20.04 -# env: -# DOCKER_IMG_CACHED: ${{needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID}} -# BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }} -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Docker Login" -# uses: azure/docker-login@v1 -# with: -# login-server: ${{ env.URL_DOCKER_REGISTRY }} -# username: $GITHUB_ACTOR -# password: ${{ secrets.GITHUB_TOKEN }} -# - name: "Build and cache image" -# uses: ./.github/actions/build-image -# with: -# docker-img: ${{ env.DOCKER_IMG_CACHED }} -# dockerfile-path: "wrappers/java/ci/android.dockerfile" -# branch-name: ${{ env.BRANCH_NAME }} -# branch-main: ${{ env.MAIN_BRANCH }} -# docker-repo-local-name: ${{ env.DOCKER_REPO_LOCAL_ANDROID }} + build-docker-libvcx: + needs: [ workflow-setup, build-docker-alpine-core ] + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + runs-on: ubuntu-20.04 + env: + DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_LIBVCX }} + DOCKER_IMG_CACHED_ALPINE_CORE: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ALPINE_CORE }} + BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }} + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Docker Login" + uses: azure/docker-login@v1 + with: + login-server: ${{ env.URL_DOCKER_REGISTRY }} + username: $GITHUB_ACTOR + password: ${{ secrets.GITHUB_TOKEN }} + - name: "Load alpine core image" + uses: ./.github/actions/load-image + with: + docker-img: ${{ env.DOCKER_IMG_CACHED_ALPINE_CORE }} + - name: "Build and cache image" + uses: ./.github/actions/build-image + with: + docker-img: ${{ env.DOCKER_IMG_CACHED }} + build-arg: "ALPINE_CORE_IMAGE=$DOCKER_IMG_CACHED_ALPINE_CORE" + dockerfile-path: "ci/libvcx.dockerfile" + branch-name: ${{ env.BRANCH_NAME }} + branch-main: ${{ env.MAIN_BRANCH }} + docker-repo-local-name: ${{ env.DOCKER_REPO_LOCAL_LIBVCX }} + + build-docker-android: + needs: workflow-setup + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true'}} + runs-on: ubuntu-20.04 + env: + DOCKER_IMG_CACHED: ${{needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID}} + BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }} + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Docker Login" + uses: azure/docker-login@v1 + with: + login-server: ${{ env.URL_DOCKER_REGISTRY }} + username: $GITHUB_ACTOR + password: ${{ secrets.GITHUB_TOKEN }} + - name: "Build and cache image" + uses: ./.github/actions/build-image + with: + docker-img: ${{ env.DOCKER_IMG_CACHED }} + dockerfile-path: "wrappers/java/ci/android.dockerfile" + branch-name: ${{ env.BRANCH_NAME }} + branch-main: ${{ env.MAIN_BRANCH }} + docker-repo-local-name: ${{ env.DOCKER_REPO_LOCAL_ANDROID }} build-docker-vdrproxy: needs: [ workflow-setup, build-docker-alpine-core ] @@ -296,165 +296,165 @@ jobs: ########################################################################################## ############################## DOCKER PUBLISH ######################################## -# publish-docker-libvcx: -# runs-on: ubuntu-20.04 -# needs: [ workflow-setup, build-docker-libvcx ] -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# env: -# DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_LIBVCX }} -# PUBLISH_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} -# BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }} -# IS_FORK: ${{ needs.workflow-setup.outputs.IS_FORK }} -# steps: -# - name: "Git checkout" -# if: ${{ env.IS_FORK == 'false' }} -# uses: actions/checkout@v3 -# - name: "Docker Login" -# uses: azure/docker-login@v1 -# with: -# login-server: ${{ env.URL_DOCKER_REGISTRY }} -# username: $GITHUB_ACTOR -# password: ${{ secrets.GITHUB_TOKEN }} -# - name: "Publish versioned image" -# if: ${{ env.IS_FORK == 'false' }} -# uses: ./.github/actions/publish-image -# with: -# docker-img: ${{ env.DOCKER_IMG_CACHED }} -# publish-version: ${{ env.PUBLISH_VERSION }} -# -# ########################################################################################## -# ############################### CODECOV ########################################### -# -# code-coverage-aries-vcx-unit-tests: -# needs: workflow-setup -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# runs-on: ubuntu-20.04 -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Setup rust codecov environment" -# uses: ./.github/actions/setup-codecov-rust -# with: -# skip-docker-setup: true -# - name: "Run workspace tests: general_test" -# run: | -# RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ -# RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ -# RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --package aries-vcx; -# -# mkdir -p /tmp/artifacts/coverage -# grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o /tmp/artifacts/coverage/coverage.lcov -# - name: "Upload coverage to Codecov" -# uses: codecov/codecov-action@v2 -# with: -# directory: /tmp/artifacts/coverage -# flags: unittests-aries-vcx -# name: codecov-unit-aries-vcx -# fail_ci_if_error: true -# path_to_write_report: /tmp/artifacts/coverage/codecov_report.gz -# - uses: actions/upload-artifact@v3 -# with: -# name: code-coverage-report-unit-aries-vcx -# path: /tmp/artifacts/coverage -# -# code-coverage-aries-vcx-integration-tests: -# needs: workflow-setup -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# runs-on: ubuntu-20.04 -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Setup rust codecov environment" -# uses: ./.github/actions/setup-codecov-rust -# - name: "Run workspace tests: pool_tests agency_pool_tests" -# run: | -# RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ -# RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ -# RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --package aries-vcx -- --ignored; -# -# mkdir -p /tmp/artifacts/coverage -# grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o /tmp/artifacts/coverage/coverage.lcov -# - name: "Upload coverage to Codecov" -# uses: codecov/codecov-action@v2 -# with: -# directory: /tmp/artifacts/coverage -# flags: unittests-aries-vcx -# name: codecov-unit-aries-vcx -# fail_ci_if_error: true -# path_to_write_report: /tmp/artifacts/coverage/codecov_report.gz -# - uses: actions/upload-artifact@v3 -# with: -# name: code-coverage-report-unit-aries-vcx -# path: /tmp/artifacts/coverage -# -# #TODO - can this be included within code-coverage-aries-vcx-integration-tests? -# code-coverage-aries-vcx-modular-dependencies-integration-tests: -# needs: workflow-setup -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# runs-on: ubuntu-20.04 -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Setup rust codecov environment" -# uses: ./.github/actions/setup-codecov-rust -# - name: "Run workspace tests: modular_libs_tests pool_tests agency_pool_tests" -# run: | -# RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ -# RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ -# RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --package aries-vcx -F 'modular_libs' -- --ignored; -# -# mkdir -p /tmp/artifacts/coverage -# grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o /tmp/artifacts/coverage/coverage.lcov -# - name: "Upload coverage to Codecov" -# uses: codecov/codecov-action@v2 -# with: -# directory: /tmp/artifacts/coverage -# flags: unittests-aries-vcx -# name: codecov-unit-aries-vcx -# fail_ci_if_error: true -# path_to_write_report: /tmp/artifacts/coverage/codecov_report.gz -# - uses: actions/upload-artifact@v3 -# with: -# name: code-coverage-report-unit-aries-vcx -# path: /tmp/artifacts/coverage -# -# ########################################################################################## -# ############################### TESTING ########################################### -# -# test-unit-workspace: -# needs: workflow-setup -# runs-on: ubuntu-20.04 -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Setup rust testing environment" -# uses: ./.github/actions/setup-testing-rust -# with: -# skip-docker-setup: true -# - name: "Run workspace tests: general_test" -# run: RUST_TEST_THREADS=1 cargo test --workspace --lib --exclude aries-vcx-agent --exclude libvdrtools -# -# test-integration-aries-vcx: -# needs: workflow-setup -# runs-on: ubuntu-20.04 -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Setup rust testing environment" -# uses: ./.github/actions/setup-testing-rust -# - name: "Run aries-vcx tests: pool_tests agency_pool_tests" -# run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" -- --ignored; -# -# test-integration-aries-vcx-mysql: -# needs: workflow-setup -# runs-on: ubuntu-20.04 -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Setup rust testing environment" -# uses: ./.github/actions/setup-testing-rust -# - name: "Run aries-vcx tests: mysql_test" -# run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" test_mysql -- --include-ignored; + publish-docker-libvcx: + runs-on: ubuntu-20.04 + needs: [ workflow-setup, build-docker-libvcx ] + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + env: + DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_LIBVCX }} + PUBLISH_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} + BRANCH_NAME: ${{ needs.workflow-setup.outputs.BRANCH_NAME }} + IS_FORK: ${{ needs.workflow-setup.outputs.IS_FORK }} + steps: + - name: "Git checkout" + if: ${{ env.IS_FORK == 'false' }} + uses: actions/checkout@v3 + - name: "Docker Login" + uses: azure/docker-login@v1 + with: + login-server: ${{ env.URL_DOCKER_REGISTRY }} + username: $GITHUB_ACTOR + password: ${{ secrets.GITHUB_TOKEN }} + - name: "Publish versioned image" + if: ${{ env.IS_FORK == 'false' }} + uses: ./.github/actions/publish-image + with: + docker-img: ${{ env.DOCKER_IMG_CACHED }} + publish-version: ${{ env.PUBLISH_VERSION }} + + ########################################################################################## + ############################### CODECOV ########################################### + + code-coverage-aries-vcx-unit-tests: + needs: workflow-setup + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + runs-on: ubuntu-20.04 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Setup rust codecov environment" + uses: ./.github/actions/setup-codecov-rust + with: + skip-docker-setup: true + - name: "Run workspace tests: general_test" + run: | + RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ + RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ + RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --package aries-vcx; + + mkdir -p /tmp/artifacts/coverage + grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o /tmp/artifacts/coverage/coverage.lcov + - name: "Upload coverage to Codecov" + uses: codecov/codecov-action@v2 + with: + directory: /tmp/artifacts/coverage + flags: unittests-aries-vcx + name: codecov-unit-aries-vcx + fail_ci_if_error: true + path_to_write_report: /tmp/artifacts/coverage/codecov_report.gz + - uses: actions/upload-artifact@v3 + with: + name: code-coverage-report-unit-aries-vcx + path: /tmp/artifacts/coverage + + code-coverage-aries-vcx-integration-tests: + needs: workflow-setup + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + runs-on: ubuntu-20.04 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Setup rust codecov environment" + uses: ./.github/actions/setup-codecov-rust + - name: "Run workspace tests: pool_tests agency_pool_tests" + run: | + RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ + RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ + RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --package aries-vcx -- --ignored; + + mkdir -p /tmp/artifacts/coverage + grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o /tmp/artifacts/coverage/coverage.lcov + - name: "Upload coverage to Codecov" + uses: codecov/codecov-action@v2 + with: + directory: /tmp/artifacts/coverage + flags: unittests-aries-vcx + name: codecov-unit-aries-vcx + fail_ci_if_error: true + path_to_write_report: /tmp/artifacts/coverage/codecov_report.gz + - uses: actions/upload-artifact@v3 + with: + name: code-coverage-report-unit-aries-vcx + path: /tmp/artifacts/coverage + + #TODO - can this be included within code-coverage-aries-vcx-integration-tests? + code-coverage-aries-vcx-modular-dependencies-integration-tests: + needs: workflow-setup + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + runs-on: ubuntu-20.04 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Setup rust codecov environment" + uses: ./.github/actions/setup-codecov-rust + - name: "Run workspace tests: modular_libs_tests pool_tests agency_pool_tests" + run: | + RUSTFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ + RUSTDOCFLAGS='-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' \ + RUST_TEST_THREADS=1 CARGO_INCREMENTAL=0 TEST_POOL_IP=127.0.0.1 cargo test --package aries-vcx -F 'modular_libs' -- --ignored; + + mkdir -p /tmp/artifacts/coverage + grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o /tmp/artifacts/coverage/coverage.lcov + - name: "Upload coverage to Codecov" + uses: codecov/codecov-action@v2 + with: + directory: /tmp/artifacts/coverage + flags: unittests-aries-vcx + name: codecov-unit-aries-vcx + fail_ci_if_error: true + path_to_write_report: /tmp/artifacts/coverage/codecov_report.gz + - uses: actions/upload-artifact@v3 + with: + name: code-coverage-report-unit-aries-vcx + path: /tmp/artifacts/coverage + + ########################################################################################## + ############################### TESTING ########################################### + + test-unit-workspace: + needs: workflow-setup + runs-on: ubuntu-20.04 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Setup rust testing environment" + uses: ./.github/actions/setup-testing-rust + with: + skip-docker-setup: true + - name: "Run workspace tests: general_test" + run: RUST_TEST_THREADS=1 cargo test --workspace --lib --exclude aries-vcx-agent --exclude libvdrtools + + test-integration-aries-vcx: + needs: workflow-setup + runs-on: ubuntu-20.04 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Setup rust testing environment" + uses: ./.github/actions/setup-testing-rust + - name: "Run aries-vcx tests: pool_tests agency_pool_tests" + run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" -- --ignored; + + test-integration-aries-vcx-mysql: + needs: workflow-setup + runs-on: ubuntu-20.04 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Setup rust testing environment" + uses: ./.github/actions/setup-testing-rust + - name: "Run aries-vcx tests: mysql_test" + run: RUST_TEST_THREADS=1 cargo test --manifest-path="aries_vcx/Cargo.toml" test_mysql -- --include-ignored; test-integration-aries-vcx-vdrproxy: needs: [workflow-setup, build-docker-vdrproxy] @@ -479,594 +479,594 @@ jobs: - name: "Run aries-vcx tests: vdrproxy_test" run: cargo test --manifest-path="aries_vcx/Cargo.toml" --test test_pool -F vdr_proxy_ledger -- --ignored -# test-integration-libvcx: -# needs: workflow-setup -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# runs-on: ubuntu-20.04 -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Setup rust testing environment" -# uses: ./.github/actions/setup-testing-rust -# - name: "Run libvcx tests: pool_tests" -# run: | -# RUST_TEST_THREADS=1 cargo test --manifest-path="libvcx/Cargo.toml" -F "pool_tests"; -# -# test-integration-resolver: -# needs: workflow-setup -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# runs-on: ubuntu-20.04 -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Setup rust testing environment" -# uses: ./.github/actions/setup-testing-rust -# - name: "Run resolver tests" -# run: | -# RUST_TEST_THREADS=1 cargo test -p did_doc_builder -p did_parser -p did_resolver -p did_resolver_registry -p did_resolver_sov --test "*" -# -# test-node-wrapper: -# needs: workflow-setup -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# runs-on: ubuntu-22.04 -# strategy: -# matrix: -# node-version: [18.x] -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Setup NodeJS libvcx testing environment" -# uses: ./.github/actions/setup-testing-nodejs -# with: -# skip-docker-setup: true -# node-version: ${{ matrix.node-version }} -# - name: "Run tests" -# run: cd wrappers/node && RUST_LOG=vcx=trace npm run test -# -# test-integration-node-wrapper: -# needs: workflow-setup -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# runs-on: ubuntu-22.04 -# strategy: -# matrix: -# node-version: [18.x] -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Setup NodeJS libvcx testing environment" -# uses: ./.github/actions/setup-testing-nodejs -# with: -# node-version: ${{ matrix.node-version }} -# - name: "Install vcxagent-core dependencies" -# run: (cd agents/node/vcxagent-core && npm install) -# - name: "Run demo" -# run: (cd agents/node/vcxagent-core && AGENCY_URL=http://localhost:8080 npm run demo) -# - name: "Run demo with revocation" -# run: (cd agents/node/vcxagent-core && AGENCY_URL=http://localhost:8080 npm run demo:revocation) -# - name: "Run integration tests" -# run: (cd agents/node/vcxagent-core && AGENCY_URL=http://localhost:8080 npm run test:integration) -# -# test-android-build: -# runs-on: ubuntu-20.04 -# needs: [ workflow-setup, build-docker-android ] -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true' }} -# env: -# DOCKER_IMG_CACHED_ANDROID: ${{needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID}} -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Docker Login" -# uses: azure/docker-login@v1 -# with: -# login-server: ${{ env.URL_DOCKER_REGISTRY }} -# username: $GITHUB_ACTOR -# password: ${{ secrets.GITHUB_TOKEN }} -# - name: "Load android image" -# uses: ./.github/actions/load-image -# with: -# docker-img: ${{ env.DOCKER_IMG_CACHED_ANDROID }} -# - name: "Run android tests" -# run: | -# rm -rf /tmp/imgcache -# docker run --rm -i $DOCKER_IMG_CACHED_ANDROID \ -# sh -c '(cd $HOME/aries-vcx && ./wrappers/java/ci/android.test.sh armv7)' -# -# build-and-publish-ios-wrapper: -# needs: workflow-setup -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_IOS != 'true' }} -# runs-on: macos-11 -# env: -# LIBVCX_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} -# PUBLISH_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v2 -# - name: Switch to xcode version 12.4 -# run: | -# sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer -# xcodebuild -version -# - name: "Build iOS wrapper" -# run: | -# ./wrappers/ios/ci/build.sh -# - uses: actions/upload-artifact@v3 -# with: -# name: libvcx-ios-${{ env.PUBLISH_VERSION }}-device -# path: /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-device.zip -# - uses: actions/upload-artifact@v3 -# with: -# name: libvcx-ios-${{ env.PUBLISH_VERSION }}-universal -# path: /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-universal.zip -# -# build-and-publish-ios-legacy-wrapper: -# needs: workflow-setup -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_IOS != 'true' }} -# runs-on: macos-11 -# env: -# LIBVCX_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} -# PUBLISH_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v2 -# - name: Switch to xcode version 12.4 -# run: | -# sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer -# xcodebuild -version -# - name: "Build Legacy iOS wrapper" -# run: | -# ./wrappers/ios_legacy/ci/build.sh -# - name: "Rename device as legacy" -# run: | -# mv /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-device.zip /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-device.zip -# - name: "Rename universal as legacy" -# run: | -# mv /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-universal.zip /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-universal.zip -# - uses: actions/upload-artifact@v3 -# with: -# name: libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-device -# path: /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-device.zip -# - uses: actions/upload-artifact@v3 -# with: -# name: libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-universal -# path: /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-universal.zip -# -# build-and-publish-android-device: -# runs-on: ubuntu-20.04 -# needs: [ workflow-setup, build-docker-android ] -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true' }} -# env: -# FULL_VERSION_NAME: libvcx-android-${{needs.workflow-setup.outputs.PUBLISH_VERSION}}-device -# DOCKER_IMG_CACHED_ANDROID: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Docker Login" -# uses: azure/docker-login@v1 -# with: -# login-server: ${{ env.URL_DOCKER_REGISTRY }} -# username: $GITHUB_ACTOR -# password: ${{ secrets.GITHUB_TOKEN }} -# - name: "Load android image" -# uses: ./.github/actions/load-image -# with: -# docker-img: ${{ env.DOCKER_IMG_CACHED_ANDROID }} -# - name: "Build, run android wrapper tests, and publish artifacts" -# uses: ./.github/actions/publish-android -# with: -# abis: "arm arm64" -# docker-img-name: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} -# full-version-name: ${{ env.FULL_VERSION_NAME }} -# - name: "Publish aar artifact" -# uses: actions/upload-artifact@v3 -# with: -# name: ${{ env.FULL_VERSION_NAME }} -# path: /tmp/artifacts/aar/${{ env.FULL_VERSION_NAME }}.aar -# -# build-and-publish-android-emulator: -# runs-on: ubuntu-20.04 -# needs: [ workflow-setup, build-docker-android ] -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true' }} -# env: -# FULL_VERSION_NAME: libvcx-android-${{needs.workflow-setup.outputs.PUBLISH_VERSION}}-emulator -# DOCKER_IMG_CACHED_ANDROID: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Docker Login" -# uses: azure/docker-login@v1 -# with: -# login-server: ${{ env.URL_DOCKER_REGISTRY }} -# username: $GITHUB_ACTOR -# password: ${{ secrets.GITHUB_TOKEN }} -# - name: "Load android image" -# uses: ./.github/actions/load-image -# with: -# docker-img: ${{ env.DOCKER_IMG_CACHED_ANDROID }} -# - name: "Build, run android wrapper tests, and publish artifacts" -# uses: ./.github/actions/publish-android -# with: -# abis: "x86 x86_64" -# docker-img-name: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} -# full-version-name: ${{ env.FULL_VERSION_NAME }} -# - uses: actions/upload-artifact@v3 -# with: -# name: ${{ env.FULL_VERSION_NAME }} -# path: /tmp/artifacts/aar/${{ env.FULL_VERSION_NAME }}.aar -# -# build-and-publish-ubuntu-lib: -# needs: workflow-setup -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# runs-on: ubuntu-20.04 -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - uses: actions-rs/toolchain@v1 -# with: -# toolchain: 1.65.0 -# - uses: Swatinem/rust-cache@v2 -# with: -# key: "11" -# - name: "Install dependencies" -# shell: bash -# run: | -# sudo apt-get update -y -# sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev -# - name: "Build libvcx.so" -# run: cargo build --release -# - name: "Publish artifact libvcx.so" -# uses: actions/upload-artifact@v3 -# with: -# name: libvcx.so -# path: target/release/libvcx.so -# -# build-and-publish-darwin-lib: -# needs: workflow-setup -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# runs-on: macos-11 -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - uses: actions-rs/toolchain@v1 -# with: -# toolchain: 1.65.0 -# - uses: Swatinem/rust-cache@v2 -# with: -# key: "11" -# - name: "Install dependencies" -# shell: bash -# run: | -# brew install openssl -# brew install zeromq -# brew install libsodium -# brew install pkg-config -# - name: "Build libvcx.dylib" -# run: cargo build --release -# - name: "Publish artifact libvcx.dylib" -# uses: actions/upload-artifact@v3 -# with: -# name: libvcx.dylib -# path: target/release/libvcx.dylib -# -# ########################################################################################## -# ############################ NPMJS PUBLISHING ####################################### -# -# publish-node-wrapper: -# runs-on: ubuntu-20.04 -# needs: -# - workflow-setup -# - test-unit-workspace -# - test-integration-libvcx -# - test-integration-aries-vcx -# - test-integration-aries-vcx-mysql -# - test-node-wrapper -# - test-integration-node-wrapper -# - publish-napi -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# env: -# PUBLISH_VERSION: ${{needs.workflow-setup.outputs.PUBLISH_VERSION}} -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Use Node.js 18" -# uses: actions/setup-node@v3 -# with: -# node-version: ${{ env.NODE_VERSION }} -# - name: "Publish package" -# run: | -# if [[ "$PUBLISH_VERSION" ]] -# then -# NPMJS_TOKEN=${{ secrets.NPMJS_TOKEN }} PUBLISH_VERSION=${{ env.PUBLISH_VERSION }} ./wrappers/node/publish.sh -# else -# echo "New version was not defined, skipping release." -# fi -# -# publish-agent-core: -# runs-on: ubuntu-20.04 -# needs: -# - workflow-setup -# - test-unit-workspace -# - test-integration-libvcx -# - test-integration-aries-vcx -# - test-integration-aries-vcx-mysql -# - test-node-wrapper -# - test-integration-node-wrapper -# - publish-napi -# - publish-node-wrapper -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# env: -# NPMJS_TOKEN: ${{ secrets.NPMJS_TOKEN }} -# PUBLISH_VERSION: ${{needs.workflow-setup.outputs.PUBLISH_VERSION}} -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v3 -# - name: "Use Node.js 18" -# uses: actions/setup-node@v3 -# with: -# node-version: ${{ env.NODE_VERSION }} -# - name: "Release agent-core package" -# run: | -# if [[ "$PUBLISH_VERSION" ]] -# then -# NPMJS_TOKEN=${{ secrets.NPMJS_TOKEN }} PUBLISH_VERSION=${{ env.PUBLISH_VERSION }} ./agents/node/vcxagent-core/publish.sh -# else -# echo "New version was not defined, skipping release." -# fi -# -# build-napi: -# needs: -# - workflow-setup -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# strategy: -# fail-fast: false -# matrix: -# settings: -# - host: ubuntu-20.04 -# target: x86_64-unknown-linux-gnu -# build: |- -# set -e -# sudo apt-get update -y -# sudo apt-get install -y libssl-dev libzmq3-dev -# npm run build:napi -- --target x86_64-unknown-linux-gnu -# strip *.node -# - host: ubuntu-20.04 -# target: x86_64-unknown-linux-musl -# docker: ghcr.io/hyperledger/aries-vcx/napi-rs-alpine -# build: |- -# set -e -# cd wrappers/vcx-napi-rs -# npm run build:napi -# strip *.node -# - host: macos-latest -# target: x86_64-apple-darwin -# build: | -# brew install openssl zmq pkg-config -# npm run build:napi -# strip -x *.node -# - host: macos-latest -# target: aarch64-apple-darwin -# skip: ${{ needs.workflow-setup.outputs.SKIP_NAPI_M1 }} -# build: | -# wget https://github.com/macports/macports-base/releases/download/v2.8.0/MacPorts-2.8.0-12-Monterey.pkg -# sudo installer -pkg ./MacPorts-2.8.0-12-Monterey.pkg -target / -# export PATH=/opt/local/bin:/opt/local/sbin:$PATH -# -# sudo port install openssl +universal zmq +universal -# export OPENSSL_DIR=/opt/local -# export OPENSSL_INCLUDE_DIR=/opt/local/include/ -# export OPENSSL_LIB_DIR=/opt/local/lib/ -# -# export SODIUM_LIB_DIR=/opt/local/lib/ -# export SODIUM_INCLUDE_DIR=/opt/local/include -# -# export LIBZMQ_LIB_DIR=/opt/local/lib/ -# export LIBZMQ_INCLUDE_DIR=/opt/local/include -# -# export PKG_CONFIG_ALLOW_CROSS=1 -# export PKG_CONFIG_SYSROOT_DIR=/ -# export RUST_BACKTRACE=1 -# npm run build:napi -- --target aarch64-apple-darwin -# strip -x *.node -# name: ${{ matrix.settings.target }} -# runs-on: ${{ matrix.settings.host }} -# steps: -# - uses: actions/checkout@v3 -# - uses: ./.github/actions/build-napi -# if: ${{ matrix.settings.skip != 'true' }} -# with: -# docker: ${{ matrix.settings.docker }} -# target: ${{ matrix.settings.target }} -# build: ${{ matrix.settings.build }} -# node-version: ${{ env.NODE_VERSION }} -# rust-version: ${{ env.RUST_TOOLCHAIN_VERSON }} -# -# publish-napi: -# runs-on: ubuntu-20.04 -# needs: -# - workflow-setup -# - build-napi -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# steps: -# - uses: actions/checkout@v3 -# - uses: ./.github/actions/publish-napi -# with: -# publish-version: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} -# npmjs-token: ${{ secrets.NPMJS_TOKEN }} -# node-version: ${{ env.NODE_VERSION }} -# -# ########################################################################################## -# ############################## RELEASE ######################################### -# -# make-release: -# runs-on: ubuntu-20.04 -# needs: -# - workflow-setup -# - build-and-publish-ios-wrapper -# - build-and-publish-ios-legacy-wrapper -# - build-and-publish-android-device -# - build-and-publish-android-emulator -# - test-unit-workspace -# - test-integration-libvcx -# - test-integration-aries-vcx -# - test-integration-aries-vcx-mysql -# - test-android-build -# - test-node-wrapper -# - test-integration-node-wrapper -# if: ${{ needs.workflow-setup.outputs.RELEASE == 'true' || needs.workflow-setup.outputs.PRERELEASE == 'true' }} -# outputs: -# RELEASE_UPLOAD_URL: ${{ steps.create-release.outputs.upload_url }} -# steps: -# - name: "Git checkout" -# uses: actions/checkout@v2 -# - name: "Generate changelog" -# uses: heinrichreimer/action-github-changelog-generator@v2.3 -# with: -# token: ${{ secrets.GITHUB_TOKEN }} -# futureRelease: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} -# releaseBranch: main -# pullRequests: true -# unreleased: false -# unreleasedOnly: false -# issuesWoLabels: true -# prWoLabels: true -# stripGeneratorNotice: true -# stripHeaders: false -# maxIssues: 50 -# excludeLabels: duplicate,question,invalid,wontfix,changelog-excluded -# breakingLabels: backwards-incompatible,breaking -# deprecatedLabels: deprecated -# headerLabel: "# Changelog" -# breakingLabel: '### Breaking changes' -# enhancementLabel: '### Enhancements' -# bugsLabel: '### Bug fixes' -# deprecatedLabel: '### Deprecations' -# removedLabel: '### Removals' -# securityLabel: '### Security fixes' -# issuesLabel: '### Other issues' -# prLabel: '### Other pull requests' -# addSections: '{"ci":{"prefix":"### CI changes","labels":["ci"]},"wrappers":{"prefix":"### Wrapper changes","labels":["wrappers"]},"agents":{"prefix":"### Changes to agents","labels":["agents"]},"features":{"prefix":"### Features","labels":["features"]},"hotfix":{"prefix":"### Hotfixes","labels":["hotfix"]},"security":{"prefix":"### Security fixes","labels":["security"]},"refactoring":{"prefix":"### Refactoring","labels":["refactoring"]},"tests":{"prefix":"### Tests","labels":["tests"]},"update":{"prefix":"### Updates","labels":["update"]}}' -# excludeTagsRegex: '^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))+)?)$' -# -# - name: "Create a new release" -# id: create-release -# uses: actions/create-release@v1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# tag_name: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} -# release_name: Release ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} -# body_path: ./CHANGELOG.md -# draft: ${{ needs.workflow-setup.outputs.PRERELEASE == 'true' }} -# prerelease: ${{ needs.workflow-setup.outputs.PRERELEASE == 'true' }} -# -# release-android-device: -# runs-on: ubuntu-20.04 -# needs: [ workflow-setup, make-release ] -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# steps: -# - name: "Fetch android device build from artifacts" -# uses: actions/download-artifact@v2 -# with: -# name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device -# - name: "Upload release assets" -# uses: actions/upload-release-asset@v1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} -# asset_path: ./libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.aar -# asset_name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.aar -# asset_content_type: application/aar -# -# release-android-emulator: -# runs-on: ubuntu-20.04 -# needs: [ workflow-setup, make-release ] -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# steps: -# - name: "Fetch android emulator build from artifacts" -# uses: actions/download-artifact@v2 -# with: -# name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-emulator -# - name: "Upload release assets" -# uses: actions/upload-release-asset@v1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} -# asset_path: ./libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-emulator.aar -# asset_name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-emulator.aar -# asset_content_type: application/aar -# -# release-ios-device: -# runs-on: ubuntu-20.04 -# needs: [ workflow-setup, make-release ] -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# steps: -# - name: "Fetch iOS device build from artifacts" -# uses: actions/download-artifact@v2 -# with: -# name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device -# - name: "Upload release assets" -# uses: actions/upload-release-asset@v1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} -# asset_path: ./libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip -# asset_name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip -# asset_content_type: application/zip -# -# release-ios-legacy-device: -# runs-on: ubuntu-20.04 -# needs: [ workflow-setup, make-release ] -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# steps: -# - name: "Fetch iOS device build from artifacts" -# uses: actions/download-artifact@v2 -# with: -# name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device -# - name: "Upload release assets" -# uses: actions/upload-release-asset@v1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} -# asset_path: ./libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip -# asset_name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip -# asset_content_type: application/zip -# -# release-ios-universal: -# runs-on: ubuntu-20.04 -# needs: [ workflow-setup, make-release ] -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# steps: -# - name: "Fetch iOS universal build from artifacts" -# uses: actions/download-artifact@v2 -# with: -# name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal -# - name: "Upload release assets" -# uses: actions/upload-release-asset@v1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} -# asset_path: ./libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip -# asset_name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip -# asset_content_type: application/zip -# -# release-ios-legacy-universal: -# runs-on: ubuntu-20.04 -# needs: [ workflow-setup, make-release ] -# if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} -# steps: -# - name: "Fetch iOS universal build from artifacts" -# uses: actions/download-artifact@v2 -# with: -# name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal -# - name: "Upload release assets" -# uses: actions/upload-release-asset@v1 -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# with: -# upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} -# asset_path: ./libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip -# asset_name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip -# asset_content_type: application/zip + test-integration-libvcx: + needs: workflow-setup + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + runs-on: ubuntu-20.04 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Setup rust testing environment" + uses: ./.github/actions/setup-testing-rust + - name: "Run libvcx tests: pool_tests" + run: | + RUST_TEST_THREADS=1 cargo test --manifest-path="libvcx/Cargo.toml" -F "pool_tests"; + + test-integration-resolver: + needs: workflow-setup + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + runs-on: ubuntu-20.04 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Setup rust testing environment" + uses: ./.github/actions/setup-testing-rust + - name: "Run resolver tests" + run: | + RUST_TEST_THREADS=1 cargo test -p did_doc_builder -p did_parser -p did_resolver -p did_resolver_registry -p did_resolver_sov --test "*" + + test-node-wrapper: + needs: workflow-setup + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + runs-on: ubuntu-22.04 + strategy: + matrix: + node-version: [18.x] + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Setup NodeJS libvcx testing environment" + uses: ./.github/actions/setup-testing-nodejs + with: + skip-docker-setup: true + node-version: ${{ matrix.node-version }} + - name: "Run tests" + run: cd wrappers/node && RUST_LOG=vcx=trace npm run test + + test-integration-node-wrapper: + needs: workflow-setup + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + runs-on: ubuntu-22.04 + strategy: + matrix: + node-version: [18.x] + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Setup NodeJS libvcx testing environment" + uses: ./.github/actions/setup-testing-nodejs + with: + node-version: ${{ matrix.node-version }} + - name: "Install vcxagent-core dependencies" + run: (cd agents/node/vcxagent-core && npm install) + - name: "Run demo" + run: (cd agents/node/vcxagent-core && AGENCY_URL=http://localhost:8080 npm run demo) + - name: "Run demo with revocation" + run: (cd agents/node/vcxagent-core && AGENCY_URL=http://localhost:8080 npm run demo:revocation) + - name: "Run integration tests" + run: (cd agents/node/vcxagent-core && AGENCY_URL=http://localhost:8080 npm run test:integration) + + test-android-build: + runs-on: ubuntu-20.04 + needs: [ workflow-setup, build-docker-android ] + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true' }} + env: + DOCKER_IMG_CACHED_ANDROID: ${{needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID}} + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Docker Login" + uses: azure/docker-login@v1 + with: + login-server: ${{ env.URL_DOCKER_REGISTRY }} + username: $GITHUB_ACTOR + password: ${{ secrets.GITHUB_TOKEN }} + - name: "Load android image" + uses: ./.github/actions/load-image + with: + docker-img: ${{ env.DOCKER_IMG_CACHED_ANDROID }} + - name: "Run android tests" + run: | + rm -rf /tmp/imgcache + docker run --rm -i $DOCKER_IMG_CACHED_ANDROID \ + sh -c '(cd $HOME/aries-vcx && ./wrappers/java/ci/android.test.sh armv7)' + + build-and-publish-ios-wrapper: + needs: workflow-setup + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_IOS != 'true' }} + runs-on: macos-11 + env: + LIBVCX_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} + PUBLISH_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} + steps: + - name: "Git checkout" + uses: actions/checkout@v2 + - name: Switch to xcode version 12.4 + run: | + sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer + xcodebuild -version + - name: "Build iOS wrapper" + run: | + ./wrappers/ios/ci/build.sh + - uses: actions/upload-artifact@v3 + with: + name: libvcx-ios-${{ env.PUBLISH_VERSION }}-device + path: /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-device.zip + - uses: actions/upload-artifact@v3 + with: + name: libvcx-ios-${{ env.PUBLISH_VERSION }}-universal + path: /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-universal.zip + + build-and-publish-ios-legacy-wrapper: + needs: workflow-setup + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_IOS != 'true' }} + runs-on: macos-11 + env: + LIBVCX_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} + PUBLISH_VERSION: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} + steps: + - name: "Git checkout" + uses: actions/checkout@v2 + - name: Switch to xcode version 12.4 + run: | + sudo xcode-select --switch /Applications/Xcode_12.4.app/Contents/Developer + xcodebuild -version + - name: "Build Legacy iOS wrapper" + run: | + ./wrappers/ios_legacy/ci/build.sh + - name: "Rename device as legacy" + run: | + mv /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-device.zip /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-device.zip + - name: "Rename universal as legacy" + run: | + mv /tmp/artifacts/libvcx-ios-${{ env.PUBLISH_VERSION }}-universal.zip /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-universal.zip + - uses: actions/upload-artifact@v3 + with: + name: libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-device + path: /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-device.zip + - uses: actions/upload-artifact@v3 + with: + name: libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-universal + path: /tmp/artifacts/libvcx-ios-legacy-${{ env.PUBLISH_VERSION }}-universal.zip + + build-and-publish-android-device: + runs-on: ubuntu-20.04 + needs: [ workflow-setup, build-docker-android ] + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true' }} + env: + FULL_VERSION_NAME: libvcx-android-${{needs.workflow-setup.outputs.PUBLISH_VERSION}}-device + DOCKER_IMG_CACHED_ANDROID: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Docker Login" + uses: azure/docker-login@v1 + with: + login-server: ${{ env.URL_DOCKER_REGISTRY }} + username: $GITHUB_ACTOR + password: ${{ secrets.GITHUB_TOKEN }} + - name: "Load android image" + uses: ./.github/actions/load-image + with: + docker-img: ${{ env.DOCKER_IMG_CACHED_ANDROID }} + - name: "Build, run android wrapper tests, and publish artifacts" + uses: ./.github/actions/publish-android + with: + abis: "arm arm64" + docker-img-name: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} + full-version-name: ${{ env.FULL_VERSION_NAME }} + - name: "Publish aar artifact" + uses: actions/upload-artifact@v3 + with: + name: ${{ env.FULL_VERSION_NAME }} + path: /tmp/artifacts/aar/${{ env.FULL_VERSION_NAME }}.aar + + build-and-publish-android-emulator: + runs-on: ubuntu-20.04 + needs: [ workflow-setup, build-docker-android ] + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' && needs.workflow-setup.outputs.SKIP_ANDROID != 'true' }} + env: + FULL_VERSION_NAME: libvcx-android-${{needs.workflow-setup.outputs.PUBLISH_VERSION}}-emulator + DOCKER_IMG_CACHED_ANDROID: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Docker Login" + uses: azure/docker-login@v1 + with: + login-server: ${{ env.URL_DOCKER_REGISTRY }} + username: $GITHUB_ACTOR + password: ${{ secrets.GITHUB_TOKEN }} + - name: "Load android image" + uses: ./.github/actions/load-image + with: + docker-img: ${{ env.DOCKER_IMG_CACHED_ANDROID }} + - name: "Build, run android wrapper tests, and publish artifacts" + uses: ./.github/actions/publish-android + with: + abis: "x86 x86_64" + docker-img-name: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_ANDROID }} + full-version-name: ${{ env.FULL_VERSION_NAME }} + - uses: actions/upload-artifact@v3 + with: + name: ${{ env.FULL_VERSION_NAME }} + path: /tmp/artifacts/aar/${{ env.FULL_VERSION_NAME }}.aar + + build-and-publish-ubuntu-lib: + needs: workflow-setup + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + runs-on: ubuntu-20.04 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.65.0 + - uses: Swatinem/rust-cache@v2 + with: + key: "11" + - name: "Install dependencies" + shell: bash + run: | + sudo apt-get update -y + sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev + - name: "Build libvcx.so" + run: cargo build --release + - name: "Publish artifact libvcx.so" + uses: actions/upload-artifact@v3 + with: + name: libvcx.so + path: target/release/libvcx.so + + build-and-publish-darwin-lib: + needs: workflow-setup + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + runs-on: macos-11 + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.65.0 + - uses: Swatinem/rust-cache@v2 + with: + key: "11" + - name: "Install dependencies" + shell: bash + run: | + brew install openssl + brew install zeromq + brew install libsodium + brew install pkg-config + - name: "Build libvcx.dylib" + run: cargo build --release + - name: "Publish artifact libvcx.dylib" + uses: actions/upload-artifact@v3 + with: + name: libvcx.dylib + path: target/release/libvcx.dylib + + ########################################################################################## + ############################ NPMJS PUBLISHING ####################################### + + publish-node-wrapper: + runs-on: ubuntu-20.04 + needs: + - workflow-setup + - test-unit-workspace + - test-integration-libvcx + - test-integration-aries-vcx + - test-integration-aries-vcx-mysql + - test-node-wrapper + - test-integration-node-wrapper + - publish-napi + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + env: + PUBLISH_VERSION: ${{needs.workflow-setup.outputs.PUBLISH_VERSION}} + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Use Node.js 18" + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + - name: "Publish package" + run: | + if [[ "$PUBLISH_VERSION" ]] + then + NPMJS_TOKEN=${{ secrets.NPMJS_TOKEN }} PUBLISH_VERSION=${{ env.PUBLISH_VERSION }} ./wrappers/node/publish.sh + else + echo "New version was not defined, skipping release." + fi + + publish-agent-core: + runs-on: ubuntu-20.04 + needs: + - workflow-setup + - test-unit-workspace + - test-integration-libvcx + - test-integration-aries-vcx + - test-integration-aries-vcx-mysql + - test-node-wrapper + - test-integration-node-wrapper + - publish-napi + - publish-node-wrapper + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + env: + NPMJS_TOKEN: ${{ secrets.NPMJS_TOKEN }} + PUBLISH_VERSION: ${{needs.workflow-setup.outputs.PUBLISH_VERSION}} + steps: + - name: "Git checkout" + uses: actions/checkout@v3 + - name: "Use Node.js 18" + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + - name: "Release agent-core package" + run: | + if [[ "$PUBLISH_VERSION" ]] + then + NPMJS_TOKEN=${{ secrets.NPMJS_TOKEN }} PUBLISH_VERSION=${{ env.PUBLISH_VERSION }} ./agents/node/vcxagent-core/publish.sh + else + echo "New version was not defined, skipping release." + fi + + build-napi: + needs: + - workflow-setup + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + strategy: + fail-fast: false + matrix: + settings: + - host: ubuntu-20.04 + target: x86_64-unknown-linux-gnu + build: |- + set -e + sudo apt-get update -y + sudo apt-get install -y libssl-dev libzmq3-dev + npm run build:napi -- --target x86_64-unknown-linux-gnu + strip *.node + - host: ubuntu-20.04 + target: x86_64-unknown-linux-musl + docker: ghcr.io/hyperledger/aries-vcx/napi-rs-alpine + build: |- + set -e + cd wrappers/vcx-napi-rs + npm run build:napi + strip *.node + - host: macos-latest + target: x86_64-apple-darwin + build: | + brew install openssl zmq pkg-config + npm run build:napi + strip -x *.node + - host: macos-latest + target: aarch64-apple-darwin + skip: ${{ needs.workflow-setup.outputs.SKIP_NAPI_M1 }} + build: | + wget https://github.com/macports/macports-base/releases/download/v2.8.0/MacPorts-2.8.0-12-Monterey.pkg + sudo installer -pkg ./MacPorts-2.8.0-12-Monterey.pkg -target / + export PATH=/opt/local/bin:/opt/local/sbin:$PATH + + sudo port install openssl +universal zmq +universal + export OPENSSL_DIR=/opt/local + export OPENSSL_INCLUDE_DIR=/opt/local/include/ + export OPENSSL_LIB_DIR=/opt/local/lib/ + + export SODIUM_LIB_DIR=/opt/local/lib/ + export SODIUM_INCLUDE_DIR=/opt/local/include + + export LIBZMQ_LIB_DIR=/opt/local/lib/ + export LIBZMQ_INCLUDE_DIR=/opt/local/include + + export PKG_CONFIG_ALLOW_CROSS=1 + export PKG_CONFIG_SYSROOT_DIR=/ + export RUST_BACKTRACE=1 + npm run build:napi -- --target aarch64-apple-darwin + strip -x *.node + name: ${{ matrix.settings.target }} + runs-on: ${{ matrix.settings.host }} + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/build-napi + if: ${{ matrix.settings.skip != 'true' }} + with: + docker: ${{ matrix.settings.docker }} + target: ${{ matrix.settings.target }} + build: ${{ matrix.settings.build }} + node-version: ${{ env.NODE_VERSION }} + rust-version: ${{ env.RUST_TOOLCHAIN_VERSON }} + + publish-napi: + runs-on: ubuntu-20.04 + needs: + - workflow-setup + - build-napi + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/publish-napi + with: + publish-version: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} + npmjs-token: ${{ secrets.NPMJS_TOKEN }} + node-version: ${{ env.NODE_VERSION }} + + ########################################################################################## + ############################## RELEASE ######################################### + + make-release: + runs-on: ubuntu-20.04 + needs: + - workflow-setup + - build-and-publish-ios-wrapper + - build-and-publish-ios-legacy-wrapper + - build-and-publish-android-device + - build-and-publish-android-emulator + - test-unit-workspace + - test-integration-libvcx + - test-integration-aries-vcx + - test-integration-aries-vcx-mysql + - test-android-build + - test-node-wrapper + - test-integration-node-wrapper + if: ${{ needs.workflow-setup.outputs.RELEASE == 'true' || needs.workflow-setup.outputs.PRERELEASE == 'true' }} + outputs: + RELEASE_UPLOAD_URL: ${{ steps.create-release.outputs.upload_url }} + steps: + - name: "Git checkout" + uses: actions/checkout@v2 + - name: "Generate changelog" + uses: heinrichreimer/action-github-changelog-generator@v2.3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + futureRelease: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} + releaseBranch: main + pullRequests: true + unreleased: false + unreleasedOnly: false + issuesWoLabels: true + prWoLabels: true + stripGeneratorNotice: true + stripHeaders: false + maxIssues: 50 + excludeLabels: duplicate,question,invalid,wontfix,changelog-excluded + breakingLabels: backwards-incompatible,breaking + deprecatedLabels: deprecated + headerLabel: "# Changelog" + breakingLabel: '### Breaking changes' + enhancementLabel: '### Enhancements' + bugsLabel: '### Bug fixes' + deprecatedLabel: '### Deprecations' + removedLabel: '### Removals' + securityLabel: '### Security fixes' + issuesLabel: '### Other issues' + prLabel: '### Other pull requests' + addSections: '{"ci":{"prefix":"### CI changes","labels":["ci"]},"wrappers":{"prefix":"### Wrapper changes","labels":["wrappers"]},"agents":{"prefix":"### Changes to agents","labels":["agents"]},"features":{"prefix":"### Features","labels":["features"]},"hotfix":{"prefix":"### Hotfixes","labels":["hotfix"]},"security":{"prefix":"### Security fixes","labels":["security"]},"refactoring":{"prefix":"### Refactoring","labels":["refactoring"]},"tests":{"prefix":"### Tests","labels":["tests"]},"update":{"prefix":"### Updates","labels":["update"]}}' + excludeTagsRegex: '^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))+)?)$' + + - name: "Create a new release" + id: create-release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} + release_name: Release ${{ needs.workflow-setup.outputs.PUBLISH_VERSION }} + body_path: ./CHANGELOG.md + draft: ${{ needs.workflow-setup.outputs.PRERELEASE == 'true' }} + prerelease: ${{ needs.workflow-setup.outputs.PRERELEASE == 'true' }} + + release-android-device: + runs-on: ubuntu-20.04 + needs: [ workflow-setup, make-release ] + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + steps: + - name: "Fetch android device build from artifacts" + uses: actions/download-artifact@v2 + with: + name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device + - name: "Upload release assets" + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} + asset_path: ./libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.aar + asset_name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.aar + asset_content_type: application/aar + + release-android-emulator: + runs-on: ubuntu-20.04 + needs: [ workflow-setup, make-release ] + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + steps: + - name: "Fetch android emulator build from artifacts" + uses: actions/download-artifact@v2 + with: + name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-emulator + - name: "Upload release assets" + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} + asset_path: ./libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-emulator.aar + asset_name: libvcx-android-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-emulator.aar + asset_content_type: application/aar + + release-ios-device: + runs-on: ubuntu-20.04 + needs: [ workflow-setup, make-release ] + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + steps: + - name: "Fetch iOS device build from artifacts" + uses: actions/download-artifact@v2 + with: + name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device + - name: "Upload release assets" + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} + asset_path: ./libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip + asset_name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip + asset_content_type: application/zip + + release-ios-legacy-device: + runs-on: ubuntu-20.04 + needs: [ workflow-setup, make-release ] + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + steps: + - name: "Fetch iOS device build from artifacts" + uses: actions/download-artifact@v2 + with: + name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device + - name: "Upload release assets" + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} + asset_path: ./libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip + asset_name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-device.zip + asset_content_type: application/zip + + release-ios-universal: + runs-on: ubuntu-20.04 + needs: [ workflow-setup, make-release ] + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + steps: + - name: "Fetch iOS universal build from artifacts" + uses: actions/download-artifact@v2 + with: + name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal + - name: "Upload release assets" + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} + asset_path: ./libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip + asset_name: libvcx-ios-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip + asset_content_type: application/zip + + release-ios-legacy-universal: + runs-on: ubuntu-20.04 + needs: [ workflow-setup, make-release ] + if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} + steps: + - name: "Fetch iOS universal build from artifacts" + uses: actions/download-artifact@v2 + with: + name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal + - name: "Upload release assets" + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.make-release.outputs.RELEASE_UPLOAD_URL }} + asset_path: ./libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip + asset_name: libvcx-ios-legacy-${{ needs.workflow-setup.outputs.PUBLISH_VERSION }}-universal.zip + asset_content_type: application/zip From d1f24c23b52dd56348e864d6d8a5fd43d67ac8ed Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Fri, 12 May 2023 16:16:56 +0200 Subject: [PATCH 09/19] Implement issuer side for IndyVdrLedger, remove most of run_indy tests Signed-off-by: Miroslav Kovar --- aries_vcx/src/common/anoncreds.rs | 2 +- aries_vcx/src/common/credentials/mod.rs | 6 +- .../primitives/credential_definition.rs | 16 ++- aries_vcx/src/common/primitives/mod.rs | 12 +- .../primitives/revocation_registry_delta.rs | 2 +- .../src/common/proofs/verifier/verifier.rs | 10 +- .../src/core/profile/vdr_proxy_profile.rs | 11 +- aries_vcx/src/utils/devsetup.rs | 3 +- aries_vcx/tests/test_creds_proofs.rs | 14 +- aries_vcx/tests/test_pool.rs | 4 +- aries_vcx_core/src/ledger/indy_vdr_ledger.rs | 136 +++++++++++++++--- 11 files changed, 158 insertions(+), 58 deletions(-) diff --git a/aries_vcx/src/common/anoncreds.rs b/aries_vcx/src/common/anoncreds.rs index 7648a5af6c..aed23b1f57 100644 --- a/aries_vcx/src/common/anoncreds.rs +++ b/aries_vcx/src/common/anoncreds.rs @@ -60,7 +60,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_revoke_credential() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let (_, _, _, _, _, _, _, _, rev_reg_id, cred_rev_id, _, rev_reg) = create_and_store_credential( diff --git a/aries_vcx/src/common/credentials/mod.rs b/aries_vcx/src/common/credentials/mod.rs index c61bd5a8c3..225ffc0f5e 100644 --- a/aries_vcx/src/common/credentials/mod.rs +++ b/aries_vcx/src/common/credentials/mod.rs @@ -53,7 +53,7 @@ mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_prover_get_credential() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let res = create_and_store_credential( @@ -85,7 +85,7 @@ mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_get_cred_rev_id() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let res = create_and_store_credential( @@ -108,7 +108,7 @@ mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_is_cred_revoked() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let res = create_and_store_credential( diff --git a/aries_vcx/src/common/primitives/credential_definition.rs b/aries_vcx/src/common/primitives/credential_definition.rs index c3db10c061..96515722b6 100644 --- a/aries_vcx/src/common/primitives/credential_definition.rs +++ b/aries_vcx/src/common/primitives/credential_definition.rs @@ -285,14 +285,14 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_create_cred_def_real() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let (schema_id, _) = create_and_write_test_schema(&setup.profile, &setup.institution_did, DEFAULT_SCHEMA_ATTRS).await; let ledger = Arc::clone(&setup.profile).inject_ledger(); let schema_json = ledger.get_schema(&schema_id, None).await.unwrap(); - let (_, cred_def_json) = generate_cred_def( + let (cred_def_id, cred_def_json_local) = generate_cred_def( &setup.profile, &setup.institution_did, &schema_json, @@ -304,9 +304,17 @@ pub mod integration_tests { .unwrap(); ledger - .publish_cred_def(&cred_def_json, &setup.institution_did) + .publish_cred_def(&cred_def_json_local, &setup.institution_did) .await .unwrap(); + + let cred_def_json_ledger = ledger + .get_cred_def(&cred_def_id, Some(&setup.institution_did)) + .await + .unwrap(); + + assert!(cred_def_json_local.contains(&cred_def_id)); + assert!(cred_def_json_ledger.contains(&cred_def_id)); }) .await; } @@ -314,7 +322,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_create_rev_reg_def() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let (schema_id, _) = create_and_write_test_schema(&setup.profile, &setup.institution_did, DEFAULT_SCHEMA_ATTRS).await; let ledger = Arc::clone(&setup.profile).inject_ledger(); diff --git a/aries_vcx/src/common/primitives/mod.rs b/aries_vcx/src/common/primitives/mod.rs index 74878fac6a..8a17e6672d 100644 --- a/aries_vcx/src/common/primitives/mod.rs +++ b/aries_vcx/src/common/primitives/mod.rs @@ -21,7 +21,7 @@ pub mod integration_tests { #[ignore] async fn test_pool_rev_reg_def_fails_for_cred_def_created_without_revocation() { // todo: does not need agency setup - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { // Cred def is created with support_revocation=false, // revoc_reg_def will fail in libindy because cred_Def doesn't have revocation keys let (_, _, cred_def_id, _, _) = create_and_store_nonrevocable_credential_def( @@ -49,7 +49,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_get_rev_reg_def_json() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let attrs = r#"["address1","address2","city","state","zip"]"#; let (_, _, _, _, rev_reg_id, _, _) = create_and_store_credential_def(&setup.profile, &setup.institution_did, attrs).await; @@ -63,7 +63,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_get_rev_reg_delta_json() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let attrs = r#"["address1","address2","city","state","zip"]"#; let (_, _, _, _, rev_reg_id, _, _) = create_and_store_credential_def(&setup.profile, &setup.institution_did, attrs).await; @@ -79,7 +79,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_get_rev_reg() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let attrs = r#"["address1","address2","city","state","zip"]"#; let (_, _, _, _, rev_reg_id, _, _) = create_and_store_credential_def(&setup.profile, &setup.institution_did, attrs).await; @@ -98,7 +98,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_get_cred_def() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let attrs = r#"["address1","address2","city","state","zip"]"#; let (_, _, cred_def_id, cred_def_json, _) = create_and_store_nonrevocable_credential_def(&setup.profile, &setup.institution_did, attrs).await; @@ -117,7 +117,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_from_pool_ledger_with_id() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let (schema_id, _schema_json) = create_and_write_test_schema(&setup.profile, &setup.institution_did, DEFAULT_SCHEMA_ATTRS).await; diff --git a/aries_vcx/src/common/primitives/revocation_registry_delta.rs b/aries_vcx/src/common/primitives/revocation_registry_delta.rs index f51f1fe964..43eb08caad 100644 --- a/aries_vcx/src/common/primitives/revocation_registry_delta.rs +++ b/aries_vcx/src/common/primitives/revocation_registry_delta.rs @@ -66,7 +66,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_create_rev_reg_delta_from_ledger() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let attrs = r#"["address1","address2","city","state","zip"]"#; let (_, _, _, _, rev_reg_id, _, _) = create_and_store_credential_def(&setup.profile, &setup.institution_did, attrs).await; diff --git a/aries_vcx/src/common/proofs/verifier/verifier.rs b/aries_vcx/src/common/proofs/verifier/verifier.rs index 0707f69f20..2e0e0c6cac 100644 --- a/aries_vcx/src/common/proofs/verifier/verifier.rs +++ b/aries_vcx/src/common/proofs/verifier/verifier.rs @@ -129,7 +129,7 @@ pub mod unit_tests { #[tokio::test] #[ignore] async fn test_pool_proof_restrictions() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let requested_attrs = json!([ @@ -218,7 +218,7 @@ pub mod unit_tests { #[tokio::test] #[ignore] async fn test_pool_proof_validate_attribute() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let requested_attrs = json!([ @@ -334,7 +334,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_prover_verify_proof() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let (schemas, cred_defs, proof_req, proof) = @@ -354,7 +354,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_prover_verify_proof_with_predicate_success_case() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let (schemas, cred_defs, proof_req, proof) = @@ -374,7 +374,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_prover_verify_proof_with_predicate_fail_case() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let (schemas, cred_defs, proof_req, proof) = diff --git a/aries_vcx/src/core/profile/vdr_proxy_profile.rs b/aries_vcx/src/core/profile/vdr_proxy_profile.rs index 79bf65d06d..3e64f4c574 100644 --- a/aries_vcx/src/core/profile/vdr_proxy_profile.rs +++ b/aries_vcx/src/core/profile/vdr_proxy_profile.rs @@ -1,12 +1,12 @@ use std::sync::Arc; use aries_vcx_core::{ - anoncreds::{base_anoncreds::BaseAnonCreds, credx_anoncreds::IndyCredxAnonCreds}, + anoncreds::{base_anoncreds::BaseAnonCreds, indy_anoncreds::IndySdkAnonCreds}, ledger::{ base_ledger::BaseLedger, indy_vdr_ledger::IndyVdrLedger, request_submitter::vdr_proxy::VdrProxySubmitter, }, - wallet::base_wallet::BaseWallet, - VdrProxyClient, + wallet::{base_wallet::BaseWallet, indy_wallet::IndySdkWallet}, + VdrProxyClient, WalletHandle, }; use super::profile::Profile; @@ -19,10 +19,11 @@ pub struct VdrProxyProfile { } impl VdrProxyProfile { - pub fn new(wallet: Arc, client: VdrProxyClient) -> Self { + pub fn new(wallet_handle: WalletHandle, client: VdrProxyClient) -> Self { + let wallet = Arc::new(IndySdkWallet::new(wallet_handle)); let submitter = Arc::new(VdrProxySubmitter::new(Arc::new(client))); let ledger = Arc::new(IndyVdrLedger::new(wallet.clone(), submitter)); - let anoncreds = Arc::new(IndyCredxAnonCreds::new(Arc::clone(&wallet))); + let anoncreds = Arc::new(IndySdkAnonCreds::new(wallet_handle)); VdrProxyProfile { wallet, ledger, diff --git a/aries_vcx/src/utils/devsetup.rs b/aries_vcx/src/utils/devsetup.rs index 50f351aeba..374e10954b 100644 --- a/aries_vcx/src/utils/devsetup.rs +++ b/aries_vcx/src/utils/devsetup.rs @@ -462,10 +462,9 @@ impl SetupProfile { // TODO: Test configuration should be handled uniformly let client_url = env::var("VDR_PROXY_CLIENT_URL").unwrap_or_else(|_| "http://127.0.0.1:3030".to_string()); - let wallet = IndySdkWallet::new(wallet_handle); let client = VdrProxyClient::new(&client_url).unwrap(); - let profile: Arc = Arc::new(VdrProxyProfile::new(Arc::new(wallet), client)); + let profile: Arc = Arc::new(VdrProxyProfile::new(wallet_handle, client)); async fn vdr_proxy_teardown() { // nothing to do diff --git a/aries_vcx/tests/test_creds_proofs.rs b/aries_vcx/tests/test_creds_proofs.rs index bc61064a4a..8d0d7d65e7 100644 --- a/aries_vcx/tests/test_creds_proofs.rs +++ b/aries_vcx/tests/test_creds_proofs.rs @@ -30,7 +30,7 @@ mod integration_tests { #[ignore] async fn test_agency_pool_retrieve_credentials() { // todo - use SetupProfile::run after modular impls - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; create_and_store_nonrevocable_credential( @@ -69,7 +69,7 @@ mod integration_tests { #[ignore] async fn test_agency_pool_get_credential_def() { // todo - use SetupProfile::run after modular impls - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let (_, _, cred_def_id, cred_def_json, _) = create_and_store_nonrevocable_credential_def( &setup.profile, &setup.institution_did, @@ -91,7 +91,7 @@ mod integration_tests { #[ignore] async fn test_agency_pool_retrieve_credentials_empty() { // todo - use SetupProfile::run after modular impls - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let mut req = json!({ "nonce":"123432421212", "name":"proof_req_1", @@ -148,7 +148,7 @@ mod integration_tests { #[ignore] async fn test_agency_pool_case_for_proof_req_doesnt_matter_for_retrieve_creds() { // todo - use SetupProfile::run after modular impls - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { create_and_store_nonrevocable_credential( &setup.profile, &setup.profile, @@ -245,7 +245,7 @@ mod integration_tests { #[ignore] async fn test_agency_pool_generate_proof() { // todo - use SetupProfile::run after modular impls - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { create_and_store_credential( &setup.profile, &setup.profile, @@ -326,7 +326,7 @@ mod integration_tests { #[ignore] async fn test_agency_pool_generate_proof_with_predicates() { // todo - use SetupProfile::run after modular impls - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { create_and_store_credential( &setup.profile, &setup.profile, @@ -411,7 +411,7 @@ mod integration_tests { #[ignore] async fn test_agency_pool_generate_self_attested_proof() { // todo - use SetupProfile::run after modular impls - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let indy_proof_req = json!({ "nonce":"123432421212", "name":"proof_req_1", diff --git a/aries_vcx/tests/test_pool.rs b/aries_vcx/tests/test_pool.rs index 0ec8c1595d..a80f9a8a27 100644 --- a/aries_vcx/tests/test_pool.rs +++ b/aries_vcx/tests/test_pool.rs @@ -33,7 +33,7 @@ mod integration_tests { #[ignore] async fn test_pool_get_credential_def() { // TODO - use SetupProfile::run after modular impls - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let (_, _, cred_def_id, cred_def_json, _) = create_and_store_nonrevocable_credential_def( &setup.profile, &setup.institution_did, @@ -71,7 +71,7 @@ mod integration_tests { // TODO - future - bring back after all endorser methods added to baseledger // #[tokio::test] // async fn test_endorse_transaction() { - // SetupProfile::run_indy(|setup| async move { + // SetupProfile::run(|setup| async move { // let ledger = Arc::clone(&setup.profile).inject_ledger(); // let (author_did, _) = add_new_did(&setup.profile, &setup.institution_did, None).await.unwrap(); // let (endorser_did, _) = add_new_did(&setup.profile, &setup.institution_did, Some("ENDORSER")).await.unwrap(); diff --git a/aries_vcx_core/src/ledger/indy_vdr_ledger.rs b/aries_vcx_core/src/ledger/indy_vdr_ledger.rs index b24f82b00f..0587f5b964 100644 --- a/aries_vcx_core/src/ledger/indy_vdr_ledger.rs +++ b/aries_vcx_core/src/ledger/indy_vdr_ledger.rs @@ -1,15 +1,19 @@ +use indy_credx::ursa::cl::RevocationRegistryDelta as UrsaRevocationRegistryDelta; use indy_vdr as vdr; use std::fmt::{Debug, Formatter}; use std::sync::Arc; use time::OffsetDateTime; +use vdr::ledger::requests::cred_def::CredentialDefinitionV1; +use vdr::ledger::requests::rev_reg::{RevocationRegistryDelta, RevocationRegistryDeltaV1}; +use vdr::ledger::requests::rev_reg_def::{RegistryType, RevocationRegistryDefinition, RevocationRegistryDefinitionV1}; use vdr::ledger::requests::schema::{AttributeNames, Schema, SchemaV1}; use async_trait::async_trait; use serde_json::Value; use vdr::ledger::identifiers::{CredentialDefinitionId, RevocationRegistryId, SchemaId}; -use vdr::ledger::requests::author_agreement::TxnAuthrAgrmtAcceptanceData; +use vdr::ledger::requests::{author_agreement::TxnAuthrAgrmtAcceptanceData, cred_def::CredentialDefinition}; use vdr::ledger::RequestBuilder; -use vdr::pool::{PreparedRequest, ProtocolVersion}; +use vdr::pool::{LedgerType, PreparedRequest, ProtocolVersion}; use vdr::utils::did::DidValue; use vdr::utils::Qualifiable; @@ -71,11 +75,7 @@ where submitter_did: Option<&str>, cred_def_id: &str, ) -> VcxCoreResult { - let identifier = if let Some(did) = submitter_did { - Some(DidValue::from_str(did)?) - } else { - None - }; + let identifier = submitter_did.map(DidValue::from_str).transpose()?; let id = CredentialDefinitionId::from_str(cred_def_id)?; Ok(self .request_builder()? @@ -121,6 +121,58 @@ where .request_builder()? .build_attrib_request(&identifier, &dest, None, attrib_json.as_ref(), None)?) } + + fn _build_schema_request(&self, submitter_did: &str, schema_data: &str) -> VcxCoreResult { + let identifier = DidValue::from_str(submitter_did)?; + let schema_data: SchemaV1 = serde_json::from_str(schema_data)?; + Ok(self + .request_builder()? + .build_schema_request(&identifier, Schema::SchemaV1(schema_data))?) + } + + fn _build_cred_def_request(&self, submitter_did: &str, cred_def_data: &str) -> VcxCoreResult { + let identifier = DidValue::from_str(submitter_did)?; + let cred_def_data: CredentialDefinitionV1 = serde_json::from_str(cred_def_data)?; + Ok(self + .request_builder()? + .build_cred_def_request(&identifier, CredentialDefinition::CredentialDefinitionV1(cred_def_data))?) + } + + fn _build_rev_reg_def_request( + &self, + submitter_did: &str, + rev_reg_def_data: &str, + ) -> VcxCoreResult { + let identifier = DidValue::from_str(submitter_did)?; + let rev_reg_def_data: RevocationRegistryDefinitionV1 = serde_json::from_str(rev_reg_def_data)?; + Ok(self.request_builder()?.build_revoc_reg_def_request( + &identifier, + RevocationRegistryDefinition::RevocationRegistryDefinitionV1(rev_reg_def_data), + )?) + } + + fn _build_rev_reg_delta_request( + &self, + submitter_did: &str, + rev_reg_id: &str, + rev_reg_delta_data: &str, + ) -> VcxCoreResult { + let identifier = DidValue::from_str(submitter_did)?; + let rev_reg_delta_data: RevocationRegistryDeltaV1 = serde_json::from_str(rev_reg_delta_data)?; + Ok(self.request_builder()?.build_revoc_reg_entry_request( + &identifier, + &RevocationRegistryId::from_str(rev_reg_id)?, + &RegistryType::CL_ACCUM, + RevocationRegistryDelta::RevocationRegistryDeltaV1(rev_reg_delta_data), + )?) + } + + fn _build_get_txn_request(&self, submitter_did: Option<&str>, seq_no: i32) -> VcxCoreResult { + let identifier = submitter_did.map(DidValue::from_str).transpose()?; + Ok(self + .request_builder()? + .build_get_txn_request(identifier.as_ref(), LedgerType::DOMAIN.to_id(), seq_no)?) + } } impl Debug for IndyVdrLedger @@ -377,18 +429,42 @@ where } async fn get_rev_reg(&self, rev_reg_id: &str, timestamp: u64) -> VcxCoreResult<(String, String, u64)> { - let _ = (rev_reg_id, timestamp); - Err(unimplemented_method_err("indy_vdr get_rev_reg")) + let revoc_reg_def_id = RevocationRegistryId::from_str(rev_reg_id)?; + + let request = self.request_builder()?.build_get_revoc_reg_request( + None, + &revoc_reg_def_id, + timestamp.try_into().unwrap(), + )?; + let res = self._submit_request(request).await?; + + let res_data = _get_response_json_data_field(&res)?; + + let rev_reg_def_id = res_data["revocRegDefId"] + .as_str() + .ok_or(AriesVcxCoreError::from_msg( + AriesVcxCoreErrorKind::InvalidJson, + "Error parsing revocRegDefId value as string", + ))? + .to_string(); + + let timestamp = res_data["txnTime"].as_u64().ok_or(AriesVcxCoreError::from_msg( + AriesVcxCoreErrorKind::InvalidJson, + "Error parsing txnTime value as u64", + ))?; + + Ok((rev_reg_def_id, res_data["value"].to_string(), timestamp)) } async fn get_ledger_txn(&self, seq_no: i32, submitter_did: Option<&str>) -> VcxCoreResult { - let _ = (seq_no, submitter_did); - Err(unimplemented_method_err("indy_vdr get_ledger_txn")) + let request = self._build_get_txn_request(submitter_did, seq_no)?; + self._submit_request(request).await } async fn build_schema_request(&self, submitter_did: &str, schema_json: &str) -> VcxCoreResult { - let _ = (submitter_did, schema_json); - Err(unimplemented_method_err("indy_vdr build_schema_request")) + let request = self._build_schema_request(submitter_did, schema_json)?; + let request = _append_txn_author_agreement_to_request(request).await?; + Ok(request.req_json.to_string()) } async fn publish_schema( @@ -397,18 +473,24 @@ where submitter_did: &str, endorser_did: Option, ) -> VcxCoreResult<()> { - let _ = (schema_json, submitter_did, endorser_did); - Err(unimplemented_method_err("indy_vdr publish_schema")) + let request = self._build_schema_request(submitter_did, schema_json)?; + let request = _append_txn_author_agreement_to_request(request).await?; + self._sign_and_submit_request(submitter_did, request).await?; + Ok(()) } async fn publish_cred_def(&self, cred_def_json: &str, submitter_did: &str) -> VcxCoreResult<()> { - let _ = (cred_def_json, submitter_did); - Err(unimplemented_method_err("indy_vdr publish_cred_def")) + let request = self._build_cred_def_request(submitter_did, cred_def_json)?; + let request = _append_txn_author_agreement_to_request(request).await?; + self._sign_and_submit_request(submitter_did, request).await?; + Ok(()) } async fn publish_rev_reg_def(&self, rev_reg_def: &str, submitter_did: &str) -> VcxCoreResult<()> { - let _ = (rev_reg_def, submitter_did); - Err(unimplemented_method_err("indy_vdr publish_rev_reg_def")) + let request = self._build_rev_reg_def_request(submitter_did, rev_reg_def)?; + let request = _append_txn_author_agreement_to_request(request).await?; + self._sign_and_submit_request(submitter_did, request).await?; + Ok(()) } async fn publish_rev_reg_delta( @@ -417,8 +499,10 @@ where rev_reg_entry_json: &str, submitter_did: &str, ) -> VcxCoreResult<()> { - let _ = (rev_reg_entry_json, rev_reg_id, submitter_did); - Err(unimplemented_method_err("indy_vdr publish_rev_reg_delta")) + let request = self._build_rev_reg_delta_request(submitter_did, rev_reg_id, rev_reg_entry_json)?; + let request = _append_txn_author_agreement_to_request(request).await?; + self._sign_and_submit_request(submitter_did, request).await?; + Ok(()) } } @@ -453,5 +537,13 @@ async fn _append_txn_author_agreement_to_request(request: PreparedRequest) -> Vc fn _get_response_json_data_field(response_json: &str) -> VcxCoreResult { let res: Value = serde_json::from_str(response_json)?; let result = (&res).try_get("result")?; - Ok(result.try_get("data")?.to_owned()) + let data = result.try_get("data")?.to_owned(); + if data.is_null() { + Err(AriesVcxCoreError::from_msg( + AriesVcxCoreErrorKind::LedgerItemNotFound, + "No data in response", + )) + } else { + Ok(data) + } } From 0a1736009340c276d53572774956dd2c17007340 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Fri, 12 May 2023 17:00:36 +0200 Subject: [PATCH 10/19] Adjust dockerfile Signed-off-by: Miroslav Kovar --- .github/actions/setup-testing-rust/action.yml | 2 +- ci/vdrproxy.dockerfile | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/actions/setup-testing-rust/action.yml b/.github/actions/setup-testing-rust/action.yml index 5952e0236b..01e7a5e7b3 100644 --- a/.github/actions/setup-testing-rust/action.yml +++ b/.github/actions/setup-testing-rust/action.yml @@ -35,4 +35,4 @@ runs: if: ${{ inputs.skip-vdrproxy-setup != 'true' }} shell: bash run: | - docker run --rm -d --name vdrproxy --network host -e GENESIS=${{ env.GENESIS_URL }} -e PORT=${{ env.VDR_PROXY_PORT }} ${{ env.DOCKER_IMAGE_VDRPROXY }} + docker run --rm -d --name vdrproxy --network host ${{ env.DOCKER_IMAGE_VDRPROXY }} -p ${{ env.VDR_PROXY_PORT }} -g ${{ env.GENESIS_URL }} diff --git a/ci/vdrproxy.dockerfile b/ci/vdrproxy.dockerfile index c7c13f7f66..24e2234d82 100644 --- a/ci/vdrproxy.dockerfile +++ b/ci/vdrproxy.dockerfile @@ -17,8 +17,5 @@ RUN apk update && apk upgrade && \ libstdc++ \ libgcc -ENV PORT 3030 -ENV GENESIS genesis.txn - COPY --from=builder /home/indy/indy-vdr/target/release/indy-vdr-proxy indy-vdr-proxy -ENTRYPOINT ./indy-vdr-proxy -p ${PORT} -g ${GENESIS} +ENTRYPOINT ["./indy-vdr-proxy"] From f72ebe6572de851f4d6086405ba502fdea34c275 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Fri, 12 May 2023 17:57:30 +0200 Subject: [PATCH 11/19] Extend vdrproxy tests Signed-off-by: Miroslav Kovar --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fcdb03cab3..f730a19d66 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -477,7 +477,7 @@ jobs: with: skip-vdrproxy-setup: false - name: "Run aries-vcx tests: vdrproxy_test" - run: cargo test --manifest-path="aries_vcx/Cargo.toml" --test test_pool -F vdr_proxy_ledger -- --ignored + run: cargo test --manifest-path="aries_vcx/Cargo.toml" -F vdr_proxy_ledger -- --ignored test-integration-libvcx: needs: workflow-setup From 5630ddf08304c9613510839d627f2f3cb0cc34c4 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Mon, 15 May 2023 09:39:32 +0200 Subject: [PATCH 12/19] Revert run_indy deletion, run proxy tests with run_indy Signed-off-by: Miroslav Kovar --- aries_vcx/src/common/anoncreds.rs | 4 ++-- aries_vcx/src/common/credentials/mod.rs | 6 +++--- .../primitives/credential_definition.rs | 4 ++-- aries_vcx/src/common/primitives/mod.rs | 10 ++++----- .../primitives/revocation_registry_delta.rs | 2 +- .../src/common/proofs/verifier/verifier.rs | 10 ++++----- aries_vcx/src/utils/devsetup.rs | 6 +++++- aries_vcx/tests/test_creds_proofs.rs | 21 +++++++------------ aries_vcx/tests/test_pool.rs | 4 ++-- 9 files changed, 32 insertions(+), 35 deletions(-) diff --git a/aries_vcx/src/common/anoncreds.rs b/aries_vcx/src/common/anoncreds.rs index aed23b1f57..0c5598b350 100644 --- a/aries_vcx/src/common/anoncreds.rs +++ b/aries_vcx/src/common/anoncreds.rs @@ -25,7 +25,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_prover_get_credentials() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let proof_req = json!({ "nonce":"123432421212", "name":"proof_req_1", @@ -60,7 +60,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_revoke_credential() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let (_, _, _, _, _, _, _, _, rev_reg_id, cred_rev_id, _, rev_reg) = create_and_store_credential( diff --git a/aries_vcx/src/common/credentials/mod.rs b/aries_vcx/src/common/credentials/mod.rs index 225ffc0f5e..c61bd5a8c3 100644 --- a/aries_vcx/src/common/credentials/mod.rs +++ b/aries_vcx/src/common/credentials/mod.rs @@ -53,7 +53,7 @@ mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_prover_get_credential() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let res = create_and_store_credential( @@ -85,7 +85,7 @@ mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_get_cred_rev_id() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let res = create_and_store_credential( @@ -108,7 +108,7 @@ mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_is_cred_revoked() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let res = create_and_store_credential( diff --git a/aries_vcx/src/common/primitives/credential_definition.rs b/aries_vcx/src/common/primitives/credential_definition.rs index 96515722b6..1b0f90e6b6 100644 --- a/aries_vcx/src/common/primitives/credential_definition.rs +++ b/aries_vcx/src/common/primitives/credential_definition.rs @@ -285,7 +285,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_create_cred_def_real() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let (schema_id, _) = create_and_write_test_schema(&setup.profile, &setup.institution_did, DEFAULT_SCHEMA_ATTRS).await; @@ -322,7 +322,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_create_rev_reg_def() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let (schema_id, _) = create_and_write_test_schema(&setup.profile, &setup.institution_did, DEFAULT_SCHEMA_ATTRS).await; let ledger = Arc::clone(&setup.profile).inject_ledger(); diff --git a/aries_vcx/src/common/primitives/mod.rs b/aries_vcx/src/common/primitives/mod.rs index 8a17e6672d..260542d2c7 100644 --- a/aries_vcx/src/common/primitives/mod.rs +++ b/aries_vcx/src/common/primitives/mod.rs @@ -21,7 +21,7 @@ pub mod integration_tests { #[ignore] async fn test_pool_rev_reg_def_fails_for_cred_def_created_without_revocation() { // todo: does not need agency setup - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { // Cred def is created with support_revocation=false, // revoc_reg_def will fail in libindy because cred_Def doesn't have revocation keys let (_, _, cred_def_id, _, _) = create_and_store_nonrevocable_credential_def( @@ -49,7 +49,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_get_rev_reg_def_json() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let attrs = r#"["address1","address2","city","state","zip"]"#; let (_, _, _, _, rev_reg_id, _, _) = create_and_store_credential_def(&setup.profile, &setup.institution_did, attrs).await; @@ -63,7 +63,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_get_rev_reg_delta_json() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let attrs = r#"["address1","address2","city","state","zip"]"#; let (_, _, _, _, rev_reg_id, _, _) = create_and_store_credential_def(&setup.profile, &setup.institution_did, attrs).await; @@ -79,7 +79,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_get_rev_reg() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let attrs = r#"["address1","address2","city","state","zip"]"#; let (_, _, _, _, rev_reg_id, _, _) = create_and_store_credential_def(&setup.profile, &setup.institution_did, attrs).await; @@ -98,7 +98,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_get_cred_def() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let attrs = r#"["address1","address2","city","state","zip"]"#; let (_, _, cred_def_id, cred_def_json, _) = create_and_store_nonrevocable_credential_def(&setup.profile, &setup.institution_did, attrs).await; diff --git a/aries_vcx/src/common/primitives/revocation_registry_delta.rs b/aries_vcx/src/common/primitives/revocation_registry_delta.rs index 43eb08caad..f51f1fe964 100644 --- a/aries_vcx/src/common/primitives/revocation_registry_delta.rs +++ b/aries_vcx/src/common/primitives/revocation_registry_delta.rs @@ -66,7 +66,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_create_rev_reg_delta_from_ledger() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let attrs = r#"["address1","address2","city","state","zip"]"#; let (_, _, _, _, rev_reg_id, _, _) = create_and_store_credential_def(&setup.profile, &setup.institution_did, attrs).await; diff --git a/aries_vcx/src/common/proofs/verifier/verifier.rs b/aries_vcx/src/common/proofs/verifier/verifier.rs index 2e0e0c6cac..0707f69f20 100644 --- a/aries_vcx/src/common/proofs/verifier/verifier.rs +++ b/aries_vcx/src/common/proofs/verifier/verifier.rs @@ -129,7 +129,7 @@ pub mod unit_tests { #[tokio::test] #[ignore] async fn test_pool_proof_restrictions() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let requested_attrs = json!([ @@ -218,7 +218,7 @@ pub mod unit_tests { #[tokio::test] #[ignore] async fn test_pool_proof_validate_attribute() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let requested_attrs = json!([ @@ -334,7 +334,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_prover_verify_proof() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let (schemas, cred_defs, proof_req, proof) = @@ -354,7 +354,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_prover_verify_proof_with_predicate_success_case() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let (schemas, cred_defs, proof_req, proof) = @@ -374,7 +374,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_prover_verify_proof_with_predicate_fail_case() { - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; let (schemas, cred_defs, proof_req, proof) = diff --git a/aries_vcx/src/utils/devsetup.rs b/aries_vcx/src/utils/devsetup.rs index 374e10954b..e7109445ec 100644 --- a/aries_vcx/src/utils/devsetup.rs +++ b/aries_vcx/src/utils/devsetup.rs @@ -495,11 +495,15 @@ impl SetupProfile { // FUTURE - ideally no tests should be using this method, they should be using the generic run // after modular profile Anoncreds/Ledger methods have all been implemented, all tests should use run() - #[cfg(feature = "vdrtools")] + #[cfg(any(feature = "vdrtools", feature = "vdr_proxy_ledger"))] pub async fn run_indy(f: impl FnOnce(Self) -> F) where F: Future, { + #[cfg(feature = "vdr_proxy_ledger")] + let init = Self::init_vdr_proxy_ledger().await; + + #[cfg(all(feature = "vdrtools", not(feature = "vdr_proxy_ledger")))] let init = Self::init_indy().await; let teardown = Arc::clone(&init.teardown); diff --git a/aries_vcx/tests/test_creds_proofs.rs b/aries_vcx/tests/test_creds_proofs.rs index 8d0d7d65e7..44f8ac69c0 100644 --- a/aries_vcx/tests/test_creds_proofs.rs +++ b/aries_vcx/tests/test_creds_proofs.rs @@ -29,8 +29,7 @@ mod integration_tests { #[tokio::test] #[ignore] async fn test_agency_pool_retrieve_credentials() { - // todo - use SetupProfile::run after modular impls - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let holder_setup = init_holder_setup_in_indy_context(&setup).await; create_and_store_nonrevocable_credential( @@ -68,8 +67,7 @@ mod integration_tests { #[tokio::test] #[ignore] async fn test_agency_pool_get_credential_def() { - // todo - use SetupProfile::run after modular impls - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let (_, _, cred_def_id, cred_def_json, _) = create_and_store_nonrevocable_credential_def( &setup.profile, &setup.institution_did, @@ -90,8 +88,7 @@ mod integration_tests { #[tokio::test] #[ignore] async fn test_agency_pool_retrieve_credentials_empty() { - // todo - use SetupProfile::run after modular impls - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let mut req = json!({ "nonce":"123432421212", "name":"proof_req_1", @@ -147,8 +144,7 @@ mod integration_tests { #[tokio::test] #[ignore] async fn test_agency_pool_case_for_proof_req_doesnt_matter_for_retrieve_creds() { - // todo - use SetupProfile::run after modular impls - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { create_and_store_nonrevocable_credential( &setup.profile, &setup.profile, @@ -244,8 +240,7 @@ mod integration_tests { #[tokio::test] #[ignore] async fn test_agency_pool_generate_proof() { - // todo - use SetupProfile::run after modular impls - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { create_and_store_credential( &setup.profile, &setup.profile, @@ -325,8 +320,7 @@ mod integration_tests { #[tokio::test] #[ignore] async fn test_agency_pool_generate_proof_with_predicates() { - // todo - use SetupProfile::run after modular impls - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { create_and_store_credential( &setup.profile, &setup.profile, @@ -410,8 +404,7 @@ mod integration_tests { #[tokio::test] #[ignore] async fn test_agency_pool_generate_self_attested_proof() { - // todo - use SetupProfile::run after modular impls - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let indy_proof_req = json!({ "nonce":"123432421212", "name":"proof_req_1", diff --git a/aries_vcx/tests/test_pool.rs b/aries_vcx/tests/test_pool.rs index a80f9a8a27..0ec8c1595d 100644 --- a/aries_vcx/tests/test_pool.rs +++ b/aries_vcx/tests/test_pool.rs @@ -33,7 +33,7 @@ mod integration_tests { #[ignore] async fn test_pool_get_credential_def() { // TODO - use SetupProfile::run after modular impls - SetupProfile::run(|setup| async move { + SetupProfile::run_indy(|setup| async move { let (_, _, cred_def_id, cred_def_json, _) = create_and_store_nonrevocable_credential_def( &setup.profile, &setup.institution_did, @@ -71,7 +71,7 @@ mod integration_tests { // TODO - future - bring back after all endorser methods added to baseledger // #[tokio::test] // async fn test_endorse_transaction() { - // SetupProfile::run(|setup| async move { + // SetupProfile::run_indy(|setup| async move { // let ledger = Arc::clone(&setup.profile).inject_ledger(); // let (author_did, _) = add_new_did(&setup.profile, &setup.institution_did, None).await.unwrap(); // let (endorser_did, _) = add_new_did(&setup.profile, &setup.institution_did, Some("ENDORSER")).await.unwrap(); From 9878f84b92f0b1fae57c0506deb6b271d209ed04 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Mon, 15 May 2023 09:56:15 +0200 Subject: [PATCH 13/19] Skip test_pool_rotate_verkey_fails for indy_vdr_proxy feature flag Signed-off-by: Miroslav Kovar --- aries_vcx/src/common/keys.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/aries_vcx/src/common/keys.rs b/aries_vcx/src/common/keys.rs index 47452f1936..22f4bed3d8 100644 --- a/aries_vcx/src/common/keys.rs +++ b/aries_vcx/src/common/keys.rs @@ -84,6 +84,7 @@ mod test { #[tokio::test] #[ignore] + #[cfg(not(feature = "vdr_proxy_ledger"))] async fn test_pool_rotate_verkey_fails() { SetupProfile::run_indy(|setup| async move { enable_pool_mocks(); From e30aaac5730796e77f59ce7ba982ff60486be882 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Mon, 15 May 2023 10:49:09 +0200 Subject: [PATCH 14/19] Try sleeping in test_pool_create_cred_def_real Signed-off-by: Miroslav Kovar --- aries_vcx/src/common/primitives/credential_definition.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aries_vcx/src/common/primitives/credential_definition.rs b/aries_vcx/src/common/primitives/credential_definition.rs index 1b0f90e6b6..cfbd6481c7 100644 --- a/aries_vcx/src/common/primitives/credential_definition.rs +++ b/aries_vcx/src/common/primitives/credential_definition.rs @@ -308,6 +308,8 @@ pub mod integration_tests { .await .unwrap(); + std::thread::sleep(std::time::Duration::from_secs(2)); + let cred_def_json_ledger = ledger .get_cred_def(&cred_def_id, Some(&setup.institution_did)) .await From 6f32cf756631b288ea1408ce889e1444b1936095 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Tue, 16 May 2023 11:51:50 +0200 Subject: [PATCH 15/19] Address CR Signed-off-by: Miroslav Kovar --- aries_vcx/src/common/anoncreds.rs | 2 +- aries_vcx/src/common/primitives/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aries_vcx/src/common/anoncreds.rs b/aries_vcx/src/common/anoncreds.rs index 0c5598b350..7648a5af6c 100644 --- a/aries_vcx/src/common/anoncreds.rs +++ b/aries_vcx/src/common/anoncreds.rs @@ -25,7 +25,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] async fn test_pool_prover_get_credentials() { - SetupProfile::run_indy(|setup| async move { + SetupProfile::run(|setup| async move { let proof_req = json!({ "nonce":"123432421212", "name":"proof_req_1", diff --git a/aries_vcx/src/common/primitives/mod.rs b/aries_vcx/src/common/primitives/mod.rs index 260542d2c7..4220c19fbd 100644 --- a/aries_vcx/src/common/primitives/mod.rs +++ b/aries_vcx/src/common/primitives/mod.rs @@ -116,7 +116,7 @@ pub mod integration_tests { #[tokio::test] #[ignore] - async fn test_pool_from_pool_ledger_with_id() { + async fn test_pool_create_and_get_schema() { SetupProfile::run(|setup| async move { let (schema_id, _schema_json) = create_and_write_test_schema(&setup.profile, &setup.institution_did, DEFAULT_SCHEMA_ATTRS).await; From e900ca280eb3aae25711140bea94381e3e0e4b01 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Wed, 17 May 2023 12:35:35 +0200 Subject: [PATCH 16/19] Update vdr_reader to use the new IndyVdrLedger API Signed-off-by: Miroslav Kovar --- did_resolver_sov/src/reader/vdr_reader.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/did_resolver_sov/src/reader/vdr_reader.rs b/did_resolver_sov/src/reader/vdr_reader.rs index 0de0c3cf5d..64ac7abeea 100644 --- a/did_resolver_sov/src/reader/vdr_reader.rs +++ b/did_resolver_sov/src/reader/vdr_reader.rs @@ -2,7 +2,10 @@ use std::sync::Arc; use crate::error::DidSovError; use aries_vcx_core::{ - ledger::indy_vdr_ledger::{IndyVdrLedger, IndyVdrLedgerPool, LedgerPoolConfig}, + ledger::{ + indy_vdr_ledger::IndyVdrLedger, + request_submitter::vdr_ledger::{IndyVdrLedgerPool, IndyVdrSubmitter, LedgerPoolConfig}, + }, wallet::{base_wallet::BaseWallet, indy_wallet::IndySdkWallet}, INVALID_WALLET_HANDLE, }; @@ -15,8 +18,8 @@ impl TryFrom for ConcreteAttrReader { fn try_from(pool_config: LedgerPoolConfig) -> Result { let wallet = Arc::new(IndySdkWallet::new(INVALID_WALLET_HANDLE)) as Arc; let ledger_pool = Arc::new(IndyVdrLedgerPool::new(pool_config)?); - Ok(Self { - ledger: Arc::new(IndyVdrLedger::new(Arc::clone(&wallet), ledger_pool)), - }) + let submitter = Arc::new(IndyVdrSubmitter::new(ledger_pool)); + let ledger = Arc::new(IndyVdrLedger::new(Arc::clone(&wallet), submitter)); + Ok(Self { ledger }) } } From 622e8fc484223f3e3ae865ff33bbfa5bcf48b639 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Wed, 17 May 2023 12:40:48 +0200 Subject: [PATCH 17/19] Add coment above forked dependency Signed-off-by: Miroslav Kovar --- aries_vcx_core/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/aries_vcx_core/Cargo.toml b/aries_vcx_core/Cargo.toml index 97373d9d56..9f0eb5bfc5 100644 --- a/aries_vcx_core/Cargo.toml +++ b/aries_vcx_core/Cargo.toml @@ -40,6 +40,7 @@ lazy_static = "1.4.0" derive_builder = "0.12.0" uuid = { version = "1.3.0", default-features = false, features = ["v4"] } tokio = { version = "1.20" } +# TODO: Point to the official repo if / when vdr-proxy-client PR is merged: https://github.com/hyperledger/indy-vdr/pull/184 indy-vdr-proxy-client = { git = "https://github.com/mirgee/indy-vdr.git", rev = "fab0535", optional = true } [dev-dependencies] From b5d936a55643e6422fac8523ebdd3065ab796800 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Wed, 17 May 2023 12:55:50 +0200 Subject: [PATCH 18/19] Hotfix build wit proxy feat. flag and no default features Signed-off-by: Miroslav Kovar --- aries_vcx/Cargo.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aries_vcx/Cargo.toml b/aries_vcx/Cargo.toml index daa558a943..4ac2b0c9d3 100644 --- a/aries_vcx/Cargo.toml +++ b/aries_vcx/Cargo.toml @@ -15,7 +15,9 @@ default = ["vdrtools"] vdrtools = ["aries_vcx_core/vdrtools"] # Feature flag to include the 'modular library' dependencies (vdrtools alternatives; indy-vdr, indy-credx) modular_libs = ["aries_vcx_core/modular_libs"] -vdr_proxy_ledger = ["aries_vcx_core/vdr_proxy_ledger"] +# TODO: Remove using "vdrtools" feature flag for vdr_proxy_ledger once IndyCredxAnonCreds +# is fully implemented +vdr_proxy_ledger = ["aries_vcx_core/vdr_proxy_ledger", "vdrtools"] [dependencies] agency_client = { path = "../agency_client" } From e84da36db37112c525a65a20cf3cbd503c47d97c Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Wed, 17 May 2023 12:56:55 +0200 Subject: [PATCH 19/19] Add extra check to check-aries-vcx-feature-variants Signed-off-by: Miroslav Kovar --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6c90a857d4..88a38a7183 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -175,6 +175,7 @@ jobs: cargo check --no-default-features cargo check --features vdrtools --no-default-features cargo check --features modular_libs --no-default-features + cargo check --features vdr_proxy_ledger --no-default-features ########################################################################################## ############################## DOCKER BUILD ##########################################