Skip to content

Commit

Permalink
Adjust Rust toolchain, clippy, and minor ci changes (#1311)
Browse files Browse the repository at this point in the history
* chore: adjust toolchain, clippy, and ci

Signed-off-by: James Ebert <[email protected]>

* chore: adjust clippy instructions

Signed-off-by: James Ebert <[email protected]>

* chore: adjust justfile, update clippy ci tasks

Signed-off-by: James Ebert <[email protected]>

* chore: remove unstable feature code formatting rules

Signed-off-by: James Ebert <[email protected]>

---------

Signed-off-by: James Ebert <[email protected]>
  • Loading branch information
JamesKEbert authored Dec 11, 2024
1 parent 0e3bed0 commit 62ce000
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 134 deletions.
31 changes: 0 additions & 31 deletions .github/actions/setup-codecov-rust/action.yml

This file was deleted.

57 changes: 16 additions & 41 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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 ##########################################
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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-]+)*))+)?)$'

Expand Down
22 changes: 13 additions & 9 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

# 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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 34 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
```
17 changes: 8 additions & 9 deletions aries/messages/src/msg_fields/protocols/cred_issuance/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
17 changes: 8 additions & 9 deletions aries/messages/src/msg_fields/protocols/cred_issuance/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion aries/wrappers/uniffi-aries-vcx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
4 changes: 0 additions & 4 deletions codecov.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand All @@ -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()),
Expand Down
12 changes: 5 additions & 7 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "1.79"

0 comments on commit 62ce000

Please sign in to comment.