From 987793088141ebffef885be349e260672bbc40c3 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 19 Apr 2024 20:58:08 +0300 Subject: Add support for build-bot manifest value overrides in bdep-ci --- bdep/ci.cli | 41 +++++++----- bdep/ci.cxx | 69 ++++++++++++++------ tests/ci.testscript | 183 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 258 insertions(+), 35 deletions(-) diff --git a/bdep/ci.cli b/bdep/ci.cli index 77d29cd..65ae252 100644 --- a/bdep/ci.cli +++ b/bdep/ci.cli @@ -90,21 +90,24 @@ namespace bdep \ build-email build-{warning,error}-email builds build-{include,exclude} + build-bot *-builds *-build-{include,exclude} + *-build-bot *-build-config *-build-email *-build-{warning,error}-email [*-]build-auxiliary[-*] \ - For the package configuration-specific build constraint, email, and - auxiliary overrides, the corresponding configuration must exist in the - package manifest. In contrast, the package configuration override - (\cb{*-build-config}) adds a new configuration if it doesn't exist and - updates 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 - corresponding \cb{*-build-config} override. + For the package configuration-specific build constraint, email, + auxiliary, and custom bot public key overrides, the corresponding + configuration must exist in the package manifest. In contrast, the + package configuration override (\cb{*-build-config}) adds a new + configuration if it doesn't exist and updates the arguments of the + existing configuration otherwise. In the former case, all the potential + build constraint, email, auxiliary, and custom bot public key overrides + for such a newly added configuration must follow the corresponding + \cb{*-build-config} override. Note that the build constraints group values (both common and build package configuration-specific) are overridden hierarchically so that the @@ -119,13 +122,21 @@ namespace bdep build constraints are reset to \cb{builds:\ none}. Similar to the build constraints groups, the common and build package - configuration-specific build emails group value overrides are mutually - exclusive. If the common build emails are overridden, then all the - configuration-specific emails are removed. Otherwise, if any - configuration-specific emails are overridden, then for the remaining - configurations the build emails are reset to the empty values and the - build warning and error emails are removed (which effectively disables - email notifications for such configurations). + configuration-specific custom bot public key value overrides are mutually + exclusive. If the common build custom bot public keys are overridden, + then all the configuration-specific custom bot public keys are removed. + Otherwise, if any configuration-specific custom bot public keys are + overridden, then for the remaining configurations the custom bot public + keys are left unchanged. + + Similar to the above, the common and build package configuration-specific + build emails group value overrides are mutually exclusive. If the common + build emails are overridden, then all the configuration-specific emails + are removed. Otherwise, if any configuration-specific emails are + overridden, then for the remaining configurations the build emails are + reset to the empty values and the build warning and error emails are + removed (which effectively disables email notifications for such + configurations). If supported by the CI service, a package can be tested interactively in a specific build configuration using the \c{\b{--interactive}|\b{-i}} diff --git a/bdep/ci.cxx b/bdep/ci.cxx index f97f0cb..cca2234 100644 --- a/bdep/ci.cxx +++ b/bdep/ci.cxx @@ -240,20 +240,21 @@ namespace bdep { const string& n (nv.name); - // True if the name is one of {*-builds, *-build-{include,exclude}}. + // True if the name is one of {*-builds, *-build-{include,exclude}} + // and update the pkg_config_ovr flag accordingly if that's the case. // - bool pco ((n.size () > 7 && + bool cbo ((n.size () > 7 && n.compare (n.size () - 7, 7, "-builds") == 0) || (n.size () > 14 && n.compare (n.size () - 14, 14, "-build-include") == 0) || (n.size () > 14 && n.compare (n.size () - 14, 14, "-build-exclude") == 0)); - if (pco) + if (cbo) pkg_config_ovr = true; if (co != nullptr && - (pco || + (cbo || n == "builds" || n == "build-include" || n == "build-exclude")) @@ -264,21 +265,34 @@ namespace bdep info << "override: " << n << ": " << nv.value; } - bool eo ( - (n == "build-email" || - n == "build-warning-email" || - n == "build-error-email" || - (n.size () > 12 && - n.compare (n.size () - 12, 12, "-build-email") == 0) || - (n.size () > 20 && - n.compare (n.size () - 20, 20, "-build-warning-email") == 0) || - (n.size () > 18 && - n.compare (n.size () - 18, 18, "-build-error-email") == 0))); - - if (eo) - build_email_ovr = true; - - if (!pco && !eo) + // Check if the name is one of {[*-]build-*email} and update the + // pkg_config_ovr and build_email_ovr flags accordingly if that's the + // case. + // + if (!cbo) + { + bool ceo ( + (n.size () > 12 && + n.compare (n.size () - 12, 12, "-build-email") == 0) || + (n.size () > 20 && + n.compare (n.size () - 20, 20, "-build-warning-email") == 0) || + (n.size () > 18 && + n.compare (n.size () - 18, 18, "-build-error-email") == 0)); + + if (ceo) + pkg_config_ovr = true; + + build_email_ovr = (ceo || + n == "build-email" || + n == "build-warning-email" || + n == "build-error-email"); + } + + // Check if the name is one of {[*-]build-auxiliary[-*]} and update + // the pkg_config_ovr and aux_ovr flags accordingly if that's the + // case. + // + if (!cbo && !build_email_ovr) { if (optional> an = bpkg::build_auxiliary::parse_value_name (n)) @@ -289,6 +303,16 @@ namespace bdep pkg_config_ovr = true; } } + + // Check if the name is one of {*-build-bot}and update the + // pkg_config_ovr flag accordingly if that's the case. + // + if (!cbo && !build_email_ovr && !aux_ovr) + { + if (n.size () > 10 && + n.compare (n.size () - 10, 10, "-build-bot") == 0) + pkg_config_ovr = true; + } } overrides.insert (overrides.end (), @@ -816,7 +840,12 @@ namespace bdep diag_record dr (fail); dr << "invalid " << to_string (static_cast (e.line)) << ": " << e.description << - info << "override: " << nv.name << ": " << nv.value; + info << "override: " << nv.name << ':'; + + if (nv.value.find ('\n') == string::npos) + dr << ' ' << nv.value; + else + dr << "\n\\\n" << nv.value << "\n\\"; if (!n.empty () && override_manifests.size () != 1) dr << info << "package: " << n; diff --git a/tests/ci.testscript b/tests/ci.testscript index abe6021..ab3f33a 100644 --- a/tests/ci.testscript +++ b/tests/ci.testscript @@ -295,6 +295,189 @@ windows = ($cxx.target.class == 'windows') EOE } + : build-bot + : + { + +$clone_prj + + : common + : + { + $clone_prj; + + cat <=f; + : 1 + build-bot: + \ + -----BEGIN PUBLIC KEY----- + MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAw5liP5pyU9ebC/nD3djZ + 1H2dlKmUyiX0Z8POvKhLREd0B3rM59bPcnbRB4HMIhj0J0hUBvS8xb4u5udCPToa + x0A/LMWZ6claiivNtJ3CdLV98eklWdNUg5WXOuqq9QDKXw2ZpGbwDwCOh6aHSWVq + 98N9AQx0ZMmMWz3qhRyxPfh+GeJ05uj2ohU9FeUJxeqUcgJT/UcMZ3+7KYbwr+Uq + /HCoX1BmN6nvzhQGHvJIZ2IcjvOQ0AUrPmpSZN01Zr3ZEpkHM3hJWNLu3ntJLGBQ + 0aT5kG3iqFyr9q3M3c4J8c0AWrnDjvj0qnCyjNwqW+qIpatmCNT43DmgYr9fQLW0 + UHusburz53AbXs12zu3gZzkb0irlShatkMqqQaqaU0/+zw1LnoZ+rvmn2XV97UuK + LFKMKXCnyi2ZG65IZHGkjBVAPuvsX6RgLNyner/QtkDJTbfhktInbG08dCPqv1EF + 1OtcYKMTn8I5P2VmMO6SXXDLMSdU8b5DA5EY6Ca6JBB8g06S9sqGqXgQFysAnZs1 + VFgMopf8WZqj23x+DX+9KKT2pVnjbwRvBAntuCDoO75gWoETDnCQXEei/PbyamPq + 9+NjNsTDn67iJTGncZbII+eciY2YiFHm6GMzBPsUYlQcxiuO4X36jW6m2rwuw37K + oFDbGI3uY4LnhwmDFLbjtk8CAwEAAQ== + -----END PUBLIC KEY----- + \ + EOI + + $* --overrides-file f 2>>~%EOE% + %CI request is queued.*% + %reference: .+% + EOE + } + + : config-specific + : + { + $clone_prj; + + cat <=f; + : 1 + network-build-bot: + \ + -----BEGIN PUBLIC KEY----- + MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAw5liP5pyU9ebC/nD3djZ + 1H2dlKmUyiX0Z8POvKhLREd0B3rM59bPcnbRB4HMIhj0J0hUBvS8xb4u5udCPToa + x0A/LMWZ6claiivNtJ3CdLV98eklWdNUg5WXOuqq9QDKXw2ZpGbwDwCOh6aHSWVq + 98N9AQx0ZMmMWz3qhRyxPfh+GeJ05uj2ohU9FeUJxeqUcgJT/UcMZ3+7KYbwr+Uq + /HCoX1BmN6nvzhQGHvJIZ2IcjvOQ0AUrPmpSZN01Zr3ZEpkHM3hJWNLu3ntJLGBQ + 0aT5kG3iqFyr9q3M3c4J8c0AWrnDjvj0qnCyjNwqW+qIpatmCNT43DmgYr9fQLW0 + UHusburz53AbXs12zu3gZzkb0irlShatkMqqQaqaU0/+zw1LnoZ+rvmn2XV97UuK + LFKMKXCnyi2ZG65IZHGkjBVAPuvsX6RgLNyner/QtkDJTbfhktInbG08dCPqv1EF + 1OtcYKMTn8I5P2VmMO6SXXDLMSdU8b5DA5EY6Ca6JBB8g06S9sqGqXgQFysAnZs1 + VFgMopf8WZqj23x+DX+9KKT2pVnjbwRvBAntuCDoO75gWoETDnCQXEei/PbyamPq + 9+NjNsTDn67iJTGncZbII+eciY2YiFHm6GMzBPsUYlQcxiuO4X36jW6m2rwuw37K + oFDbGI3uY4LnhwmDFLbjtk8CAwEAAQ== + -----END PUBLIC KEY----- + \ + EOI + + $* --overrides-file f 2>>~%EOE% + %CI request is queued.*% + %reference: .+% + EOE + } + + : common-and-config-specific + : + { + $clone_prj; + + cat <=f; + : 1 + build-bot: + \ + -----BEGIN PUBLIC KEY----- + ABCCIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAw5liP5pyU9ebC/nD3djZ + 1H2dlKmUyiX0Z8POvKhLREd0B3rM59bPcnbRB4HMIhj0J0hUBvS8xb4u5udCPToa + x0A/LMWZ6claiivNtJ3CdLV98eklWdNUg5WXOuqq9QDKXw2ZpGbwDwCOh6aHSWVq + 98N9AQx0ZMmMWz3qhRyxPfh+GeJ05uj2ohU9FeUJxeqUcgJT/UcMZ3+7KYbwr+Uq + /HCoX1BmN6nvzhQGHvJIZ2IcjvOQ0AUrPmpSZN01Zr3ZEpkHM3hJWNLu3ntJLGBQ + 0aT5kG3iqFyr9q3M3c4J8c0AWrnDjvj0qnCyjNwqW+qIpatmCNT43DmgYr9fQLW0 + UHusburz53AbXs12zu3gZzkb0irlShatkMqqQaqaU0/+zw1LnoZ+rvmn2XV97UuK + LFKMKXCnyi2ZG65IZHGkjBVAPuvsX6RgLNyner/QtkDJTbfhktInbG08dCPqv1EF + 1OtcYKMTn8I5P2VmMO6SXXDLMSdU8b5DA5EY6Ca6JBB8g06S9sqGqXgQFysAnZs1 + VFgMopf8WZqj23x+DX+9KKT2pVnjbwRvBAntuCDoO75gWoETDnCQXEei/PbyamPq + 9+NjNsTDn67iJTGncZbII+eciY2YiFHm6GMzBPsUYlQcxiuO4X36jW6m2rwuw37K + oFDbGI3uY4LnhwmDFLbjtk8CAwEAAQ== + -----END PUBLIC KEY----- + \ + network-build-bot: + \ + -----BEGIN PUBLIC KEY----- + MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAw5liP5pyU9ebC/nD3djZ + 1H2dlKmUyiX0Z8POvKhLREd0B3rM59bPcnbRB4HMIhj0J0hUBvS8xb4u5udCPToa + x0A/LMWZ6claiivNtJ3CdLV98eklWdNUg5WXOuqq9QDKXw2ZpGbwDwCOh6aHSWVq + 98N9AQx0ZMmMWz3qhRyxPfh+GeJ05uj2ohU9FeUJxeqUcgJT/UcMZ3+7KYbwr+Uq + /HCoX1BmN6nvzhQGHvJIZ2IcjvOQ0AUrPmpSZN01Zr3ZEpkHM3hJWNLu3ntJLGBQ + 0aT5kG3iqFyr9q3M3c4J8c0AWrnDjvj0qnCyjNwqW+qIpatmCNT43DmgYr9fQLW0 + UHusburz53AbXs12zu3gZzkb0irlShatkMqqQaqaU0/+zw1LnoZ+rvmn2XV97UuK + LFKMKXCnyi2ZG65IZHGkjBVAPuvsX6RgLNyner/QtkDJTbfhktInbG08dCPqv1EF + 1OtcYKMTn8I5P2VmMO6SXXDLMSdU8b5DA5EY6Ca6JBB8g06S9sqGqXgQFysAnZs1 + VFgMopf8WZqj23x+DX+9KKT2pVnjbwRvBAntuCDoO75gWoETDnCQXEei/PbyamPq + 9+NjNsTDn67iJTGncZbII+eciY2YiFHm6GMzBPsUYlQcxiuO4X36jW6m2rwuw37K + oFDbGI3uY4LnhwmDFLbjtk8CAwEAAQ== + -----END PUBLIC KEY----- + \ + EOI + + $* --overrides-file f 2>>EOE != 0 + error: invalid file referenced by --overrides-file option: 'network-build-bot' override specified together with 'build-bot' override + info: override: network-build-bot: + \ + -----BEGIN PUBLIC KEY----- + MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAw5liP5pyU9ebC/nD3djZ + 1H2dlKmUyiX0Z8POvKhLREd0B3rM59bPcnbRB4HMIhj0J0hUBvS8xb4u5udCPToa + x0A/LMWZ6claiivNtJ3CdLV98eklWdNUg5WXOuqq9QDKXw2ZpGbwDwCOh6aHSWVq + 98N9AQx0ZMmMWz3qhRyxPfh+GeJ05uj2ohU9FeUJxeqUcgJT/UcMZ3+7KYbwr+Uq + /HCoX1BmN6nvzhQGHvJIZ2IcjvOQ0AUrPmpSZN01Zr3ZEpkHM3hJWNLu3ntJLGBQ + 0aT5kG3iqFyr9q3M3c4J8c0AWrnDjvj0qnCyjNwqW+qIpatmCNT43DmgYr9fQLW0 + UHusburz53AbXs12zu3gZzkb0irlShatkMqqQaqaU0/+zw1LnoZ+rvmn2XV97UuK + LFKMKXCnyi2ZG65IZHGkjBVAPuvsX6RgLNyner/QtkDJTbfhktInbG08dCPqv1EF + 1OtcYKMTn8I5P2VmMO6SXXDLMSdU8b5DA5EY6Ca6JBB8g06S9sqGqXgQFysAnZs1 + VFgMopf8WZqj23x+DX+9KKT2pVnjbwRvBAntuCDoO75gWoETDnCQXEei/PbyamPq + 9+NjNsTDn67iJTGncZbII+eciY2YiFHm6GMzBPsUYlQcxiuO4X36jW6m2rwuw37K + oFDbGI3uY4LnhwmDFLbjtk8CAwEAAQ== + -----END PUBLIC KEY----- + \ + EOE + } + + : unknown-config + : + { + $clone_prj; + + cat <=f; + : 1 + unknown-build-bot: + \ + -----BEGIN PUBLIC KEY----- + MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAw5liP5pyU9ebC/nD3djZ + 1H2dlKmUyiX0Z8POvKhLREd0B3rM59bPcnbRB4HMIhj0J0hUBvS8xb4u5udCPToa + x0A/LMWZ6claiivNtJ3CdLV98eklWdNUg5WXOuqq9QDKXw2ZpGbwDwCOh6aHSWVq + 98N9AQx0ZMmMWz3qhRyxPfh+GeJ05uj2ohU9FeUJxeqUcgJT/UcMZ3+7KYbwr+Uq + /HCoX1BmN6nvzhQGHvJIZ2IcjvOQ0AUrPmpSZN01Zr3ZEpkHM3hJWNLu3ntJLGBQ + 0aT5kG3iqFyr9q3M3c4J8c0AWrnDjvj0qnCyjNwqW+qIpatmCNT43DmgYr9fQLW0 + UHusburz53AbXs12zu3gZzkb0irlShatkMqqQaqaU0/+zw1LnoZ+rvmn2XV97UuK + LFKMKXCnyi2ZG65IZHGkjBVAPuvsX6RgLNyner/QtkDJTbfhktInbG08dCPqv1EF + 1OtcYKMTn8I5P2VmMO6SXXDLMSdU8b5DA5EY6Ca6JBB8g06S9sqGqXgQFysAnZs1 + VFgMopf8WZqj23x+DX+9KKT2pVnjbwRvBAntuCDoO75gWoETDnCQXEei/PbyamPq + 9+NjNsTDn67iJTGncZbII+eciY2YiFHm6GMzBPsUYlQcxiuO4X36jW6m2rwuw37K + oFDbGI3uY4LnhwmDFLbjtk8CAwEAAQ== + -----END PUBLIC KEY----- + \ + EOI + + $* --overrides-file f 2>>EOE != 0 + error: invalid file referenced by --overrides-file option: cannot override 'unknown-build-bot' value: no build package configuration 'unknown' + info: override: unknown-build-bot: + \ + -----BEGIN PUBLIC KEY----- + MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAw5liP5pyU9ebC/nD3djZ + 1H2dlKmUyiX0Z8POvKhLREd0B3rM59bPcnbRB4HMIhj0J0hUBvS8xb4u5udCPToa + x0A/LMWZ6claiivNtJ3CdLV98eklWdNUg5WXOuqq9QDKXw2ZpGbwDwCOh6aHSWVq + 98N9AQx0ZMmMWz3qhRyxPfh+GeJ05uj2ohU9FeUJxeqUcgJT/UcMZ3+7KYbwr+Uq + /HCoX1BmN6nvzhQGHvJIZ2IcjvOQ0AUrPmpSZN01Zr3ZEpkHM3hJWNLu3ntJLGBQ + 0aT5kG3iqFyr9q3M3c4J8c0AWrnDjvj0qnCyjNwqW+qIpatmCNT43DmgYr9fQLW0 + UHusburz53AbXs12zu3gZzkb0irlShatkMqqQaqaU0/+zw1LnoZ+rvmn2XV97UuK + LFKMKXCnyi2ZG65IZHGkjBVAPuvsX6RgLNyner/QtkDJTbfhktInbG08dCPqv1EF + 1OtcYKMTn8I5P2VmMO6SXXDLMSdU8b5DA5EY6Ca6JBB8g06S9sqGqXgQFysAnZs1 + VFgMopf8WZqj23x+DX+9KKT2pVnjbwRvBAntuCDoO75gWoETDnCQXEei/PbyamPq + 9+NjNsTDn67iJTGncZbII+eciY2YiFHm6GMzBPsUYlQcxiuO4X36jW6m2rwuw37K + oFDbGI3uY4LnhwmDFLbjtk8CAwEAAQ== + -----END PUBLIC KEY----- + \ + EOE + } + } + : invalid-option : { -- cgit v1.1