From: Matthias Kruk Date: Fri, 26 Nov 2021 10:41:30 +0000 (+0900) Subject: buildbot: Receive build orders from a pubsub channel X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=cd554686942ac05e25a6f2cae1bc3aebaf5f4790;p=foundry buildbot: Receive build orders from a pubsub channel The current buildbot implementation expects to receive build orders addressed directly to it, requiring a central orchestrator in the build system. This commit makes buildbot receive build orders from a pubsub channel, as a first step towards a completely distributed build system made of independent processes. --- diff --git a/buildbot.sh b/buildbot.sh index 7f135de..14275ce 100755 --- a/buildbot.sh +++ b/buildbot.sh @@ -26,6 +26,7 @@ build() { local err err=0 + if ! output=$(git clone "$repository" -b "$branch" "$builddir/sources" 2>&1); then err=1 fi @@ -144,7 +145,8 @@ handle_build_request() { dispatch_tasks() { local endpoint_name="$1" - local topic="$2" + local watch="$2" + local publish_to="$3" local endpoint @@ -153,6 +155,11 @@ dispatch_tasks() { return 1 fi + if ! ipc_endpoint_subscribe "$endpoint" "$watch"; then + log_error "Could not subscribe to $watch" + return 1 + fi + while inst_running; do local msg local data @@ -177,7 +184,7 @@ dispatch_tasks() { inst_set_status "Build request received" - handle_build_request "$endpoint" "$topic" "$data" + handle_build_request "$endpoint" "$publish_to" "$data" done return 0 @@ -185,19 +192,22 @@ dispatch_tasks() { main() { local endpoint - local topic + local watch + local publish_to - opt_add_arg "e" "endpoint" "v" "pub/buildbot" "The IPC endpoint to listen on" - opt_add_arg "t" "topic" "v" "builds" "The topic to publish builds under" + opt_add_arg "e" "endpoint" "v" "pub/buildbot" "The IPC endpoint to listen on" + opt_add_arg "w" "watch" "v" "commits" "The topic to watch for commit messages" + opt_add_arg "p" "publish-to" "v" "builds" "The topic to publish builds under" if ! opt_parse "$@"; then return 1 fi endpoint=$(opt_get "endpoint") - topic=$(opt_get "topic") + watch=$(opt_get "watch") + publish_to=$(opt_get "publish-to") - if ! inst_start dispatch_tasks "$endpoint" "$topic"; then + if ! inst_start dispatch_tasks "$endpoint" "$watch" "$publish_to"; then return 1 fi