summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-07-03 16:19:48 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2024-07-03 16:27:23 -0400
commit3e32af6172f6654eb4083552f2b5999594bb95c1 (patch)
treee7e9a67c713ffb92192df178ea5ac9bed579c768 /src/lib.rs
parent9b196227dc807aad9069d02a30bb197036328520 (diff)
ci: per user config filesci-users
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 0ba1232..4847046 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -11,6 +11,9 @@ use anyhow;
pub mod testresult_capnp;
pub mod worker_capnp;
+pub mod users;
+pub use users::Userrc;
+pub use users::RcTestGroup;
pub fn git_get_commit(repo: &git2::Repository, reference: String) -> Result<git2::Commit, git2::Error> {
let r = repo.revparse_single(&reference);
@@ -28,25 +31,11 @@ pub fn git_get_commit(repo: &git2::Repository, reference: String) -> Result<git2
}
#[derive(Deserialize)]
-pub struct KtestrcTestGroup {
- pub max_commits: u64,
- pub priority: u64,
- pub tests: Vec<PathBuf>,
-}
-
-#[derive(Deserialize)]
-pub struct KtestrcBranch {
- pub fetch: String,
- pub tests: Vec<String>,
-}
-
-#[derive(Deserialize)]
pub struct Ktestrc {
pub linux_repo: PathBuf,
pub output_dir: PathBuf,
pub ktest_dir: PathBuf,
- pub test_group: BTreeMap<String, KtestrcTestGroup>,
- pub branch: BTreeMap<String, KtestrcBranch>,
+ pub users_dir: PathBuf,
}
pub fn ktestrc_read() -> anyhow::Result<Ktestrc> {
@@ -56,6 +45,27 @@ pub fn ktestrc_read() -> anyhow::Result<Ktestrc> {
Ok(ktestrc)
}
+pub struct CiConfig {
+ pub ktest: Ktestrc,
+ pub users: BTreeMap<String, Userrc>,
+}
+
+pub fn ciconfig_read() -> anyhow::Result<CiConfig> {
+ let mut rc = CiConfig {
+ ktest: ktestrc_read()?,
+ users: BTreeMap::new(),
+ };
+
+ for i in std::fs::read_dir(&rc.ktest.users_dir)?
+ .filter_map(|x| x.ok())
+ .map(|i| i.path()){
+ rc.users.insert(i.file_stem().unwrap().to_string_lossy().to_string(),
+ users::userrc_read(&i)?);
+ }
+
+ Ok(rc)
+}
+
pub use testresult_capnp::test_result::Status as TestStatus;
impl TestStatus {