Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tasks #1386

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open

Tasks #1386

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1b1fc16
WIP tasks
domenkozar Aug 14, 2024
d7ec351
Use async and factor out Nix abstraction into it's own impl
domenkozar Aug 30, 2024
656d895
tests for DependencyFailed
domenkozar Aug 30, 2024
1a286b9
Fix a bunch of errors for tasks
domenkozar Aug 30, 2024
7f23705
tasks: handle stdout/stderr and errors from tasks
domenkozar Aug 30, 2024
e61339a
tasks: fix remaining bugs to happy path
domenkozar Aug 30, 2024
d5710f5
tasks: allow multiple :
domenkozar Sep 2, 2024
e15c289
tasks: improve output
domenkozar Sep 2, 2024
8c271d3
tasks: garden
domenkozar Sep 2, 2024
1b21d99
tasks: reduce locking for TUI to seamlessy update
domenkozar Sep 2, 2024
444868d
tasks: garden
domenkozar Sep 2, 2024
8c6cc53
tasks: convert some of the enterShell into tasks
domenkozar Sep 3, 2024
a127b23
outputs
domenkozar Sep 9, 2024
bddd6fe
tasks: add Skipped reason
domenkozar Sep 12, 2024
169642c
tasks: implement task input/output
domenkozar Sep 12, 2024
147794a
tasks: implement
domenkozar Sep 13, 2024
12d88c1
tasks: implement sourcing of variables for enterShell
domenkozar Sep 13, 2024
4edb3cd
tasks: run as a separate binary
cachix-test-user Sep 17, 2024
9dbde1b
bump mkdocs-rss-plugin
cachix-test-user Sep 17, 2024
7dce134
cnix: fix develop call
cachix-test-user Sep 17, 2024
e0e2491
Auto generate docs/reference/options.md
github-actions[bot] Sep 17, 2024
85cb802
store load-env into DEVENV_DOTFILE
cachix-test-user Sep 17, 2024
22653ab
fix tests
cachix-test-user Sep 17, 2024
b96078f
substituters: pass all options with prepanding instead of recreating cmd
cachix-test-user Sep 18, 2024
7ab79df
devenv-run-test: insert $PATH pointing to the current executable
cachix-test-user Sep 18, 2024
fbeb18c
fix devenv info
cachix-test-user Sep 18, 2024
90679fd
fix mongodb test
cachix-test-user Sep 18, 2024
d0e34ad
fix cachix push and impure
cachix-test-user Sep 18, 2024
cd65c25
tasks: refresh docs
cachix-test-user Sep 19, 2024
d4c579b
move task tests to a test module
sandydoo Sep 19, 2024
e7d6c76
docs: add note about TSP
cachix-test-user Sep 19, 2024
137c48a
fix clippy warnings
sandydoo Sep 19, 2024
6d492ff
devenv: avoid modifying paths post-init
sandydoo Sep 19, 2024
99057e8
devenv: remove unnecessary muts, clones, and arcs
sandydoo Sep 19, 2024
5797e8d
devenv: use simpler RefCell for cachix caches
sandydoo Sep 19, 2024
be6867a
devenv: fix dotfile override for `devenv test`
sandydoo Sep 19, 2024
fde3759
cli: search nixpkgs from devenv.yaml
cachix-test-user Sep 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
434 changes: 384 additions & 50 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
[workspace]
resolver = "2"
members = [
"devenv",
"devenv-run-tests",
"xtask",
]
members = ["devenv", "devenv-run-tests", "xtask", "tasks"]

[workspace.package]
edition = "2021"
Expand All @@ -25,7 +21,12 @@ miette = { version = "7.1.0", features = ["fancy"] }
nix = { version = "0.28.0", features = ["signal"] }
regex = "1.10.3"
reqwest = "0.11.26"
schematic = { version = "0.14.3", features = ["schema", "yaml", "renderer_template", "renderer_json_schema"] }
schematic = { version = "0.14.3", features = [
"schema",
"yaml",
"renderer_template",
"renderer_json_schema",
] }
serde = "1.0.197"
serde_json = "1.0.114"
serde_yaml = "0.9.32"
Expand All @@ -35,5 +36,5 @@ tracing = "0.1.40"
which = "6.0.0"
whoami = "1.5.1"
xdg = "2.5.2"

tokio = "1.39.3"
schemars = "0.8.16"
1 change: 1 addition & 0 deletions devenv-run-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ clap.workspace = true
tempdir.workspace = true

