Radish alpha
r
rad:z2UcCU1LgMshWvXj6hXSDDrwB8q8M
Radicle Job Collaborative Object
Radicle
Git
docs: add a doc test to library, for documetation
Merged liw opened 11 months ago

Signed-off-by: Lars Wirzenius liw@liw.fi

4 files changed +49 -5 8b8cb494 7cd8b06c
added .radicle/ambient.yaml
@@ -0,0 +1,6 @@
+
pre_plan:
+
  - action: cargo_fetch
+
plan:
+
  - action: cargo_fmt
+
  - action: cargo_clippy
+
  - action: cargo_test
modified Cargo.toml
@@ -5,6 +5,7 @@ license = "MIT OR Apache-2.0"
version = "0.1.0"
authors = ["Fintan Halpenny <fintan.halpenny@gmail.com>"]
edition = "2021"
+
rust-version = "1.82"

[dependencies]
indexmap = { version = "2.7.1", features = ["serde"] }
deleted rust-toolchain.toml
@@ -1,4 +0,0 @@
-
[toolchain]
-
channel = "1.84"
-
profile = "default"
-
components = [ "rust-src" ]
modified src/lib.rs
@@ -1,3 +1,44 @@
+
//! Radicle "job COB".
+
//!
+
//! # Example
+
//!
+
//! ```
+
//! # use radicle::crypto::Signer;
+
//! # use radicle::git::{raw::Repository, Oid};
+
//! # use radicle::test;
+
//! # use url::Url;
+
//! # use uuid::Uuid;
+
//! #
+
//! # use radicle_job::{Jobs, Run, Runs, Reason};
+
//! #
+
//! # fn commit(repo: &Repository) -> Oid {
+
//! #     let tree = {
+
//! #         let tree = repo.treebuilder(None).unwrap();
+
//! #         let oid = tree.write().unwrap();
+
//! #         repo.find_tree(oid).unwrap()
+
//! #     };
+
//! #
+
//! #     let author = repo.signature().unwrap();
+
//! #     repo.commit(None, &author, &author, "Test Commit", &tree, &[])
+
//! #         .unwrap()
+
//! #         .into()
+
//! # }
+
//! #
+
//! # let test::setup::NodeWithRepo {
+
//! #     node: alice, repo, ..
+
//! # } = test::setup::NodeWithRepo::default();
+
//! # let oid = commit(&repo.backend);
+
//! # let repo = (&*repo).clone();
+
//! let mut jobs = Jobs::open(repo).unwrap();
+
//! #
+
//! # let test::setup::NodeWithRepo { node: bob, .. } = test::setup::NodeWithRepo::default();
+
//! let mut job = jobs.create(oid, &alice.signer).unwrap();
+
//! #
+
//! let uuid = Uuid::new_v4();
+
//! let log = Url::parse(&format!("https://example.com/ci/logs?run={}", uuid)).unwrap();
+
//! job.run(uuid, log, &alice.signer).unwrap();
+
//! ```
+

use std::collections::HashMap;
use std::ops::{Deref, DerefMut};
use std::str::FromStr;
@@ -381,7 +422,7 @@ pub struct Run {
}

impl Run {
-
    fn new(log: Url) -> Self {
+
    pub fn new(log: Url) -> Self {
        Self {
            status: Status::Started,
            log,