Skip to content

Commit

Permalink
Merge branch 'main' into b5/dockerize
Browse files Browse the repository at this point in the history
  • Loading branch information
b5 authored Nov 14, 2022
2 parents bad9bb0 + 804255c commit 8fb4bf5
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 24 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
release-arch: amd64
env:
RUST_BACKTRACE: full
# Force not building debuginfo to save space on disk.
RUSTFLAGS: "-C debuginfo=0"
RUSTC_WRAPPER: sccache
RUSTV: ${{ matrix.rust }}
SCCACHE_CACHE_SIZE: 2G
Expand Down Expand Up @@ -135,7 +137,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: check
args: --all --bins --tests --examples
args: --workspace --all-features --bins --tests --examples --benches

- name: tests
uses: actions-rs/cargo@v1
Expand All @@ -145,17 +147,17 @@ jobs:
# GHA if this is not present
# https://twitter.com/steipete/status/921066430220652544?lang=en
# https://blog.phusion.nl/2017/10/13/why-ruby-app-servers-break-on-macos-high-sierra-and-what-can-be-done-about-it/
OBJC_DISABLE_INITIALIZE_FORK_SAFETY: YES
OBJC_DISABLE_INITIALIZE_FORK_SAFETY: "YES"
with:
command: test
args: --all -j 4
args: -j 2 --workspace --all-features --examples --benches --bins

- name: clipy
- name: clippy
uses: actions-rs/cargo@v1
if: matrix.os == 'ubuntu-latest' && matrix.rust=='stable'
with:
command: clippy
args: --all --tests --benches --all-targets -- -D warnings
command: clippy
args: --workspace --all-features --tests --benches --examples --bins --all-targets -- -D warnings

- name: build release
uses: actions-rs/cargo@v1
Expand Down Expand Up @@ -257,4 +259,4 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
args: --all -- --check
6 changes: 3 additions & 3 deletions DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ When you push your branch to github and open up a pull request, it will automati
In order to catch linting and testing errors before pushing the code to github, be sure to run:

```shell
$ cargo clippy --workspace --examples --benches --tests
$ cargo test --workspace --examples --benches
$ cargo clippy --workspace --all-features --examples --benches --tests --bins
$ cargo test --workspace --all-features --examples --benches --bins
```

Setting up a [git hook][git-hook] to run these commands can save you many headaches:

```shell
#!/bin/sh
cargo clippy --workspace --examples --tests --benches && cargo test --workspace --examples
cargo clippy --workspace --all-features --examples --benches --tests --bins && cargo test --workspace --all-features --examples --benches --bins
```