devenv= { path = "../devenv" }
tokio = "1.39.3"
26 changes: 21 additions & 5 deletions devenv-run-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ struct TestResult {
passed: bool,
}

fn run_tests_in_directory(args: &Args) -> Result<Vec<TestResult>, Box<dyn std::error::Error>> {
async fn run_tests_in_directory(
args: &Args,
) -> Result<Vec<TestResult>, Box<dyn std::error::Error>> {
let logger = Logger::new(Level::Info);

logger.info("Running Tests");
Expand Down Expand Up @@ -118,11 +120,13 @@ fn run_tests_in_directory(args: &Args) -> Result<Vec<TestResult>, Box<dyn std::e
// Run .setup.sh if it exists
if setup_script_path.exists() {
println!(" Running {setup_script}");
devenv.shell(&Some(format!("./{setup_script}")), &[], false)?;
devenv
.shell(&Some(format!("./{setup_script}")), &[], false)
.await?;
}

// TODO: wait for processes to shut down before exiting
let status = devenv.test();
let status = devenv.test().await;
let result = TestResult {
name: dir_name.to_string(),
passed: status.is_ok(),
Expand All @@ -135,10 +139,22 @@ fn run_tests_in_directory(args: &Args) -> Result<Vec<TestResult>, Box<dyn std::e
Ok(test_results)
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Args::parse();

let test_results = run_tests_in_directory(&args)?;
let executable_path = std::env::current_exe()?;
let executable_dir = executable_path.parent().unwrap();
std::env::set_var(
"PATH",
format!(
"{}:{}",
executable_dir.display(),
std::env::var("PATH").unwrap_or_default()
),
);

let test_results = run_tests_in_directory(&args).await?;
let num_tests = test_results.len();
let num_failed_tests = test_results.iter().filter(|r| !r.passed).count();

Expand Down
2 changes: 2 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
env.DEVENV_NIX = inputs.nix.packages.${pkgs.stdenv.system}.nix;
# ignore annoying browserlists warning that breaks pre-commit hooks
env.BROWSERSLIST_IGNORE_OLD_DATA = "1";
env.RUST_LOG = "devenv=debug";
env.RUST_LOG_SPAN_EVENTS = "full";

packages = [
pkgs.cairo
Expand Down
11 changes: 11 additions & 0 deletions devenv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ default-run = "devenv"
ansiterm.workspace = true
clap.workspace = true
cli-table.workspace = true
crossterm = "0.28.1"
dotlock.workspace = true
fs2.workspace = true
hex.workspace = true
include_dir.workspace = true
indoc.workspace = true
miette.workspace = true
nix.workspace = true
petgraph = "0.6.5"
pretty_assertions = { version = "1.4.0", features = ["unstable"] }
regex.workspace = true
reqwest.workspace = true
schemars.workspace = true
Expand All @@ -29,6 +32,14 @@ serde_json.workspace = true
serde_yaml.workspace = true
sha2.workspace = true
tempdir.workspace = true
tempfile = "3.12.0"
test-log = { version = "0.2.16", features = ["trace"] }
thiserror = "1.0.63"
tokio = { version = "1.39.3", features = [
"process",
"macros",
"rt-multi-thread",
] }
tracing.workspace = true
which.workspace = true
whoami.workspace = true
Expand Down
6 changes: 6 additions & 0 deletions devenv/init/devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
git --version
'';

# https://devenv.sh/tasks/
# tasks = {
# "myproj:setup".exec = "mytool build";
# "devenv:enterShell".depends = ["myproj:setup"];
# };

# https://devenv.sh/tests/
enterTest = ''
echo "Running tests"
Expand Down
13 changes: 13 additions & 0 deletions devenv/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ pub(crate) enum Commands {
command: ProcessesCommand,
},

#[command(about = "Run tasks. https://devenv.sh/tasks/")]
Tasks {
#[command(subcommand)]
command: TasksCommand,
},

#[command(about = "Run tests. http://devenv.sh/tests/", alias = "ci")]
Test {
#[arg(short, long, help = "Don't override .devenv to a temporary directory.")]
Expand Down Expand Up @@ -241,6 +247,13 @@ pub(crate) enum ProcessesCommand {
// TODO: Status/Attach
}

#[derive(Subcommand, Clone)]
#[clap(about = "Run tasks. https://devenv.sh/tasks/")]
pub(crate) enum TasksCommand {
#[command(about = "Run tasks.")]
Run { tasks: Vec<String> },
}

#[derive(Subcommand, Clone)]
#[clap(
about = "Build, copy, or run a container. https://devenv.sh/containers/",
Expand Down
Loading
Loading