No known key found for this signature in database
GPG Key ID: 1B3F9523B542D315
5 changed files with
67 additions and
0 deletions
-
debug-attach.sh
-
init-tmate.sh
-
testserver.py
-
vars.sh
-
webhook-handler.py
|
|
@ -0,0 +1,3 @@ |
|
|
|
#!/bin/bash |
|
|
|
|
|
|
|
tmate -S /run/user/1000/aur-buildbot/tmate-sockets/tmate-0.sock attach-session |
|
|
@ -0,0 +1,25 @@ |
|
|
|
#!/bin/bash |
|
|
|
|
|
|
|
source vars.sh |
|
|
|
|
|
|
|
mkdir -p "${XDG_BUILDBOT_TMATE}" |
|
|
|
CONFIG_FILE_LOC="$(mktemp --suffix="-aur-buildbot.conf")" |
|
|
|
|
|
|
|
# Check if tmate sessions are empty |
|
|
|
# TODO: implement concurrent builds |
|
|
|
if [ -z "$(find "${XDG_BUILDBOT_TMATE}" -maxdepth 0 -empty -exec echo "1" ';')" ]; then |
|
|
|
echo "Concurrent builds are not supported yet!" |
|
|
|
exit 0 |
|
|
|
fi |
|
|
|
|
|
|
|
# Write configuration file |
|
|
|
cat > "${CONFIG_FILE_LOC}" <<EOF |
|
|
|
set-option -g tmate-webhook-url "https://warp.mikroskeem.eu/aur_buildbot" |
|
|
|
set-option -g tmate-webhook-userdata "some private data" |
|
|
|
EOF |
|
|
|
|
|
|
|
# Start up tmate |
|
|
|
tmate -S "${XDG_BUILDBOT_TMATE}/tmate-0.sock" -f "${CONFIG_FILE_LOC}" new-session -d '/usr/bin/python3 webhook-handler.py /bin/bash -i' |
|
|
|
|
|
|
|
# Remove configuration file |
|
|
|
rm "${CONFIG_FILE_LOC}" |
|
|
@ -0,0 +1,14 @@ |
|
|
|
#!/usr/bin/env python |
|
|
|
|
|
|
|
import tornado.ioloop |
|
|
|
import tornado.web |
|
|
|
import pprint |
|
|
|
|
|
|
|
class DumpingHandler(tornado.web.RequestHandler): |
|
|
|
def post(self): |
|
|
|
pprint.pprint(self.request) |
|
|
|
pprint.pprint(self.request.body.decode()) |
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
tornado.web.Application([("/.*", DumpingHandler)]).listen(8080) |
|
|
|
tornado.ioloop.IOLoop.instance().start() |
|
|
@ -0,0 +1,4 @@ |
|
|
|
#!/bin/bash |
|
|
|
|
|
|
|
export XDG_BUILDBOT="${XDG_RUNTIME_DIR}/aur-buildbot" |
|
|
|
export XDG_BUILDBOT_TMATE="${XDG_RUNTIME_DIR}/aur-buildbot/tmate-sockets" |
|
|
@ -0,0 +1,21 @@ |
|
|
|
#!/usr/bin/env python |
|
|
|
|
|
|
|
import json |
|
|
|
import os |
|
|
|
import sys |
|
|
|
import time |
|
|
|
import tornado.ioloop |
|
|
|
import tornado.web |
|
|
|
|
|
|
|
class WebHookHandler(tornado.web.RequestHandler): |
|
|
|
def post(self): |
|
|
|
data = json.loads(self.request.body.decode()) |
|
|
|
if data["type"] == "session_register": |
|
|
|
print(data["params"]["stoken_ro"]) |
|
|
|
target = sys.argv[1:] |
|
|
|
os.spawnlp(os.P_NOWAIT, target[0], target) |
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
tornado.web.Application([("/aur_buildbot", WebHookHandler)]).listen(8080) |
|
|
|
tornado.ioloop.IOLoop.instance().start() |
|
|
|
time.sleep(5) |