diff --git a/README.md b/README.md index a96d424..d9bd43d 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ dput PROJECT DSC_FILE [--build-info-out BUILD_INFO_FILE=build-info.json] [--message MESSAGE] [--rebuild-if-unchanged] + [--exclude-arch EXCLUDED_ARCH] + [--exclude-repo EXCLUDED_REPO] ``` This will upload the given .dsc file, as well as any files referenced by it, to diff --git a/obo-core/src/actions.rs b/obo-core/src/actions.rs index 13ccb71..e2cedee 100644 --- a/obo-core/src/actions.rs +++ b/obo-core/src/actions.rs @@ -72,6 +72,10 @@ pub struct DputAction { pub rebuild_if_unchanged: bool, #[clap(long, default_value = "")] pub message: String, + #[clap(long)] + pub exclude_arch: Vec, + #[clap(long)] + pub exclude_repo: Vec, } #[derive(Parser, Debug)] @@ -233,6 +237,8 @@ impl Actions { // Getting disabled repos has to happen *after* the upload, // since the new version can change the supported architectures. disabled_repos: DisabledRepos::Keep, + exclude_arch: args.exclude_arch.clone(), + exclude_repo: args.exclude_repo.clone(), }, ) .await?; @@ -264,6 +270,8 @@ impl Actions { disabled_repos: DisabledRepos::Skip { wait_options: Default::default(), }, + exclude_arch: args.exclude_arch, + exclude_repo: args.exclude_repo, }, ) .await? diff --git a/obo-core/src/build_meta.rs b/obo-core/src/build_meta.rs index ba7142b..c55f112 100644 --- a/obo-core/src/build_meta.rs +++ b/obo-core/src/build_meta.rs @@ -57,6 +57,8 @@ pub enum DisabledRepos { pub struct BuildMetaOptions { pub history_retrieval: BuildHistoryRetrieval, pub disabled_repos: DisabledRepos, + pub exclude_arch: Vec, + pub exclude_repo: Vec, } #[instrument(skip(client))] @@ -156,7 +158,17 @@ impl BuildMeta { let mut repos = HashMap::new(); for repo_meta in project_meta.repositories { + if options.exclude_repo.contains(&repo_meta.name) { + debug!(repo = %repo_meta.name, "Excluded by options"); + continue; + } + for arch in repo_meta.arches { + if options.exclude_arch.contains(&arch) { + debug!(repo = %repo_meta.name, %arch, "Excluded by options"); + continue; + } + if let DisabledRepos::Skip { wait_options } = &options.disabled_repos { let status = get_status_when_ready( &client, @@ -343,6 +355,8 @@ mod tests { disabled_repos: DisabledRepos::Skip { wait_options: Default::default() }, + exclude_arch: vec![], + exclude_repo: vec![], } ) .await @@ -359,6 +373,25 @@ mod tests { let arch_2 = assert_some!(build_info.iter().find(|e| e.repo_arch == repo_arch_2)); assert_none!(arch_2.prev_endtime_for_commit); + let meta = assert_ok!( + BuildMeta::get( + client.clone(), + TEST_PROJECT.to_owned(), + TEST_PACKAGE_1.to_owned(), + &BuildMetaOptions { + history_retrieval: BuildHistoryRetrieval::Full, + disabled_repos: DisabledRepos::Skip { + wait_options: Default::default() + }, + exclude_arch: vec![TEST_ARCH_1.to_string()], + exclude_repo: vec![], + } + ) + .await + ); + assert_eq!(meta.repos.len(), 1); + assert!(meta.repos.contains_key(&repo_arch_2)); + let meta = assert_ok!( BuildMeta::get( client.clone(), @@ -369,6 +402,8 @@ mod tests { disabled_repos: DisabledRepos::Skip { wait_options: Default::default() }, + exclude_arch: vec![], + exclude_repo: vec![], } ) .await @@ -416,6 +451,8 @@ mod tests { disabled_repos: DisabledRepos::Skip { wait_options: Default::default() }, + exclude_arch: vec![], + exclude_repo: vec![], } ) .await @@ -450,6 +487,8 @@ mod tests { disabled_repos: DisabledRepos::Skip { wait_options: Default::default() }, + exclude_arch: vec![], + exclude_repo: vec![], } ) .await @@ -485,6 +524,8 @@ mod tests { disabled_repos: DisabledRepos::Skip { wait_options: Default::default() }, + exclude_arch: vec![], + exclude_repo: vec![], } ) .await @@ -499,6 +540,8 @@ mod tests { &BuildMetaOptions { history_retrieval: BuildHistoryRetrieval::Full, disabled_repos: DisabledRepos::Keep, + exclude_arch: vec![], + exclude_repo: vec![], } ) .await @@ -507,6 +550,68 @@ mod tests { assert_ok!(meta.remove_disabled_repos(&Default::default()).await); assert_eq!(meta.repos.len(), 0); + + mock.add_or_update_repository( + TEST_PROJECT, + TEST_REPO.to_owned(), + TEST_ARCH_1.to_owned(), + MockRepositoryCode::Finished, + ); + + mock.add_or_update_repository( + TEST_PROJECT, + TEST_REPO.to_owned(), + TEST_ARCH_2.to_owned(), + MockRepositoryCode::Finished, + ); + + mock.add_or_update_repository( + TEST_PROJECT, + TEST_REPO_EXTRA.to_owned(), + TEST_ARCH_1.to_owned(), + MockRepositoryCode::Finished, + ); + + mock.add_or_update_repository( + TEST_PROJECT, + TEST_REPO_EXTRA.to_owned(), + TEST_ARCH_2.to_owned(), + MockRepositoryCode::Finished, + ); + + let meta = assert_ok!( + BuildMeta::get( + client.clone(), + TEST_PROJECT.to_owned(), + TEST_PACKAGE_1.to_owned(), + &BuildMetaOptions { + history_retrieval: BuildHistoryRetrieval::Full, + disabled_repos: DisabledRepos::Keep, + exclude_arch: vec![], + exclude_repo: vec![], + } + ) + .await + ); + assert_eq!(meta.repos.len(), 4); + + let meta = assert_ok!( + BuildMeta::get( + client.clone(), + TEST_PROJECT.to_owned(), + TEST_PACKAGE_1.to_owned(), + &BuildMetaOptions { + history_retrieval: BuildHistoryRetrieval::Full, + disabled_repos: DisabledRepos::Keep, + exclude_arch: vec![], + exclude_repo: vec![TEST_REPO_EXTRA.to_owned()], + } + ) + .await + ); + assert_eq!(meta.repos.len(), 2); + assert!(meta.repos.contains_key(&repo_arch_1)); + assert!(meta.repos.contains_key(&repo_arch_2)); } #[rstest] @@ -556,7 +661,9 @@ mod tests { history_retrieval: BuildHistoryRetrieval::Full, disabled_repos: DisabledRepos::Skip { wait_options: Default::default() - } + }, + exclude_arch: vec![], + exclude_repo: vec![], } ) .await @@ -611,6 +718,8 @@ mod tests { } else { DisabledRepos::Keep }, + exclude_arch: vec![], + exclude_repo: vec![], } ) .await diff --git a/obo-test-support/src/lib.rs b/obo-test-support/src/lib.rs index 809b3bc..7ef229f 100644 --- a/obo-test-support/src/lib.rs +++ b/obo-test-support/src/lib.rs @@ -8,6 +8,7 @@ pub const TEST_PROJECT: &str = "foo"; pub const TEST_PACKAGE_1: &str = "bar"; pub const TEST_PACKAGE_2: &str = "baz"; pub const TEST_REPO: &str = "repo"; +pub const TEST_REPO_EXTRA: &str = "repo_extra"; pub const TEST_ARCH_1: &str = "aarch64"; pub const TEST_ARCH_2: &str = "x86_64";