Skip to content

Commit

Permalink
Update CI runner
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Oct 22, 2023
1 parent b1547c9 commit d7100c4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-features --all-targets -- -D warnings
- run: cargo clippy --no-default-features --all-targets --features benchmarking -- -D warnings
- run: cargo clippy --no-default-features --all-targets -- -D warnings

min_versions:
name: check minimum rustc version
Expand All @@ -37,9 +37,9 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@1.65
- uses: Swatinem/rust-cache@v2
# check only zspell; we can use later for the CLI
- run: cargo check -p zspell --all-features
- run: cargo check -p zspell --no-default-features --features benchmarking
# check only the library; we can use later for the CLI
- run: cargo check -p rcrypto --all-features
- run: cargo check -p rcrypto --no-default-features

test:
strategy:
Expand Down Expand Up @@ -70,6 +70,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}
- run: cargo build # tests need prebuild so
- run: cargo llvm-cov nextest --lcov --output-path lcov.info
- run: cargo test --doc
- name: Upload coverage data to codecov
Expand Down
32 changes: 32 additions & 0 deletions rcrypto-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,35 @@ pub mod aeads;
pub mod b64;
pub mod kdf;
pub mod zeroize;

/// Version in form `0x00MMmmpp` where `MM` is major, `mm` is minor, and `pp` is patch
#[no_mangle]
pub static RC_VERSION: u32 = make_version();

const fn make_version() -> u32 {
/// Quick const string parser, since the builtins aren't const
const fn const_atoi(s: &str) -> u32 {
let mut i = s.len();
let mut tmp = 0;
loop {
i -= 1;
// ascii offset and scale
tmp += ((s.as_bytes()[i] - 48) as u32) * (10u32.pow(i as u32));

if i == 0 {
break;
}
}
tmp
}

let major = const_atoi(env!("CARGO_PKG_VERSION_MAJOR"));
let minor = const_atoi(env!("CARGO_PKG_VERSION_MINOR"));
let patch = const_atoi(env!("CARGO_PKG_VERSION_PATCH"));

assert!(major < 0xff);
assert!(minor < 0xff);
assert!(patch < 0xff);

(major << 4) | (minor << 2) | patch
}
2 changes: 2 additions & 0 deletions rcrypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ typedef enum RcPwhashresult {
extern "C" {
#endif // __cplusplus

extern const uint32_t RC_VERSION;

/**
* Generate a nonce suitible for use with the
*AES128-GCM
Expand Down

0 comments on commit d7100c4

Please sign in to comment.