From 62ce00088ca1408ed2fabae0a1602902a9a0ed8b Mon Sep 17 00:00:00 2001 From: James Ebert Date: Tue, 10 Dec 2024 23:41:53 -0800 Subject: [PATCH] Adjust Rust toolchain, clippy, and minor ci changes (#1311) * chore: adjust toolchain, clippy, and ci Signed-off-by: James Ebert * chore: adjust clippy instructions Signed-off-by: James Ebert * chore: adjust justfile, update clippy ci tasks Signed-off-by: James Ebert * chore: remove unstable feature code formatting rules Signed-off-by: James Ebert --------- Signed-off-by: James Ebert --- .github/actions/setup-codecov-rust/action.yml | 31 ---------- .github/workflows/main.yml | 57 ++++++------------- .rustfmt.toml | 22 ++++--- Cargo.toml | 1 + README.md | 49 +++++++++++----- .../protocols/cred_issuance/v1/mod.rs | 17 +++--- .../protocols/cred_issuance/v2/mod.rs | 17 +++--- aries/wrappers/uniffi-aries-vcx/README.md | 2 +- codecov.yml | 4 -- .../src/peer_did/numalgos/numalgo2/helpers.rs | 14 ++--- justfile | 12 ++-- rust-toolchain.toml | 2 + 12 files changed, 94 insertions(+), 134 deletions(-) delete mode 100644 .github/actions/setup-codecov-rust/action.yml delete mode 100644 codecov.yml create mode 100644 rust-toolchain.toml diff --git a/.github/actions/setup-codecov-rust/action.yml b/.github/actions/setup-codecov-rust/action.yml deleted file mode 100644 index a4c4620230..0000000000 --- a/.github/actions/setup-codecov-rust/action.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: "setup-codecov-rust" -description: 'Setup host environment for measuring rust code coverage' - -inputs: - skip-docker-setup: - description: 'If true, skip spinning up docker containers' - required: false - default: false - -runs: - using: "composite" - steps: - - name: Install nightly 1.72 - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly-2023-08-24 - override: true - - uses: Swatinem/rust-cache@v2 - - name: "Install dependencies" - shell: bash - run: | - sudo apt-get update -y - sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev - cargo install grcov --version 0.8.9 - - name: "Setup environment" - if: ${{ inputs.skip-docker-setup != 'true' }} - shell: bash - run: | - docker run --rm -d --name mysql --network host -e MYSQL_ROOT_PASSWORD=mysecretpassword mysql:5.7.35 - docker run --rm -d --name indypool --network host ${{ env.DOCKER_IMAGE_POOL }} - sleep 5 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 276634dd93..339ae53cbe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ env: DOCKER_REPO_LOCAL_VDRPROXY: vdrproxy DOCKER_REPO_LOCAL_AATH: aath-backchannel - RUST_TOOLCHAIN_VERSION: 1.79.0 + RUST_TOOLCHAIN_VERSION: 1.79 NODE_VERSION: 18.x jobs: @@ -29,7 +29,7 @@ jobs: uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: - toolchain: nightly-2023-05-08 + toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} components: rustfmt override: true - name: "Install just" @@ -97,11 +97,8 @@ jobs: echo "DOCKER_IMG_CACHED_VDRPROXY ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_VDRPROXY }}" echo "DOCKER_IMG_CACHED_AATH ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_AATH }}" - workspace_clippy: + clippy: runs-on: ubuntu-20.04 - strategy: - matrix: - wallet: ["askar_wallet"] steps: - name: "Git checkout" uses: actions/checkout@v3 @@ -117,29 +114,7 @@ jobs: sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev sudo snap install --edge --classic just - name: "Verify clippy across the entire workspace" - run: just clippy-workspace ${{ matrix.wallet }} - - aries_vcx_clippy: - runs-on: ubuntu-20.04 - strategy: - matrix: - backend: ["anoncreds,askar_wallet", "vdr_proxy_ledger,askar_wallet"] - steps: - - name: "Git checkout" - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} - default: true - components: clippy - - name: "Install dependencies" - shell: bash - run: | - sudo apt-get update -y - sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev - sudo snap install --edge --classic just - - name: "Verify clippy across the entire workspace with default features" - run: just clippy-aries-vcx ${{ matrix.backend }} + run: just clippy ########################################################################################## ############################## DOCKER BUILD ########################################## @@ -150,7 +125,7 @@ jobs: permissions: contents: read packages: write - needs: [ workflow-setup ] + needs: [workflow-setup] if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} env: DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_VDRPROXY }} @@ -183,7 +158,7 @@ jobs: permissions: contents: read packages: write - needs: [ workflow-setup ] + needs: [workflow-setup] if: ${{ needs.workflow-setup.outputs.IS_MAIN_BRANCH == 'true' }} env: DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_AATH }} @@ -218,7 +193,7 @@ jobs: permissions: contents: read packages: write - needs: [ workflow-setup, build-docker-vdrproxy ] + needs: [workflow-setup, build-docker-vdrproxy] if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }} env: DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_VDRPROXY }} @@ -249,7 +224,7 @@ jobs: permissions: contents: read packages: write - needs: [ workflow-setup, build-docker-aath-backchannel ] + needs: [workflow-setup, build-docker-aath-backchannel] if: ${{ needs.workflow-setup.outputs.RELEASE == 'true' || needs.workflow-setup.outputs.PRERELEASE == 'true' }} env: DOCKER_IMG_CACHED: ${{ needs.workflow-setup.outputs.DOCKER_IMG_CACHED_AATH }} @@ -391,14 +366,14 @@ jobs: 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' + 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-]+)*))+)?)$' diff --git a/.rustfmt.toml b/.rustfmt.toml index 7227a01f05..e8d3747f08 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -3,12 +3,16 @@ # "rust-analyzer.rustfmt.extraArgs": [ # "+nightly" # ], -unstable_features = true -group_imports = "StdExternalCrate" -imports_granularity = "Crate" -format_code_in_doc_comments = true -format_macro_bodies = true -format_macro_matchers = true -format_strings = true -comment_width = 100 -wrap_comments = true \ No newline at end of file + +# The following have been commented out as we are no longer targeting nightly, +# therefore these are no longer accessible: +# +# unstable_features = true +# group_imports = "StdExternalCrate" +# imports_granularity = "Crate" +# format_code_in_doc_comments = true +# format_macro_bodies = true +# format_macro_matchers = true +# format_strings = true +# comment_width = 100 +# wrap_comments = true diff --git a/Cargo.toml b/Cargo.toml index 5a604c6592..42b60279c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,7 @@ authors = [ description = "Library to work with Aries protocols & collection of supporting components" license = "Apache-2.0" edition = "2021" +rust-version = "1.79" [profile.release] debug = 0 diff --git a/README.md b/README.md index bf22237b99..cbaa08604d 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,13 @@ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Join the chat at https://chat.hyperledger.org/channel/aries](https://img.shields.io/badge/Chat%20on-Hyperledger%20Chat-blue)](https://chat.hyperledger.org/channel/aries) -The repository contains Rust crates to build +The repository contains Rust crates to build + - [Aries](https://github.com/hyperledger/aries-rfcs/) based applications (mobile, server, anything, ...), - [DIDComm](https://didcomm.org/) related components. ## Aries implementation + - [`aries_vcx`](aries/aries_vcx) - Library implementing DIDComm protocols, with focus on verifiable credential issuance and verification. - [`messages`](aries/messages) - Library for building and parsing Aries (DIDComm v1) messages. - [`aries_vcx_anoncreds`](aries/aries_vcx_anoncreds) - Interfaces for interaction with credentials. @@ -17,28 +19,45 @@ The repository contains Rust crates to build - [`agents`](aries/agents) - Aries agents built on top of `aries_vcx`. ## Did document implementation - - [`did_doc`](did_core/did_doc) - Building and parsing [DID Documents](https://w3c.github.io/did-core/) + +- [`did_doc`](did_core/did_doc) - Building and parsing [DID Documents](https://w3c.github.io/did-core/) ## Did methods implementation - - [`did_parser`](did_core/did_parser_nom) - Building and parsing [DIDs](https://w3c.github.io/did-core/) - - [`did_peer`](did_core/did_methods/did_peer) - https://identity.foundation/peer-did-method-spec/ - - [`did_sov`](did_core/did_methods/did_resolver_sov) - https://sovrin-foundation.github.io/sovrin/spec/did-method-spec-template.html - - [`did_cheqd`](did_core/did_methods/did_cheqd) - https://docs.cheqd.io/product/architecture/adr-list/adr-001-cheqd-did-method - - [`did_web`](did_core/did_methods/did_resolver_web) - https://w3c-ccg.github.io/did-method-web/ - - [`did_key`](did_core/did_methods/did_key) - https://w3c-ccg.github.io/did-method-key/ - - [`did_jwk`](did_core/did_methods/did_jwk) - https://github.com/quartzjer/did-jwk/blob/main/spec.md + +- [`did_parser`](did_core/did_parser_nom) - Building and parsing [DIDs](https://w3c.github.io/did-core/) +- [`did_peer`](did_core/did_methods/did_peer) - https://identity.foundation/peer-did-method-spec/ +- [`did_sov`](did_core/did_methods/did_resolver_sov) - https://sovrin-foundation.github.io/sovrin/spec/did-method-spec-template.html +- [`did_cheqd`](did_core/did_methods/did_cheqd) - https://docs.cheqd.io/product/architecture/adr-list/adr-001-cheqd-did-method +- [`did_web`](did_core/did_methods/did_resolver_web) - https://w3c-ccg.github.io/did-method-web/ +- [`did_key`](did_core/did_methods/did_key) - https://w3c-ccg.github.io/did-method-key/ +- [`did_jwk`](did_core/did_methods/did_jwk) - https://github.com/quartzjer/did-jwk/blob/main/spec.md # Contact + Do you have a question ❓Are you considering using our components? πŸš€ We'll be excited to hear from you. πŸ‘‹ There's 2 best way to reach us: + - Leave us message on `aries-vcx` [discord](https://discord.com/channels/905194001349627914/955480822675308604) channel. - Join our Zoom community calls. Biweekly Tuesdays @ 11:00 pm UTC via Zoom, find more details on [wiki](https://wiki.hyperledger.org/display/ARIES/Community+calls) ## Versioning & releases - - Crates are not yet published on crates.io. You can consume crates as github-type Cargo dependency. - - All releases have currently major version `0` - - We bump minor version on releases containing new features, significant refactors or breaking changes. - - We bump patch version if release only contains fixes or smaller refactoring. - - See [releases](https://github.com/hyperledger/aries-vcx/releases) page. - - Crates are known to be stable with atleast Rust version 1.79 + +- Crates are not yet published on crates.io. You can consume crates as github-type Cargo dependency. +- All releases have currently major version `0` + - We bump minor version on releases containing new features, significant refactors or breaking changes. + - We bump patch version if release only contains fixes or smaller refactoring. +- See [releases](https://github.com/hyperledger/aries-vcx/releases) page. +- Crates are known to be stable with atleast Rust version 1.79 + +# Contributions + +Contributions are very welcome! If you have questions or issues, please let us know on [Discord](https://chat.hyperledger.org/channel/aries) or at our [bi-weekly community call](https://wiki.hyperledger.org/display/ARIES/Community+calls). + +For contributions, please run `clippy` and format prior to creating a PR. This can be done via `just`: + +``` +cargo install just +just clippy +just fmt +``` diff --git a/aries/messages/src/msg_fields/protocols/cred_issuance/v1/mod.rs b/aries/messages/src/msg_fields/protocols/cred_issuance/v1/mod.rs index 95b75f4194..feb1b0df59 100644 --- a/aries/messages/src/msg_fields/protocols/cred_issuance/v1/mod.rs +++ b/aries/messages/src/msg_fields/protocols/cred_issuance/v1/mod.rs @@ -63,16 +63,15 @@ impl DelayedSerde for CredentialIssuanceV1 { D: Deserializer<'de>, { let (protocol, kind_str) = msg_type; - let kind = match protocol { - CredentialIssuanceKind::V1(CredentialIssuanceTypeV1::V1_0(kind)) => { - kind.kind_from_str(kind_str) - } - CredentialIssuanceKind::V2(_) => { - return Err(D::Error::custom( + let kind = + match protocol { + CredentialIssuanceKind::V1(CredentialIssuanceTypeV1::V1_0(kind)) => { + kind.kind_from_str(kind_str) + } + CredentialIssuanceKind::V2(_) => return Err(D::Error::custom( "Cannot deserialize issue-credential-v2 message type into issue-credential-v1", - )) - } - }; + )), + }; match kind.map_err(D::Error::custom)? { CredentialIssuanceTypeV1_0::OfferCredential => { diff --git a/aries/messages/src/msg_fields/protocols/cred_issuance/v2/mod.rs b/aries/messages/src/msg_fields/protocols/cred_issuance/v2/mod.rs index 200ff03b91..2253562b76 100644 --- a/aries/messages/src/msg_fields/protocols/cred_issuance/v2/mod.rs +++ b/aries/messages/src/msg_fields/protocols/cred_issuance/v2/mod.rs @@ -62,16 +62,15 @@ impl DelayedSerde for CredentialIssuanceV2 { D: Deserializer<'de>, { let (protocol, kind_str) = msg_type; - let kind = match protocol { - CredentialIssuanceKind::V2(CredentialIssuanceTypeV2::V2_0(kind)) => { - kind.kind_from_str(kind_str) - } - CredentialIssuanceKind::V1(_) => { - return Err(D::Error::custom( + let kind = + match protocol { + CredentialIssuanceKind::V2(CredentialIssuanceTypeV2::V2_0(kind)) => { + kind.kind_from_str(kind_str) + } + CredentialIssuanceKind::V1(_) => return Err(D::Error::custom( "Cannot deserialize issue-credential-v1 message type into issue-credential-v2", - )) - } - }; + )), + }; match kind.map_err(D::Error::custom)? { CredentialIssuanceTypeV2_0::OfferCredential => { diff --git a/aries/wrappers/uniffi-aries-vcx/README.md b/aries/wrappers/uniffi-aries-vcx/README.md index 22c06d00bd..d85d469228 100644 --- a/aries/wrappers/uniffi-aries-vcx/README.md +++ b/aries/wrappers/uniffi-aries-vcx/README.md @@ -38,7 +38,7 @@ eg. for Android ARM64 on host linux platform. rustup target add aarch64-linux-android ``` -More documentation can be found [here](https://rust-lang.github.io/rustup/cross-compilation.html). Information on supported platforms can be found [here](https://doc.rust-lang.org/nightly/rustc/platform-support.html). +More documentation can be found [here](https://rust-lang.github.io/rustup/cross-compilation.html). Information on supported platforms can be found [here](https://doc.rust-lang.org/stable/rustc/platform-support.html). 3. `cargo-ndk` requires Android NDK to be set up on the host machine. The recommended way of doing this is using Android Studio as described [here](https://developer.android.com/studio/projects/install-ndk#default-version). diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index f158160d61..0000000000 --- a/codecov.yml +++ /dev/null @@ -1,4 +0,0 @@ -fixes: - - "/home/indy/aries-vcx/::aries-vcx/" -ignore: - - "libvcx" diff --git a/did_core/did_methods/did_peer/src/peer_did/numalgos/numalgo2/helpers.rs b/did_core/did_methods/did_peer/src/peer_did/numalgos/numalgo2/helpers.rs index 1e19b3b089..b6a47a6eed 100644 --- a/did_core/did_methods/did_peer/src/peer_did/numalgos/numalgo2/helpers.rs +++ b/did_core/did_methods/did_peer/src/peer_did/numalgos/numalgo2/helpers.rs @@ -144,11 +144,10 @@ mod tests { #[test] fn test_process_elements_with_multiple_elements() { - let did: Did = - "did:peer:2.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.\ + let did: Did = "did:peer:2.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.\ SeyJpZCI6IiNzZXJ2aWNlLTAiLCJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCJ9" - .parse() - .unwrap(); + .parse() + .unwrap(); let did_doc = diddoc_from_peerdid2_elements( DidDocument::new(did.clone()), @@ -164,12 +163,11 @@ mod tests { #[test] fn test_process_elements_error_on_invalid_element() { - let did: Did = - "did:peer:2.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.\ + let did: Did = "did:peer:2.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.\ SeyJpZCI6IiNzZXJ2aWNlLTAiLCJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCJ9.\ Xinvalid" - .parse() - .unwrap(); + .parse() + .unwrap(); match diddoc_from_peerdid2_elements( DidDocument::new(did.clone()), diff --git a/justfile b/justfile index 609f68a7b5..c8894595e3 100644 --- a/justfile +++ b/justfile @@ -2,17 +2,15 @@ default: just --list fmt: - cargo +nightly-2023-05-08 fmt + cargo fmt fmt-check: - cargo +nightly-2023-05-08 fmt --check + cargo fmt --check -clippy-workspace wallet: - cargo clippy --examples --tests --no-default-features -F anoncreds,vdr_proxy_ledger,legacy_proof,{{wallet}} - -clippy-aries-vcx features: - cargo clippy -p aries_vcx --features legacy_proof --features {{features}} --no-default-features +clippy: + cargo clippy --examples --tests --all-features +# The following need review: check-workspace: cargo check --tests --all-features diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000000..c6e4d7d503 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.79"