Skip to content

Commit

Permalink
chore: update CI and features (#71)
Browse files Browse the repository at this point in the history
This PR updates CI and relaxes features.

When running CI, a mix of nightly and stable toolchains is used. This PR
moves to the stable toolchain for all jobs except formatting, which
requires nightly. It also updates the CI actions to more updated and
supported versions.

It also relaxes feature gating and simplifies dependencies while
retaining `no_std` compatibility.
  • Loading branch information
AaronFeickert authored Oct 10, 2024
1 parent ae44946 commit f115f66
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 160 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
16 changes: 0 additions & 16 deletions .github/workflows/clippy-check.yml

This file was deleted.

24 changes: 8 additions & 16 deletions .github/workflows/deny.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,13 @@ jobs:
name: deny
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: toolchain
uses: actions-rs/toolchain@v1
- name: Checkout
uses: actions/checkout@v4
- name: Install components
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
profile: minimal
- uses: Swatinem/rust-cache@v1
- name: install cargo deny
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-deny
- name: cargo deny check
uses: actions-rs/cargo@v1
with:
command: deny
args: check
- name: Install deny
run: cargo install cargo-deny
- name: Run deny
run: cargo deny check
140 changes: 40 additions & 100 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,117 +7,57 @@ jobs:
name: clippy
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: toolchain
uses: actions-rs/toolchain@v1
- name: Checkout
uses: actions/checkout@v4
- name: Install components
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
profile: minimal
components: rustfmt, clippy
override: true
- uses: Swatinem/rust-cache@v1
- name: cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: install cargo lints
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-lints
- name: cargo lints clippy
uses: actions-rs/cargo@v1
with:
command: lints
args: clippy --all-features
components: clippy, rustfmt
- name: Check formatting
run: cargo +nightly fmt --all -- --check
- name: Install linter
run: cargo install cargo-lints
- name: Run linter
run: cargo +stable lints clippy --all-targets --all-features
build:
name: build
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: toolchain
uses: actions-rs/toolchain@v1
- name: Checkout
uses: actions/checkout@v4
- name: Install components
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
profile: minimal
override: true
- name: toolchain thumbv8m.main-none-eabi
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
target: thumbv8m.main-none-eabi
override: true
- uses: Swatinem/rust-cache@v1
- name: cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features
- name: cargo build std
uses: actions-rs/cargo@v1
with:
command: build
args: --release --no-default-features --features "std"
- name: cargo build std
uses: actions-rs/cargo@v1
with:
command: build
args: --release --no-default-features --features "zero"
- name: cargo build std
uses: actions-rs/cargo@v1
- name: Install components (metal)
uses: dtolnay/rust-toolchain@master
with:
command: build
args: --release --no-default-features --features "serialize"
- name: cargo build no default
uses: actions-rs/cargo@v1
with:
command: build
args: --release --no-default-features
- name: cargo build no default for non std target
uses: actions-rs/cargo@v1
with:
command: build
args: --release --no-default-features --target=thumbv8m.main-none-eabi"
toolchain: stable
targets: thumbv8m.main-none-eabi
- name: Build (release, all features)
run: cargo +stable build --release --all-features
- name: Build (release, std)
run: cargo +stable build --release --no-default-features --features "std"
- name: Build (release, serialize)
run: cargo +stable build --release --no-default-features --features "serialize"
- name: Build (release, borsh)
run: cargo +stable build --release --no-default-features --features "borsh"
- name: Build (release, no features)
run: cargo +stable build --release --no-default-features
- name: Build (release, no features, metal)
run: cargo +stable build --release --no-default-features --target=thumbv8m.main-none-eabi
test:
name: cargo test
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- nightly
steps:
- name: checkout
uses: actions/checkout@v2
- name: toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: test/debug
uses: actions-rs/cargo@v1
- name: Checkout
uses: actions/checkout@v4
- name: Install components
uses: dtolnay/rust-toolchain@master
with:
command: test
args: --all-features
- name: test/release
uses: actions-rs/cargo@v1
with:
command: test
args: --release --all-features
- name: test/debug all features
if: ${{ matrix.rust != 'stable' }}
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
- name: test/release all features
if: ${{ matrix.rust != 'stable' }}
uses: actions-rs/cargo@v1
with:
command: test
args: --release --all-features
toolchain: stable
- name: Test (debug, all features)
run: cargo +stable test --all-features
- name: Test (release, all features)
run: cargo +stable test --release --all-features
29 changes: 14 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,24 @@ version = "0.7.0"
edition = "2018"

[dependencies]
base58-monero = { version = "0.3", default-features = false,optional = true}
base64 = { version = "0.13", default-features = false, optional = true , features = ["alloc"] }
base58-monero = { version = "0.3", default-features = false, optional = true }
base64 = { version = "0.13", default-features = false, optional = true, features = ["alloc"] }
bincode = { version = "1.3", default-features = false, optional = true }
newtype-ops = { version = "0.1", default-features = false , optional = true}
newtype-ops = { version = "0.1", default-features = false, optional = true }
borsh = { version = "1.2", optional = true, features = ["derive"] }
generic-array = "0.14"
serde = { version = "1.0", optional = true, default-features = false , features = ["derive"] }
serde_json = { version = "1.0", default-features = false, optional = true, features = ["std"]}
snafu = {version="0.7", default-features =false}
zeroize = {version="1.3", default-features =false, features = ["zeroize_derive"], optional = true}
subtle = {version= "2.4", default-features =false, optional = true}
generic-array = { version = "0.14", default-features = false }
serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] }
serde_json = { version = "1.0", default-features = false, optional = true, features = ["std"] }
snafu = { version="0.7", default-features = false }
zeroize = { version ="1.3", default-features = false, features = ["alloc", "zeroize_derive"] }
subtle = { version = "2.4", default-features = false }