## <a name="dependecies"></a> Dependencies
Expand Down
2 changes: 1 addition & 1 deletion iroh-metrics/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ mod tests {
#[cfg(feature = "tokio-console")]
expect.insert(
"tokio_console".to_string(),
Value::new(None, cfg.tokio_console.clone()),
Value::new(None, cfg.tokio_console),
);
let got = cfg.collect().unwrap();
for key in got.keys() {
Expand Down
3 changes: 2 additions & 1 deletion iroh-one/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ iroh-store = {path = "../iroh-store", default-features = false, features = ["rpc
iroh-util = {path = "../iroh-util"}
reqwest = {version = "0.11", features = ["rustls-tls"], default-features = false}
serde = {version = "1.0", features = ["derive"]}
tempfile = { version = "3.3.0", optional = true }
tokio = {version = "1", features = ["macros", "rt-multi-thread", "process"]}
tracing = "0.1.33"

Expand All @@ -41,4 +42,4 @@ rpc-grpc = ["iroh-rpc-types/grpc", "iroh-rpc-client/grpc", "iroh-metrics/rpc-grp
rpc-mem = ["iroh-rpc-types/mem", "iroh-rpc-client/mem"]
# uds-gateway controls whether http over uds is enabled. This is independent of the
# rpc-grpc control endpoint.
uds-gateway = []
uds-gateway = ["tempfile"]
11 changes: 9 additions & 2 deletions iroh-one/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ impl Config {
/// as a single entry point for other system services if feature enabled.
pub fn default_rpc_config() -> RpcClientConfig {
#[cfg(feature = "uds-gateway")]
let path: PathBuf = tempdir::TempDir::new("iroh")
let path: PathBuf = tempfile::Builder::new()
.prefix("iroh")
.tempfile()
.unwrap()
.path()
.join("ipfsd.http");
Expand Down Expand Up @@ -93,7 +95,12 @@ impl Config {
impl Default for Config {
fn default() -> Self {
#[cfg(feature = "uds-gateway")]
let gateway_uds_path: PathBuf = TempDir::new("iroh").unwrap().path().join("ipfsd.http");
let gateway_uds_path: PathBuf = tempfile::Builder::new()
.prefix("iroh")
.tempfile()
.unwrap()
.path()
.join("ipfsd.http");
let rpc_client = Self::default_rpc_config();
let metrics_config = MetricsConfig::default();
let store_config =
Expand Down
10 changes: 6 additions & 4 deletions iroh-one/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ use iroh_rpc_client::Client as RpcClient;
use iroh_rpc_types::Addr;
use iroh_util::lock::ProgramLock;
use iroh_util::{iroh_config_path, make_config};
#[cfg(feature = "uds-gateway")]
use tempdir::TempDir;
use tokio::sync::RwLock;

#[tokio::main(flavor = "multi_thread")]
Expand Down Expand Up @@ -109,14 +107,18 @@ async fn main() -> Result<()> {

#[cfg(feature = "uds-gateway")]
let uds_server_task = {
let mut path = TempDir::new("iroh")?.path().join("ipfsd.http");
let mut path = tempfile::Builder::new()
.prefix("iroh")
.tempdir()?
.path()
.join("ipfsd.http");
if let Some(uds_path) = config.gateway_uds_path {
path = uds_path;
} else {
// Create the parent path when using the default value since it's likely
// it won't exist yet.
if let Some(parent) = path.parent() {
let _ = std::fs::create_dir_all(&parent);
let _ = std::fs::create_dir_all(parent);
}
}

Expand Down
2 changes: 1 addition & 1 deletion iroh-one/src/uds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use hyper::{
server::accept::Accept,
};
use iroh_gateway::{core::State, handlers::get_app_routes};
use iroh_resolver::resolver::ContentLoader;
use iroh_resolver::content_loader::ContentLoader;
use std::path::PathBuf;
use std::{
io,
Expand Down
2 changes: 1 addition & 1 deletion iroh-share/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ libp2p = { version = "0.50", default-features = false, features = ["gossipsub"]
multibase = "0.9.1"
rand = "0.8.5"
serde = { version = "1", features = ["derive"] }
tempfile = "3.3"
tempfile = "3.3.0"
tokio = { version = "1" }
tokio-stream = "0.1.9"
tracing = "0.1.34"
Expand Down
1 change: 1 addition & 0 deletions iroh/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub struct Cli {
enum Commands {
P2p(P2p),
#[clap(about = "Add a file or directory to iroh & make it available on IPFS")]
#[clap(after_help = doc::ADD_LONG_DESCRIPTION )]
Add {
/// The path to a file or directory to be added
path: PathBuf,
Expand Down
7 changes: 3 additions & 4 deletions iroh/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ use iroh_util::lock::{LockError, ProgramLock};

const SERVICE_START_TIMEOUT_SECONDS: u64 = 15;

/// start any of {iroh-gateway,iroh-store,iroh-p2p} that aren't currently
/// running.
/// Start any given services that aren't currently running.
pub async fn start(api: &Api, services: &Vec<String>) -> Result<()> {
let services = match services.is_empty() {
true => HashSet::from(["gateway", "store"]),
Expand Down Expand Up @@ -232,7 +231,7 @@ where
W: Write,
{
w.queue(style::PrintStyledContent(
"Process\t\t\tNumber\tStatus\n".bold(),
"Service\t\t\tNumber\tStatus\n".bold(),
))?;
queue_row(&table.gateway, &mut w)?;
queue_row(&table.p2p, &mut w)?;
Expand Down Expand Up @@ -326,7 +325,7 @@ mod tests {

#[test]
fn status_table_queue() {
let expect = format!("{}gateway\t\t\t1/1\t{}\np2p\t\t\t1/1\t{}\nstore\t\t\t1/1\t{}\tThe service is currently unavailable\n", "Process\t\t\tNumber\tStatus\n".bold(), "Unknown".dark_yellow(), "Serving".green(), "Down".grey());
let expect = format!("{}gateway\t\t\t1/1\t{}\np2p\t\t\t1/1\t{}\nstore\t\t\t1/1\t{}\tThe service is currently unavailable\n", "Service\t\t\tNumber\tStatus\n".bold(), "Unknown".dark_yellow(), "Serving".green(), "Down".grey());
let table = StatusTable::new(
Some(StatusRow::new("gateway", 1, ServiceStatus::Unknown)),
Some(StatusRow::new("p2p", 1, ServiceStatus::Serving)),
Expand Down

0 comments on commit 8fb4bf5

Please sign in to comment.