From 3a005657f3576488f20b664eb01d35ad9fa7b7e9 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 15 Apr 2024 17:21:17 +0300 Subject: Add support for build-bot package manifest value --- libbpkg/manifest.hxx | 94 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 73 insertions(+), 21 deletions(-) (limited to 'libbpkg/manifest.hxx') diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx index 4b0ccc6..feb3b96 100644 --- a/libbpkg/manifest.hxx +++ b/libbpkg/manifest.hxx @@ -1014,13 +1014,21 @@ namespace bpkg }; // Package build configuration. Includes comment and optional overrides for - // target build configuration class expressions/constraints and build - // notification emails. + // target build configuration class expressions/constraints, auxiliaries, + // custom bot public keys, and notification emails. // - class build_package_config + // Note that in the package manifest the build bot keys list contains the + // public keys data (std::string type). However, for other use cases it may + // be convenient to store some other key representations (public key object + // pointers represented as key fingerprints, etc; see brep for such a use + // case). + // + template + class build_package_config_template { public: using email_type = bpkg::email; + using key_type = K; std::string name; @@ -1040,16 +1048,39 @@ namespace bpkg // std::vector auxiliaries; + std::vector bot_keys; + butl::optional email; butl::optional warning_email; butl::optional error_email; - build_package_config () = default; + build_package_config_template () = default; + + build_package_config_template (std::string n, + std::string a, + std::string c, + butl::small_vector bs, + std::vector cs, + std::vector as, + std::vector bks, + butl::optional e, + butl::optional we, + butl::optional ee) + : name (move (n)), + arguments (move (a)), + comment (move (c)), + builds (move (bs)), + constraints (move (cs)), + auxiliaries (move (as)), + bot_keys (move (bks)), + email (move (e)), + warning_email (move (we)), + error_email (move (ee)) {} // Built incrementally. // explicit - build_package_config (std::string n): name (move (n)) {} + build_package_config_template (std::string n): name (move (n)) {} // Return the configuration's build class expressions/constraints if they // override the specified common expressions/constraints and return the @@ -1080,6 +1111,15 @@ namespace bpkg return !auxiliaries.empty () ? auxiliaries : common; } + // Return the configuration's custom bot public keys, if specified, and + // the common ones otherwise. + // + const std::vector& + effective_bot_keys (const std::vector& common) const noexcept + { + return !bot_keys.empty () ? bot_keys : common; + } + // Return the configuration's build notification emails if they override // the specified common build notification emails and return the latter // otherwise (see package_manifest::override() for the override semantics @@ -1106,6 +1146,8 @@ namespace bpkg } }; + using build_package_config = build_package_config_template; + enum class test_dependency_type { tests, @@ -1253,8 +1295,8 @@ namespace bpkg std::vector requirements; butl::small_vector tests; - // Common build classes, constraints, and auxiliaries that apply to all - // configurations unless overridden. + // Common build classes, constraints, auxiliaries, and custom bot public + // keys that apply to all configurations unless overridden. // // Note that all entries in build_auxiliaries must have distinct // environment names (with empty name being one of the possibilities). @@ -1262,6 +1304,7 @@ namespace bpkg butl::small_vector builds; std::vector build_constraints; std::vector build_auxiliaries; + strings build_bot_keys; // Note that the parsing constructor adds the implied (empty) default // configuration at the beginning of the list. Also note that serialize() @@ -1418,20 +1461,22 @@ namespace bpkg // // {build-*email} // {builds, build-{include,exclude}} + // {build-bot} // {*-builds, *-build-{include,exclude}} + // {*-build-bot} // {*-build-config} // {*-build-*email} // // [*-]build-auxiliary[-*] // // Throw manifest_parsing if the configuration specified by the build - // package configuration-specific build constraint, email, or auxiliary - // value override doesn't exists. In contrast, for the build config - // override add a new configuration if it doesn't exist and update the - // arguments of the existing configuration otherwise. In the former case, - // all the potential build constraint, email, and auxiliary overrides for - // such a newly added configuration must follow the respective - // *-build-config override. + // package configuration-specific build constraint, email, auxiliary, or + // custom bot public key value override doesn't exists. In contrast, for + // the build config override add a new configuration if it doesn't exist + // and update the arguments of the existing configuration otherwise. In + // the former case, all the potential build constraint, email, auxiliary, + // and bot key overrides for such a newly added configuration must follow + // the respective *-build-config override. // // Note that the build constraints group values (both common and build // config-specific) are overridden hierarchically so that the @@ -1446,13 +1491,20 @@ namespace bpkg // constraints are reset to `builds: none`. // // Similar to the build constraints groups, the common and build - // config-specific build emails group value overrides are mutually - // exclusive. If the common build emails are overridden, then all the - // build config-specific emails are reset to nullopt. Otherwise, if some - // build config-specific emails are overridden, then for the remaining - // configs the email is reset to the empty value and the warning and error - // emails are reset to nullopt (which effectively disables email - // notifications for such configurations). + // config-specific custom bot key value overrides are mutually + // exclusive. If the common custom bot keys are overridden, then all the + // build config-specific custom bot keys are removed. Otherwise, if some + // build config-specific custom bot keys are overridden, then for the + // remaining configs the custom bot keys are left unchanged. + // + // Similar to the above, the common and build config-specific build emails + // group value overrides are mutually exclusive. If the common build + // emails are overridden, then all the build config-specific emails are + // reset to nullopt. Otherwise, if some build config-specific emails are + // overridden, then for the remaining configs the email is reset to the + // empty value and the warning and error emails are reset to nullopt + // (which effectively disables email notifications for such + // configurations). // // If a non-empty source name is specified, then the specified values are // assumed to also include the line/column information and the possibly -- cgit v1.1