diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-07-10 17:43:08 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-07-10 17:43:08 -0400 |
commit | c636a46621674f46fdfe2c351dca5a56153ceb7b (patch) | |
tree | 308c69bac9129046df969bbd12d3e58b53191938 | |
parent | c2acc1e27580de87a516b7722d8634b4538cf35e (diff) |
update commit summaries when deleting stale lockfiles
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | src/bin/gen-job-list.rs | 14 | ||||
-rw-r--r-- | src/bin/get-test-job.rs | 11 | ||||
-rw-r--r-- | src/lib.rs | 6 |
3 files changed, 25 insertions, 6 deletions
diff --git a/src/bin/gen-job-list.rs b/src/bin/gen-job-list.rs index 02e9ad8..0cc77c4 100644 --- a/src/bin/gen-job-list.rs +++ b/src/bin/gen-job-list.rs @@ -1,12 +1,12 @@ extern crate libc; -use std::collections::BTreeMap; +use std::collections::{BTreeMap, HashSet}; use std::ffi::OsStr; use std::fs::File; use std::io::prelude::*; use std::path::{Path, PathBuf}; use std::process; use std::process::Stdio; -use ci_cgi::{CiConfig, Userrc, RcTestGroup, ciconfig_read, git_get_commit, commitdir_get_results, lockfile_exists}; +use ci_cgi::{CiConfig, Userrc, RcTestGroup, ciconfig_read, git_get_commit, commitdir_get_results, lockfile_exists, commit_update_results_from_fs}; use ci_cgi::TestResultsMap; use file_lock::{FileLock, FileOptions}; use memoize::memoize; @@ -107,6 +107,8 @@ fn branch_test_jobs(rc: &CiConfig, repo: &git2::Repository, return ret; } + let mut commits_updated = HashSet::new(); + for (age, commit) in walk .filter_map(|i| i.ok()) .filter_map(|i| repo.find_commit(i).ok()) @@ -125,7 +127,9 @@ fn branch_test_jobs(rc: &CiConfig, repo: &git2::Repository, let full_subtest_name = subtest_full_name(&test_path, &i); !have_result(&results, &full_subtest_name) && - !lockfile_exists(&rc.ktest, &commit, &full_subtest_name, false) + !lockfile_exists(&rc.ktest, &commit, &full_subtest_name, + false, + &mut commits_updated) }) .map(|i| i.clone()) .collect(); @@ -142,6 +146,10 @@ fn branch_test_jobs(rc: &CiConfig, repo: &git2::Repository, } } + for i in commits_updated.iter() { + commit_update_results_from_fs(&rc.ktest, &i); + } + ret } diff --git a/src/bin/get-test-job.rs b/src/bin/get-test-job.rs index bd766df..89ef0e9 100644 --- a/src/bin/get-test-job.rs +++ b/src/bin/get-test-job.rs @@ -1,4 +1,5 @@ extern crate libc; +use std::collections::HashSet; use std::path::Path; use std::process; use ci_cgi::{Ktestrc, ciconfig_read, lockfile_exists, commit_update_results_from_fs}; @@ -106,12 +107,20 @@ fn subtest_full_name(test_path: &Path, subtest: &String) -> String { } fn create_job_lockfiles(rc: &Ktestrc, mut job: TestJob) -> Option<TestJob> { + let mut commits_updated = HashSet::new(); + job.subtests = job.subtests.iter() .filter(|i| lockfile_exists(rc, &job.commit, - &subtest_full_name(&Path::new(&job.test), &i), true)) + &subtest_full_name(&Path::new(&job.test), &i), + true, + &mut commits_updated)) .map(|i| i.to_string()) .collect(); + for i in commits_updated.iter() { + commit_update_results_from_fs(rc, &i); + } + if !job.subtests.is_empty() { Some(job) } else { None } } @@ -1,4 +1,4 @@ -use std::collections::BTreeMap; +use std::collections::{BTreeMap, HashSet}; use std::fs::{File, OpenOptions, create_dir_all, read_to_string}; use std::io::ErrorKind; use std::io::prelude::*; @@ -361,7 +361,8 @@ pub fn update_lcov(rc: &Ktestrc, commit_id: &String) -> Option<()> { Some(()) } -pub fn lockfile_exists(rc: &Ktestrc, commit: &str, test_name: &str, create: bool) -> bool { +pub fn lockfile_exists(rc: &Ktestrc, commit: &str, test_name: &str, create: bool, + commits_updated: &mut HashSet<String>) -> bool { let lockfile = rc.output_dir.join(commit).join(test_name).join("status"); let timeout = std::time::Duration::from_secs(3600); @@ -380,6 +381,7 @@ pub fn lockfile_exists(rc: &Ktestrc, commit: &str, test_name: &str, create: bool &lockfile, metadata.modified().unwrap(), SystemTime::now(), elapsed); + commits_updated.insert(commit.to_string()); } } |