Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: add cargo hack #170

Merged
merged 21 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/hack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Hack

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
hack:

runs-on: ubuntu-latest

steps:
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo
target
key: ${{ matrix.os }}-hack
Boog900 marked this conversation as resolved.
Show resolved Hide resolved

- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: |
sudo apt install -y libboost-dev
cargo install cargo-hack --locked

- name: Hack Check
# TODO: remove the exclude when `cuprate-database` errors are fixed
run: cargo hack --workspace --exclude cuprate-database check --feature-powerset --no-dev-deps
Boog900 marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 8 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ It currently:
- Runs [`clippy`](https://github.com/rust-lang/rust-clippy) (and fails on warnings)
- Runs all tests
- Builds all targets
- Automatically adds approriate [labels](#31-labels) to your PR
- Automatically adds appropriate [labels](#31-labels) to your PR

Before pushing your code, please run the following at the root of the repository:

Expand All @@ -120,12 +120,13 @@ Before pushing your code, please run the following at the root of the repository

After that, ensure all other CI passes by running:

| Command | Does what |
|------------------------------------------------------------------------|-----------|
| `RUSTDOCFLAGS='-D warnings' cargo doc --workspace --all-features` | Checks documentation is OK
| `cargo clippy --workspace --all-features --all-targets -- -D warnings` | Checks clippy lints are satisfied
| `cargo test --all-features --workspace` | Runs all tests
| `cargo build --all-features --all-targets --workspace` | Builds all code
| Command | Does what |
|--------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| `RUSTDOCFLAGS='-D warnings' cargo doc --workspace --all-features` | Checks documentation is OK |
| `cargo clippy --workspace --all-features --all-targets -- -D warnings` | Checks clippy lints are satisfied |
| `cargo test --all-features --workspace` | Runs all tests |
| `cargo build --all-features --all-targets --workspace` | Builds all code |
| `cargo hack --workspace --exclude cuprate-database check --feature-powerset --no-dev-deps` | Uses cargo hack to check our crates build with different features set |

**Note: in order for some tests to work, you will need to place a [`monerod`](https://www.getmonero.org/downloads/) binary at the root of the repository.**
Boog900 marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
2 changes: 1 addition & 1 deletion helper/src/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use crossbeam::atomic::AtomicCell;

#[allow(unused_imports)] // docs
use std::sync::atomic::{Ordering, Ordering::Acquire, Ordering::Release};
use core::sync::atomic::{Ordering, Ordering::Acquire, Ordering::Release};

//---------------------------------------------------------------------------------------------------- Atomic Float
/// Compile-time assertion that our floats are
Expand Down
2 changes: 1 addition & 1 deletion helper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub mod atomic;
#[cfg(feature = "constants")]
pub mod constants;

#[cfg(feature = "fs")]
#[cfg(all(feature = "fs", feature = "std"))]
pub mod fs;

pub mod network;
Expand Down
4 changes: 3 additions & 1 deletion net/epee-encoding/src/container_as_blob.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::{string::ToString, vec, vec::Vec};

use bytes::{Buf, BufMut, Bytes, BytesMut};
use ref_cast::RefCast;

Expand Down Expand Up @@ -70,7 +72,7 @@ pub trait Containerable {
macro_rules! int_container_able {
($int:ty ) => {
impl Containerable for $int {
const SIZE: usize = std::mem::size_of::<$int>();
const SIZE: usize = core::mem::size_of::<$int>();

fn from_bytes(bytes: &[u8]) -> Self {
<$int>::from_le_bytes(bytes.try_into().unwrap())
Expand Down
1 change: 1 addition & 0 deletions net/epee-encoding/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use alloc::string::{String, ToString};
use core::{
fmt::{Debug, Formatter},
num::TryFromIntError,
Expand Down
1 change: 1 addition & 0 deletions net/epee-encoding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

extern crate alloc;

use alloc::string::ToString;
use core::{ops::Deref, str::from_utf8 as str_from_utf8};

use bytes::{Buf, BufMut, Bytes, BytesMut};
Expand Down
2 changes: 1 addition & 1 deletion net/epee-encoding/src/value.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! This module contains a [`EpeeValue`] trait and
//! impls for some possible base epee values.

use alloc::{string::String, vec::Vec};
use alloc::{string::String, vec, vec::Vec};
use core::fmt::Debug;

use bytes::{Buf, BufMut, Bytes, BytesMut};
Expand Down
2 changes: 1 addition & 1 deletion p2p/p2p-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cuprate-helper = { path = "../../helper", features = ["asynch"], default-feature
cuprate-wire = { path = "../../net/wire", features = ["tracing"] }
cuprate-pruning = { path = "../../pruning" }

tokio = { workspace = true, features = ["net", "sync", "macros", "time"]}
tokio = { workspace = true, features = ["net", "sync", "macros", "time", "rt"]}
tokio-util = { workspace = true, features = ["codec"] }
tokio-stream = { workspace = true, features = ["sync"]}
futures = { workspace = true, features = ["std"] }
Expand Down
4 changes: 2 additions & 2 deletions storage/blockchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default = ["heed", "service"]
heed = ["cuprate-database/heed"]
redb = ["cuprate-database/redb"]
redb-memory = ["cuprate-database/redb-memory"]
service = ["dep:crossbeam", "dep:futures", "dep:tokio", "dep:tokio-util", "dep:tower", "dep:rayon"]
service = ["dep:crossbeam", "dep:futures", "dep:tokio", "dep:tokio-util", "dep:tower", "dep:rayon", "dep:thread_local"]

[dependencies]
# FIXME:
Expand All @@ -38,7 +38,7 @@ futures = { workspace = true, optional = true }
tokio = { workspace = true, features = ["full"], optional = true }
tokio-util = { workspace = true, features = ["full"], optional = true }
tower = { workspace = true, features = ["full"], optional = true }
thread_local = { workspace = true }
thread_local = { workspace = true, optional = true }
rayon = { workspace = true, optional = true }

[dev-dependencies]
Expand Down
Loading