diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2021-09-29 21:22:00 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-10-03 19:42:36 +0300 |
commit | 022d5cb4f246809ce8d9a08d3499edd309ed26e7 (patch) | |
tree | b5546e41ab32cb5692fd3ca409642c3fc5cf1b5c | |
parent | b387713a19ddf0d10d8ae28c5de6e78cd9d568b5 (diff) |
Add agent, worker, and dependency checksums to task/result manifests
-rw-r--r-- | libbbot/manifest.cxx | 87 | ||||
-rw-r--r-- | libbbot/manifest.hxx | 34 | ||||
-rw-r--r-- | tests/manifest/result-request.testscript | 31 | ||||
-rw-r--r-- | tests/manifest/result.testscript | 21 | ||||
-rw-r--r-- | tests/manifest/task-response.testscript | 31 | ||||
-rw-r--r-- | tests/manifest/task.testscript | 17 |
6 files changed, 212 insertions, 9 deletions
diff --git a/libbbot/manifest.cxx b/libbbot/manifest.cxx index 36f92a0..c604810 100644 --- a/libbbot/manifest.cxx +++ b/libbbot/manifest.cxx @@ -43,6 +43,7 @@ namespace bbot { switch (s) { + case result_status::skip: return "skip"; case result_status::success: return "success"; case result_status::warning: return "warning"; case result_status::error: return "error"; @@ -57,7 +58,8 @@ namespace bbot result_status to_result_status (const string& s) { - if (s == "success") return result_status::success; + if (s == "skip") return result_status::skip; + else if (s == "success") return result_status::success; else if (s == "warning") return result_status::warning; else if (s == "error") return result_status::error; else if (s == "abort") return result_status::abort; @@ -621,6 +623,16 @@ namespace bbot bad_value (e.what ()); } } + else if (n == "dependency-checksum") + { + if (dependency_checksum) + bad_name ("task dependency checksum redefinition"); + + if (v.empty ()) + bad_value ("empty task dependency checksum"); + + dependency_checksum = move (v); + } else if (n == "machine") { if (!machine.empty ()) @@ -697,6 +709,16 @@ namespace bbot interactive = move (v); } + else if (n == "worker-checksum") + { + if (worker_checksum) + bad_name ("task worker checksum redefinition"); + + if (v.empty ()) + bad_value ("empty task worker checksum"); + + worker_checksum = move (v); + } else if (!iu) bad_name ("unknown name '" + n + "' in task manifest"); } @@ -768,6 +790,9 @@ namespace bbot for (const test_dependency& t: tests) s.next (to_string (t.type), t.string ()); + if (dependency_checksum) + s.next ("dependency-checksum", *dependency_checksum); + s.next ("machine", machine); s.next ("target", target.string ()); @@ -804,6 +829,9 @@ namespace bbot if (interactive) s.next ("interactive", *interactive); + if (worker_checksum) + s.next ("worker-checksum", *worker_checksum); + s.next ("", ""); // End of manifest. } @@ -898,6 +926,16 @@ namespace bbot result_url = move (v); } + else if (n == "agent-checksum") + { + if (agent_checksum) + bad_name ("task response agent checksum redefinition"); + + if (v.empty ()) + bad_value ("empty task response agent checksum"); + + agent_checksum = move (v); + } else if (!iu) bad_name ("unknown name '" + n + "' in task response manifest"); } @@ -925,6 +963,9 @@ namespace bbot if (result_url) bad_value ("unexpected task response result url"); + + if (agent_checksum) + bad_value ("unexpected task response agent checksum"); } // If session is not empty then the task manifest must follow, otherwise it @@ -964,6 +1005,9 @@ namespace bbot if (result_url) s.next ("result-url", *result_url); + if (agent_checksum) + s.next ("agent-checksum", *agent_checksum); + s.next ("", ""); // End of manifest. if (task) @@ -1130,6 +1174,26 @@ namespace bbot // results[nlog++].log = move (v); } + else if (n == "worker-checksum") + { + if (worker_checksum) + bad_name ("result worker checksum redefinition"); + + if (v.empty ()) + bad_value ("empty result worker checksum"); + + worker_checksum = move (v); + } + else if (n == "dependency-checksum") + { + if (dependency_checksum) + bad_name ("result dependency checksum redefinition"); + + if (v.empty ()) + bad_value ("empty result dependency checksum"); + + dependency_checksum = move (v); + } else if (!iu) bad_name ("unknown name '" + n + "' in result manifest"); } @@ -1186,6 +1250,12 @@ namespace bbot for (const auto& r: results) s.next (r.operation + "-log", r.log); + if (worker_checksum) + s.next ("worker-checksum", *worker_checksum); + + if (dependency_checksum) + s.next ("dependency-checksum", *dependency_checksum); + s.next ("", ""); // End of manifest. } @@ -1248,6 +1318,16 @@ namespace bbot bad_value ("invalid result request challenge"); } } + else if (n == "agent-checksum") + { + if (!agent_checksum.empty ()) + bad_name ("result request agent checksum redefinition"); + + if (v.empty ()) + bad_value ("empty result request agent checksum"); + + agent_checksum = move (v); + } else if (!iu) bad_name ("unknown name '" + n + "' in result request manifest"); } @@ -1257,6 +1337,9 @@ namespace bbot if (session.empty ()) bad_value ("no result request session specified"); + if (agent_checksum.empty ()) + bad_value ("no result request agent checksum specified"); + nv = p.next (); if (nv.empty ()) bad_value ("result manifest expected"); @@ -1283,6 +1366,8 @@ namespace bbot if (challenge) s.next ("challenge", base64_encode (*challenge)); + s.next ("agent-checksum", agent_checksum); + s.next ("", ""); // End of manifest. result.serialize (s); diff --git a/libbbot/manifest.hxx b/libbbot/manifest.hxx index 1896f70..7ba53cb 100644 --- a/libbbot/manifest.hxx +++ b/libbbot/manifest.hxx @@ -170,6 +170,8 @@ namespace bbot std::vector<bpkg::requirement_alternatives> requirements; butl::small_vector<bpkg::test_dependency, 1> tests; + butl::optional<std::string> dependency_checksum; + std::string machine; // Build machine to use for building the package. butl::target_triplet target; // Build target. @@ -178,6 +180,7 @@ namespace bbot // Build system configuration variables (in addition to build environment // configuration variables). + // // Note: could be quoted. // strings config; @@ -194,6 +197,8 @@ namespace bbot butl::optional<std::string> interactive; // Interactive build breakpoint. + butl::optional<std::string> worker_checksum; + strings unquoted_config () const; @@ -206,26 +211,30 @@ namespace bbot strings tr, std::vector<bpkg::requirement_alternatives> ra, butl::small_vector<bpkg::test_dependency, 1> ts, + butl::optional<std::string> dc, std::string mn, butl::target_triplet tg, butl::optional<std::string> en, strings cf, butl::optional<bool> ht, strings wr, - butl::optional<std::string> ir) + butl::optional<std::string> ir, + butl::optional<std::string> wc) : name (std::move (nm)), version (std::move (vr)), repository (std::move (rl)), trust (std::move (tr)), requirements (std::move (ra)), tests (std::move (ts)), + dependency_checksum (std::move (dc)), machine (std::move (mn)), target (std::move (tg)), environment (std::move (en)), config (std::move (cf)), host (std::move (ht)), warning_regex (std::move (wr)), - interactive (std::move (ir)) {} + interactive (std::move (ir)), + worker_checksum (std::move (wc)) {} public: task_manifest () = default; // VC export. @@ -255,15 +264,20 @@ namespace bbot // butl::optional<std::string> challenge; butl::optional<std::string> result_url; + + butl::optional<std::string> agent_checksum; + butl::optional<task_manifest> task; task_response_manifest (std::string s, butl::optional<std::string> c, butl::optional<std::string> u, + butl::optional<std::string> ac, butl::optional<task_manifest> t) : session (std::move (s)), challenge (std::move (c)), result_url (std::move (u)), + agent_checksum (std::move (ac)), task (std::move (t)) {} public: @@ -283,6 +297,7 @@ namespace bbot // indicate whether one "overrides" the other in the "merge" operator| // (see below). // + skip, success, warning, error, @@ -346,14 +361,21 @@ namespace bbot // operation_results results; + butl::optional<std::string> worker_checksum; + butl::optional<std::string> dependency_checksum; + result_manifest (bpkg::package_name n, bpkg::version v, result_status s, - operation_results r) + operation_results r, + butl::optional<std::string> wc, + butl::optional<std::string> dc) : name (std::move (n)), version (std::move (v)), status (s), - results (std::move (r)) {} + results (std::move (r)), + worker_checksum (std::move (wc)), + dependency_checksum (std::move (dc)) {} public: result_manifest () = default; // VC export. @@ -375,13 +397,17 @@ namespace bbot // butl::optional<std::vector<char>> challenge; + std::string agent_checksum; + result_manifest result; result_request_manifest (std::string s, butl::optional<std::vector<char>> c, + std::string ac, result_manifest r) : session (std::move (s)), challenge (std::move (c)), + agent_checksum (std::move (ac)), result (std::move (r)) {} public: diff --git a/tests/manifest/result-request.testscript b/tests/manifest/result-request.testscript index e2c4a94..6d0e5b1 100644 --- a/tests/manifest/result-request.testscript +++ b/tests/manifest/result-request.testscript @@ -14,10 +14,12 @@ test.options += -rq : 1 session: abcd challenge: YQo= + agent-checksum: 1 : name: libfoo version: 1.0 status: error + worker-checksum: 1 EOF : no-challenge @@ -25,10 +27,12 @@ test.options += -rq $* <<EOF >>EOF : 1 session: abcd + agent-checksum: 1 : name: libfoo version: 1.0 status: error + worker-checksum: 1 EOF } @@ -51,6 +55,14 @@ test.options += -rq challenge: YQo= challenge: YQo= EOI + + : agent-checksum + : + $* <<EOI 2>'stdin:3:1: error: result request agent checksum redefinition' == 1 + : 1 + agent-checksum: 1 + agent-checksum: 1 + EOI } : invalid @@ -76,6 +88,13 @@ test.options += -rq : 1 challenge: EOI + + : empty-agent-checksum + : + $* <<EOI 2>'stdin:2:16: error: empty result request agent checksum' == 1 + : 1 + agent-checksum: + EOI } : unknown-name @@ -95,11 +114,21 @@ EOI challenge: YQo= EOI + + : agent-checksum + : + $* <<EOI 2>'stdin:4:1: error: no result request agent checksum specified' == 1 + : 1 + session: abc + challenge: YQo= + EOI + : result : - $* <<EOI 2>'stdin:4:1: error: result manifest expected' == 1 + $* <<EOI 2>'stdin:5:1: error: result manifest expected' == 1 : 1 session: abc challenge: YQo= + agent-checksum: 1 EOI } diff --git a/tests/manifest/result.testscript b/tests/manifest/result.testscript index c530170..0a1511f 100644 --- a/tests/manifest/result.testscript +++ b/tests/manifest/result.testscript @@ -30,6 +30,8 @@ test.options += -r test line 1 test line 2 \ + worker-checksum: 1 + dependency-checksum: 12345 EOF : update-error @@ -49,6 +51,8 @@ test.options += -r update line 1 update line 2 \ + worker-checksum: 1 + dependency-checksum: 12345 EOF : early-abort @@ -106,12 +110,20 @@ test.options += -r configure-log: configured configure-log: configured EOI + + : worker-checksum + : + $* <<EOI 2>'stdin:3:1: error: result worker checksum redefinition' == 1 + : 1 + worker-checksum: 1 + worker-checksum: 1 + EOI } : invalid : { - : name-empty + : empty-name : $* <<EOI 2>'stdin:2:6: error: invalid result package name: length is less than two characters' == 1 : 1 @@ -181,6 +193,13 @@ test.options += -r update-log: log EOI } + + : empty-worker-checksum + : + $* <<EOI 2>'stdin:2:17: error: empty result worker checksum' == 1 + : 1 + worker-checksum: + EOI } : unknown-name diff --git a/tests/manifest/task-response.testscript b/tests/manifest/task-response.testscript index d486dda..df63f70 100644 --- a/tests/manifest/task-response.testscript +++ b/tests/manifest/task-response.testscript @@ -18,6 +18,7 @@ test.options += -ts session: abcd challenge: cc6585375ef81898cc60791b11852e3d2ed9ebb82ebb0874010fe0e6f9ebdb73 result-url: https://cppget.org/?build-result + agent-checksum: 1 : name: libfoo version: 1.0 @@ -26,7 +27,7 @@ test.options += -ts target: x86_64-microsoft-win32-msvc14.0 EOF - : no-challenge + : no-optional : $* <<EOF >>EOF : 1 @@ -75,12 +76,19 @@ test.options += -ts result-url: https://cppget.org/?build-result result-url: https://cppget.org/?build-result EOI + + : agent-checksum + : + $* <<EOI 2>'stdin:3:1: error: task response agent checksum redefinition' == 1 + : 1 + agent-checksum: 1 + agent-checksum: 1 + EOI } : invalid : { - : challenge : { @@ -119,6 +127,25 @@ test.options += -ts EOI } + : agent-checksum + : + { + : empty + : + $* <<EOI 2>'stdin:2:16: error: empty task response agent checksum' == 1 + : 1 + agent-checksum: + EOI + + : redundant + : + $* <<EOI 2>'stdin:4:1: error: unexpected task response agent checksum' == 1 + : 1 + session: + agent-checksum: 1 + EOI + } + : task-unexpected : $* <<EOI 2>'stdin:3:1: error: single task response manifest expected' == 1 diff --git a/tests/manifest/task.testscript b/tests/manifest/task.testscript index 704ca20..95a2b30 100644 --- a/tests/manifest/task.testscript +++ b/tests/manifest/task.testscript @@ -20,12 +20,14 @@ test.options += -t requires: host tests: foo-tests examples: foo-examples + dependency-checksum: 12345 machine: windows_10-msvc_14 target: x86_64-microsoft-win32-msvc14.0 environment: lld config: config.cc.coptions=/Z7 config.cc.loptions=/DEBUG warning-regex: '^warning: ' '^.+: warning: ' interactive: error + worker-checksum: 1 EOF : no-config-regex-environment @@ -244,6 +246,14 @@ test.options += -t interactive: error interactive: warning EOI + + : worker-checksum + : + $* <<EOI 2>'stdin:3:1: error: task worker checksum redefinition' == 1 + : 1 + worker-checksum: 1 + worker-checksum: 1 + EOI } : invalid @@ -386,6 +396,13 @@ test.options += -t : 1 interactive: EOI + + : worker-checksum + : + $* <<EOI 2>'stdin:2:17: error: empty task worker checksum' == 1 + : 1 + worker-checksum: + EOI } : unknown-name |