Code Monkey home page Code Monkey logo

xtaskops's Introduction

xtaskops

github crates.io docs.rs build status

This is a Rust library that has a few goodies for working with the xtask concept.

Dependency

[dependencies]
xtaskops = "0.4.0"

For most recent version see crates.io

Usage

You should have the xtask concept already set up for your project.

Available Tasks

Full workflow tasks for your daily development.

  • bloat_deps Show biggest crates in release build
  • bloat_time Show crate build times
  • dev Run cargo check followed by cargo test for every file change
  • ci Run typical CI tasks in series: fmt, clippy, and tests
  • coverage Run coverage
  • docs Run cargo docs in watch mode
  • install Instal cargo tools
  • powerset Perform a CI build with powerset of features

Here's an example for how to integrate the coverage task with clap:

use xtaskops::tasks;
// assuming you use `clap`
let res = match matches.subcommand() {
    Some(("coverage", sm)) => tasks::coverage(sm.is_present("dev")),
  //..

Quick start

You can include everything from xtask in your project. In your xtask/main.rs:

fn main() -> Result<(), anyhow::Error> {
    xtaskops::tasks::main()
}

Ops

Low level convenience operations, for file system operations, user input and more.

use xtaskops::ops::{remove_dir, create_dir_all, cmd};

remove_dir("target")?;
create_dir_all("target")?;
// cmd! is from the `duct` library
cmd!("cargo", "watch", "-s", "cargo doc --no-deps").run()?;
Ok(())

Running Tasks

Run:

$ cargo xtask coverage

Recommended: alias cargo xtask to x:

# in your zshrc/shell rcfile
alias x="cargo xtask"

Copyright

Copyright (c) 2022 @jondot. See LICENSE for further details.

xtaskops's People

Contributors

jondot avatar owissett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

xtaskops's Issues

Are /* and ../* ignore options useful?

What do ignore "/" and "../" do?

"--ignore",
"../*",
"--ignore",
"/*",

I believe they do nothing in grcov and are superfluous.

Here's how I arrive at that conclusion

I've added some debug logging to grcov and investigated how globset works and AFAICT --ignore "/*" would would ignore files that have an absolute path that begins with a / and --ignore "../*" would ignore any explicitly relative paths that begin with ../.

After looking at the original code in fn rewrite_paths:

    if let Some(p) = &source_dir {
        assert!(p.is_absolute());
    }


    // Traverse source dir and store all paths, reversed.
    let mut file_to_paths: FxHashMap<String, Vec<PathBuf>> = FxHashMap::default();
    if let Some(ref source_dir) = source_dir {
        for entry in WalkDir::new(&source_dir)
            .into_iter()
            .filter_entry(|e| !is_hidden(e) && !is_symbolic_link(e))
        {
            let entry = entry
                .unwrap_or_else(|_| panic!("Failed to open directory '{}'.", source_dir.display()));


            let full_path = entry.path();
            if !full_path.is_file() {
                continue;
            }


            let path = full_path.strip_prefix(&source_dir).unwrap().to_path_buf();
            if to_ignore_globset.is_match(&path) {
                continue;
            }


            let name = entry.file_name().to_str().unwrap().to_string();
            match file_to_paths.entry(name) {
                hash_map::Entry::Occupied(f) => f.into_mut().push(path),
                hash_map::Entry::Vacant(v) => {
                    v.insert(vec![path]);
                }
            };
        }
    }

I added some debug logging to print the full_path and path:

            println!("checking full_path: {:?}", full_path);
            let path = full_path.strip_prefix(&source_dir).unwrap().to_path_buf();
            println!("checking  stripped: {:?}", path);
            if to_ignore_globset.is_match(&path) {
                println!("ignoring     path: {:?}", path);
                continue;
            }

And here is some output where `--ignore "xtask/*" is processed:

checking full_path: "/home/wink/prgs/rust/myrepos/workspace-template-with-xtask/xtask/Cargo.lock"
checking  stripped: "xtask/Cargo.lock"
ignoring     path: "xtask/Cargo.lock"
checking full_path: "/home/wink/prgs/rust/myrepos/workspace-template-with-xtask/xtask/Cargo.toml"
checking  stripped: "xtask/Cargo.toml"
ignoring     path: "xtask/Cargo.toml"
checking full_path: "/home/wink/prgs/rust/myrepos/workspace-template-with-xtask/xtask/src/main.rs"
checking  stripped: "xtask/src/main.rs"
ignoring     path: "xtask/src/main.rs"

As can be seen, full_path always begins with / and path never begins with / or ../ but instead is always
relative to source_dir. To me, that means that "/" and "../" will never match path and are therefore superfluous.

Cargo compiles twice

Cargo compilation repeats twice when I run cargo xtask coverage --dev
As I understand the first time is for running xtask command and the second time is for running tests. Is there a way to compile once?

[Bug]: atty potential unaligned read

What happened?

Hi ๐Ÿ‘‹

xtaskops seems to have a dependency on using clap v3.2.25 which has triggered a dependabot alert https://github.com/sebastienrousseau/shokunin/security/dependabot/8

On windows, atty dereferences a potentially unaligned pointer.

In practice however, the pointer won't be unaligned unless a custom global allocator is used.

In particular, the System allocator on windows uses HeapAlloc, which guarantees a large enough alignment.

[[package]]
name = "clap"
version = "3.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
dependencies = [
 "atty",
 "bitflags 1.3.2",
 "clap_lex 0.2.4",
 "indexmap 1.9.3",
 "strsim",
 "termcolor",
 "textwrap",
]

I believe this has been solved by clap in subsequent versions:

clap-rs/clap#5028

What type of Operating System?

Windows

Steps to produce this issue.

Please refer to my security alert:

https://github.com/sebastienrousseau/shokunin/security/dependabot/8

You can see the details in my [Cargo.lock](https://github.com/sebastienrousseau/shokunin/blob/main/Cargo.lock)

[Bug]: "No such file or directory" confusing error message

What happened?

Running coverage works but not generating the report.

(coverage directory is created at the root, and profraw files are in each subdirectories)

=== running coverage ===

// test here

ok.
=== generating report ===
Error: No such file or directory (os error 2)

What type of Operating System?

Linux

Steps to produce this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.