[dev-dependencies]
rand = "0.8.0"
clap = { version = "3.2", features = ["derive", "env"] }
rand_core = { version = "0.6", default-features = false, features = ["getrandom"] }
clap = { version = "3.2", default-features = false, features = ["derive", "env", "std"] }

[features]
default = ["serialize", "std", "zero"]
std = ["subtle", "base58-monero", "newtype-ops" ]
zero = ["zeroize/alloc"]
default = ["serialize", "std"]
std = ["base58-monero", "newtype-ops"]
serialize = ["serde", "serde_json", "bincode", "base64", "newtype-ops"]
borsh = ["dep:borsh"]
borsh = ["dep:borsh"]
1 change: 0 additions & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[toolchain]
#channel = "nightly-2022-01-17"
channel = "stable"
2 changes: 1 addition & 1 deletion src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<T: ByteArray> Base58 for T {
mod test {
use alloc::vec::Vec;

use rand::{rngs::OsRng, RngCore};
use rand_core::{OsRng, RngCore};

use super::*;

Expand Down
7 changes: 2 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,17 @@ pub mod epoch_time;
pub mod fixed_set;
pub mod hash;
pub mod hex;
#[cfg(feature = "zeroize")]
pub mod hidden;
pub mod locks;
#[cfg(feature = "serde")]
pub mod message_format;
#[cfg(feature = "zeroize")]
pub mod password;
#[cfg(feature = "std")]
pub mod safe_array;
#[cfg(feature = "serde")]
pub mod serde;
pub use self::{
byte_array::{ByteArray, ByteArrayError},
hash::Hashable,
hidden::Hidden,
password::SafePassword,
};
#[cfg(feature = "zeroize")]
pub use self::{hidden::Hidden, password::SafePassword};
8 changes: 3 additions & 5 deletions src/safe_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use core::{
};

use subtle::ConstantTimeEq;
#[cfg(feature = "zeroize")]
use zeroize::Zeroize;

/// Sometimes it is not good that an array be used for a cryptographic key.
Expand All @@ -49,8 +48,8 @@ use zeroize::Zeroize;
///
/// ```edition2018
/// # #[macro_use] extern crate tari_utilities;
/// # use rand::rngs::OsRng;
/// # use rand::RngCore;
/// # use rand_core::OsRng;
/// # use rand_core::RngCore;
/// # use tari_utilities::{hidden_type, hidden::Hidden, safe_array::SafeArray};
/// # use zeroize::Zeroize;
/// # fn main() {
Expand Down Expand Up @@ -102,7 +101,6 @@ impl<T, const N: usize> DerefMut for SafeArray<T, N> {
}
}

#[cfg(feature = "zeroize")]
impl<T, const N: usize> Zeroize for SafeArray<T, N>
where T: Zeroize
{
Expand Down Expand Up @@ -142,7 +140,7 @@ mod tests {

#[test]
fn reference() {
use rand::{rngs::OsRng, RngCore};
use rand_core::{OsRng, RngCore};
use zeroize::Zeroize;

use crate::{hidden::Hidden, hidden_type};
Expand Down

0 comments on commit f115f66

Please sign in to comment.