Compare commits
No commits in common. "522d12929b0a27488eff22ecf1be0013643625bd" and "00703db338a4f729853553fd15bf405b6423d3b4" have entirely different histories.
522d12929b
...
00703db338
2 changed files with 12 additions and 95 deletions
33
README.md
33
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.
|
||||
|
|
74
src/main.rs
74
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<String, Job>, conf: Config) -> HashMap<String, Vec<String>> {
|
||||
let mut dep_map: HashMap<String, Vec<String>> = 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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue