Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/monetize

xtask/src/lib.rs

//! monetize's repository tasks, as a library so the tests can drive them.
//!
//! Nothing here is a build dependency of anything: repository tooling is
//! invoked as a tool, never as a dependency. The crate carries zero
//! dependencies for the same reason — see `Cargo.toml`.

pub mod ci;
pub mod drill;
pub mod fast;
pub mod bench;
pub mod browser;
pub mod clippy;
pub mod guests;
pub mod publish;
pub mod release_version;
pub mod score;
pub mod trials;

use std::path::{Path, PathBuf};

/// The workspace root: the parent of `xtask/`.
///
/// Baked in at compile time rather than discovered by walking up from the
/// current directory, so the answer does not depend on where the binary was
/// invoked from.
///
/// # ⚠ A KNOWN TWIN — and this one has a KEEP that already exists
///
/// `nornir mimir analyze semantic-clones` (the type-4 lens: high cosine, LOW
/// structural agreement — independent re-implementations rather than copies)
/// put this in a seven-member cluster across SIX repositories' xtasks:
/// gunnar-ui `workspace_root`, monetize `workspace_root`, monetize-impl `root`,
/// holger `functional_status`'s neighbour, modgunn `repo_root`, znippy
/// `repo_root`. gunnar-ui's and monetize's bodies are BYTE-IDENTICAL;
/// monetize-impl's differs only in `unwrap_or` where these two `expect`.
///
/// And the keep is not hypothetical: **`nornir_xtask_support::workspace_root_of`
/// in edda is this exact function**, already published, already documenting the
/// same `<root>/xtask` climb and the same "the caller supplies
/// `env!("CARGO_MANIFEST_DIR")` because the leaf cannot read the caller's" —
/// and it is used by facett's and sl-verify's xtasks today.
///
/// It is not used HERE because `xtask/Cargo.toml` declares ZERO dependencies
/// deliberately: a workspace member takes part in resolver-2 feature
/// unification, so a dependency here could turn a feature on in a crate the
/// product links. That rule is the whole reason six xtasks re-wrote a
/// three-line function that one crate already holds, and it is worth writing
/// down as the cost it is rather than rediscovering it a seventh time.
pub fn workspace_root() -> PathBuf {
    Path::new(env!("CARGO_MANIFEST_DIR"))
        .parent()
        .expect("xtask/ has a parent")
        .to_path_buf()
}