Test README on ci.
This commit is contained in:
parent
00707dc45e
commit
8419fe8438
21
.github/workflows/ci.yml
vendored
21
.github/workflows/ci.yml
vendored
@ -14,6 +14,7 @@ jobs:
|
||||
toolchain:
|
||||
- rust: stable
|
||||
#- rust: nightly
|
||||
|
||||
platform:
|
||||
- target: x86_64-unknown-linux-gnu
|
||||
host: ubuntu-latest
|
||||
@ -109,3 +110,23 @@ jobs:
|
||||
|
||||
- name: cargo clippy
|
||||
run: cargo clippy -- -D warnings
|
||||
|
||||
readme-doctest:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Cache cargo folder
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cargo
|
||||
key: readme-doctest
|
||||
|
||||
- name: Install rust toolchain
|
||||
uses: hecrj/setup-rust-action@v1
|
||||
with:
|
||||
rust-version: nightly
|
||||
|
||||
- name: cargo test --features nightly
|
||||
run: cargo test --features nightly
|
||||
|
@ -7,6 +7,7 @@ license = "MIT OR Apache-2.0"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
nightly = []
|
||||
all = ["rocksdb"]
|
||||
|
||||
[dependencies]
|
||||
@ -33,11 +34,11 @@ serde = "1.0.104"
|
||||
serde_derive = "1.0.104"
|
||||
serde_json = "1.0.48"
|
||||
|
||||
[patch.crates-io]
|
||||
ctr = { git = "https://github.com/koivunej/stream-ciphers.git", branch = "ctr128-64to128" }
|
||||
|
||||
[build-dependencies]
|
||||
prost-build = "0.6.1"
|
||||
|
||||
[workspace]
|
||||
members = [ "http" ]
|
||||
|
||||
[patch.crates-io]
|
||||
ctr = { git = "https://github.com/koivunej/stream-ciphers.git", branch = "ctr128-64to128" }
|
||||
|
@ -60,7 +60,7 @@ You will then find the binaries inside of the project root's `/target/debug` fol
|
||||
_Note: binaries available via `cargo install` is coming soon._
|
||||
|
||||
## Getting started
|
||||
```rust,no-run
|
||||
```rust,no_run
|
||||
use async_std::task;
|
||||
use futures::join;
|
||||
use ipfs::{IpfsOptions, Ipld, Types, UninitializedIpfs};
|
||||
|
@ -1,37 +0,0 @@
|
||||
use async_std::task;
|
||||
use futures::join;
|
||||
use ipfs::{IpfsOptions, Ipld, Types, UninitializedIpfs};
|
||||
|
||||
fn main() {
|
||||
let options = IpfsOptions::<Types>::default();
|
||||
env_logger::Builder::new()
|
||||
.parse_filters(&options.ipfs_log)
|
||||
.init();
|
||||
|
||||
task::block_on(async move {
|
||||
// Start daemon and initialize repo
|
||||
let (ipfs, fut) = UninitializedIpfs::new(options).await.start().await.unwrap();
|
||||
task::spawn(fut);
|
||||
|
||||
// Create a DAG
|
||||
let block1: Ipld = "block1".to_string().into();
|
||||
let block2: Ipld = "block2".to_string().into();
|
||||
let f1 = ipfs.put_dag(block1);
|
||||
let f2 = ipfs.put_dag(block2);
|
||||
let (res1, res2) = join!(f1, f2);
|
||||
let root: Ipld = vec![res1.unwrap(), res2.unwrap()].into();
|
||||
let path = ipfs.put_dag(root).await.unwrap();
|
||||
|
||||
// Query the DAG
|
||||
let path1 = path.sub_path("0").unwrap();
|
||||
let path2 = path.sub_path("1").unwrap();
|
||||
let f1 = ipfs.get_dag(path1);
|
||||
let f2 = ipfs.get_dag(path2);
|
||||
let (res1, res2) = join!(f1, f2);
|
||||
println!("Received block with contents: {:?}", res1.unwrap());
|
||||
println!("Received block with contents: {:?}", res2.unwrap());
|
||||
|
||||
// Exit
|
||||
ipfs.exit_daemon();
|
||||
});
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
//! IPFS node implementation
|
||||
//#![deny(missing_docs)]
|
||||
|
||||
#![cfg_attr(feature = "nightly", feature(external_doc))]
|
||||
#![cfg_attr(feature = "nightly", doc(include = "../README.md"))]
|
||||
|
||||
#[macro_use]
|
||||
extern crate failure;
|
||||
#[macro_use]
|
||||
|
Loading…
Reference in New Issue
Block a user