]> git.corax.cc Git - foundry/commitdiff
buildbot: Receive build orders from a pubsub channel
authorMatthias Kruk <m@m10k.eu>
Fri, 26 Nov 2021 10:41:30 +0000 (19:41 +0900)
committerMatthias Kruk <m@m10k.eu>
Fri, 26 Nov 2021 10:41:30 +0000 (19:41 +0900)
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.

buildbot.sh

index 7f135defab902ed79c6e08246d7a2a63fcda8db7..14275cef64d203b43181e8d01866f77c9e4cc55a 100755 (executable)
@@ -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