From 49a94c43a2dfe0710fd6ce91992795535b1d57c8 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 8 Apr 2021 15:24:37 +0300 Subject: Add --build-config option to bdep-ci command --- bdep/ci.cli | 19 ++++++++++++++--- bdep/ci.cxx | 36 ++++++++++++++++++++++++++++---- tests/ci.testscript | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 7 deletions(-) diff --git a/bdep/ci.cli b/bdep/ci.cli index a45828c..08d65cc 100644 --- a/bdep/ci.cli +++ b/bdep/ci.cli @@ -57,12 +57,13 @@ namespace bdep Some package manifest values can be overridden as part of the CI request submission using the \cb{--override} and \cb{--overrides-file} options as - well as their \cb{--builds} and \cb{--build-email} shortcuts. This is - primarily useful for specifying alternative build configurations and/or - build notification emails. For example: + well as their \cb{--builds}, \cb{--build-config}, and \cb{--build-email} + shortcuts. This is primarily useful for specifying alternative build + configurations and/or build notification emails. For example: \ $ bdep ci --builds gcc + $ bdep ci --build-config 'linux*-gcc*' \ Note that manifest overrides override the entire value group that they @@ -148,6 +149,18 @@ namespace bdep "Shortcut for \c{\b{--override\ builds:}}." } + strings --build-config + { + "[/]", + "Shortcut for the following options sequence: + + \c{\b{--override\ builds:all}}\n + \c{\b{--override\ build-include:}[/]}\n + \c{\b{--override\ build-exclude:**}} + + Repeat this option to specify multiple build configurations." + } + string --build-email { "", diff --git a/bdep/ci.cxx b/bdep/ci.cxx index 18ebf7f..3b59a30 100644 --- a/bdep/ci.cxx +++ b/bdep/ci.cxx @@ -22,6 +22,7 @@ using namespace butl; namespace bdep { using bpkg::repository_location; + using bpkg::package_manifest; // Note: the git_status() function, that we use, requires git 2.11.0 or // higher. @@ -195,7 +196,7 @@ namespace bdep if (o.overrides_specified ()) try { - if (o.interactive_specified ()) + if (o.interactive_specified () || o.build_config_specified ()) { for (const manifest_name_value& nv: o.overrides ()) { @@ -203,12 +204,13 @@ namespace bdep nv.name == "build-include" || nv.name == "build-exclude") fail << "'" << nv.name << "' override specified together with " - << "--interactive|-i"; + << (o.interactive_specified () + ? "--interactive|-i" + : "--build-config"); } } - bpkg::package_manifest::validate_overrides (o.overrides (), - "" /* name */); + package_manifest::validate_overrides (o.overrides (), "" /* name */); overrides.insert (overrides.end (), o.overrides ().begin (), @@ -219,6 +221,32 @@ namespace bdep fail << "invalid overrides: " << e; } + // Validate the --build-config option values and convert them into build + // manifest value overrides. + // + if (o.build_config_specified ()) + try + { + if (o.interactive_specified ()) + fail << "--build-config specified together with --interactive|-i"; + + override ("builds", "all"); + + for (const string& c: o.build_config ()) + override ("build-include", c); + + override ("build-exclude", "**"); + + // Note that some of the overrides are knowingly valid (builds:all, + // etc), but let's keep it simple and validate all of them. + // + package_manifest::validate_overrides (overrides, "" /* name */); + } + catch (const manifest_parsing& e) + { + fail << "invalid --build-config option value: " << e; + } + // If we are submitting the entire project, then we have two choices: we // can list all the packages in the project or we can only do so for // packages that were initialized in the (specified) configuration(s?). diff --git a/tests/ci.testscript b/tests/ci.testscript index d72d872..d0407b5 100644 --- a/tests/ci.testscript +++ b/tests/ci.testscript @@ -234,6 +234,66 @@ windows = ($cxx.target.class == 'windows') } } + : build-config + : + { + +$clone_root_prj + +$init -C @cfg &prj-cfg/*** + + test.options += --no-progress + + : valid + : + { + $clone_prj; + + $* --build-config 'linux**/x86_64**' --build-config 'freebsd**' 2>>~%EOE% + %CI request is queued.*% + %reference: .+% + EOE + } + + : empty-config + : + { + $clone_prj; + + $* --build-config '/x86_64**' 2>>EOE != 0 + error: invalid --build-config option value: empty build configuration name pattern in '/x86_64**' + EOE + } + + : empty-target + : + { + $clone_prj; + + $* --build-config 'linux**/' 2>>EOE != 0 + error: invalid --build-config option value: empty build target pattern in 'linux**/' + EOE + } + + : overrides + : + { + $clone_prj; + + $* --build-config 'linux_debian_8-gcc_4.9' --builds '&gcc' 2>>EOE != 0 + error: 'builds' override specified together with --build-config + EOE + } + + : interactive + : + { + $clone_prj; + + $* --build-config 'linux**' --interactive 'linux_debian_8-gcc_4.9' 2>>EOE != 0 + error: --build-config specified together with --interactive|-i + EOE + } + } + : interactive : { -- cgit v1.1