diff --git a/README.md b/README.md index daf7a92..7ea4976 100644 --- a/README.md +++ b/README.md @@ -4,36 +4,7 @@ This is Gregory. Gregory controls repos. Gregory keeps track of updating repos, ## Documentation -Install gregory with `cargo install`: - -```sh -cargo install --git https://github.com/askiiart/gregory -``` - -Gregory's config looks something like this: - -```toml -max-jobs = 4 -max-threads = 10 - -[packages] - - [packages.librewolf] - - dependencies = ["some-librewolf-dependency"] - version_check = ["check-version --whenever-you-feel-like-it-please"] - - [packages.librewolf.compilation] - revision = "2" - threads = 6 - image = "docker.io/library/debian" - commands = ["echo hi", "sleep 2.432", "echo helloooooooooo"] - volumes = ["librewolf"] -``` - -For more details, look at the `./docs/`, and check out the rest of the [example config](./gregory.example.toml). - -Once you've created your config, just run gregory with `gregory run` - that's it! +Go look at [`docs/`](/docs/), and check out the [example config](/gregory.example.toml) ## TODO @@ -44,6 +15,6 @@ Once you've created your config, just run gregory with `gregory run` - that's it - The formatting for the config file (`gregory.toml`) was heavily inspired by Drone's config. - Why the name? - - I was thinking to go with something dark and foreboding, since this is a program to control *everything* about many repos - it's the high command. But I couldn't think of anything and thought just naming it some lame random name instead would be way funnier. Hence, Gregory. + - I was thinking to go with something dark and foreboding, since this is a program to control *everything* about a repo - it's the high command. But I couldn't think of anything and thought just naming it some lame random name instead would be way funnier. Hence, Gregory. - Gregory is a program, so it uses it/its pronouns. It also doesn't mind whether you capitalize its name or not, "gregory" or "Gregory" are fine, you can even shorten it if you want. - It's built for updating package repositories, but can be used to run pretty much anything. This isn't to say support won't be offered unless you're using it for a repo, but development will be focused on updating repos. diff --git a/src/main.rs b/src/main.rs index 2fc0eeb..2b79ee7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,18 +77,8 @@ async fn run(config_path: String) { // runs the jobs (will need to be updated after sorting is added) for (job_id, job) in state.jobs { - println!("Running {job_id}"); let start_time = SystemTime::now(); let job_exit_status = run_job(&state.conf, job_id.clone(), job.clone()); - match job_exit_status.exit_code.clone() { - Some(e) => { - println!(" Job completed, exit code {e}"); - } - None => { - println!(" Job completed, !!! no exit code !!!"); - println!(" This means the process was terminated by a signal, like SIGKILL, which you should probably look into. See also: https://doc.rust-lang.org/std/process/struct.ExitStatus.html#method.code") - } - } sql::log_job( &mut pg_connection, @@ -98,51 +88,9 @@ async fn run(config_path: String) { job_id, job.revision, job_exit_status.job_uuid, - job_exit_status.log_path.clone(), + job_exit_status.log_path, ) .await; - - println!( - " Logged metadata to postgres database; log file at {}", - job_exit_status.log_path - ); - - println!() - } - - // run repo updates - for (job_id, job) in update_repo_jobs { - println!("Running {job_id}"); - let start_time = SystemTime::now(); - let job_exit_status = run_job(&state.conf, job_id.clone(), job.clone()); - match job_exit_status.exit_code.clone() { - Some(e) => { - println!(" Job completed, exit code {e}"); - } - None => { - println!(" Job completed, !!! no exit code !!!"); - println!(" This means the process was terminated by a signal, like SIGKILL, which you should probably look into. See also: https://doc.rust-lang.org/std/process/struct.ExitStatus.html#method.code") - } - } - - sql::log_job( - &mut pg_connection, - start_time, - start_time + job_exit_status.duration, - job_exit_status.exit_code, - job_id, - job.revision, - job_exit_status.job_uuid, - job_exit_status.log_path.clone(), - ) - .await; - - println!( - " Logged metadata to postgres database; log file at {}", - job_exit_status.log_path - ); - - println!() } } @@ -243,7 +191,7 @@ fn run_job(conf: &Config, job_id: String, job: Job) -> JobExitStatus { } /// Turns a job name into the relevant data - (category (i.e. "packaging"), package name (i.e. "librewolf"), name (i.e. "compilation")) -fn job_id_to_metadata(job_id: String) -> (String, String, String) { +fn jod_id_to_metadata(job_id: String) -> (String, String, String) { let data = job_id .split(".") .map(|item| item.to_string()) @@ -358,30 +306,25 @@ impl State { /// /// ```json /// { + /// "packages.some-librewolf-dependency.packaging.fedora": [ + /// "packages.librewolf.compilation", + /// "packages.librewolf.packaging.fedora", + /// ], /// "packages.some-librewolf-dependency.compilation": [ /// "packages.librewolf.compilation", /// "packages.librewolf.packaging.fedora", /// "packages.some-librewolf-dependency.packaging.fedora", /// ], - /// "packages.librewolf.packaging.fedora": [], /// "packages.librewolf.compilation": [ /// "packages.librewolf.packaging.fedora", /// ], - /// "packages.some-librewolf-dependency.packaging.fedora": [ - /// "packages.librewolf.compilation", - /// "packages.librewolf.packaging.fedora", - /// ], /// } /// ``` fn dependency_map(jobs: HashMap, conf: Config) -> HashMap> { let mut dep_map: HashMap> = HashMap::new(); // holds job ids and every job they depend on (recursively) - not just specified dependencies, also packaging depending on compilation for (job_id, _) in jobs.clone() { - dep_map.insert(job_id, Vec::new()); - } - - for (job_id, _) in jobs.clone() { - let (_, package_name, _) = job_id_to_metadata(job_id.clone()); + let (_, package_name, _) = jod_id_to_metadata(job_id.clone()); for dep_name in conf .packages @@ -392,6 +335,9 @@ impl State { { let all_deps = recursive_deps_for_package(dep_name.clone(), conf.clone()); for dep in all_deps { + if !dep_map.contains_key(&dep) { + dep_map.insert(dep.clone(), Vec::new()); + } dep_map.get_mut(&dep).unwrap().push(job_id.clone()); } }