Verified Commit 1cf7fcef authored by Jordan Petridіs's avatar Jordan Petridіs 🌱 Committed by Jordan Petridіs
Browse files

Add script to create marge bot instances

parent 82f1fabc
This is the script used to bootstrap all the instances of the [marge_bot][1] to manage all the Merge Requests in GStreamer.
Marge only ever looks at a single project at a time and waits till the given Pipeline is finished,
which means that a single MR block all the other projects. To work around this we create many
instances of Marge where each one is responsible for a given module.
The script will create a `$PWD/generated` folder with all the configuration files for each instance.
It also expects a `$PWD/secrets` folder, where the ssh key and gitlab token for the bot are expected to be in.
By default the filenames for the secrets are `marge-bot.token` for the gitlab token and `marge-bot-ssh-key` for the ssh key,
but the filenames are configurable through the `template.yml` config.
The folder which the script is run from, will be mounted inside all the containers created, so take care.
import os
from shutil import copyfile
from subprocess import call
TEMPLATE = "template.yml"
VERSION = "0.9.2"
def concat_modules():
containers = " ".join(str(x) for x in MODULES + MESON_PORTS)
return containers
# can fail if container name doesn't exist yet, should be fine
def stop_all():
containers = concat_modules();
cmd = f"docker stop {containers}"
call(cmd, shell=True)
# can fail if container name doesn't exist yet, should be fine
def remove_all():
containers = concat_modules();
cmd = f"docker rm {containers}"
call(cmd, shell=True)
def create_container(name, module):
filename = f"{name}.yml"
filepath = f"generated/{filename}"
copyfile(TEMPLATE, filepath)
cmd = f"sed -i 's|@MODULE@|gstreamer/{module}$|' {filepath}"
ret = call(cmd, shell=True)
assert ret == 0
cmd = f"docker run -dt --restart=always --name={name} -v $PWD:/configuration smarkets/marge-bot:{VERSION} --config-file=/configuration/{filepath}"
ret = call(cmd, shell=True)
assert ret == 0
def main():
if not os.path.exists('secrets'):
print("Please create a 'secrets' directory")
if not os.path.exists('generated'):
# cleanup existing containers
# create the new containers
for module in MODULES:
create_container(module, module)
for name in MESON_PORTS:
create_container(name, f"meson-ports/{name}")
add-part-of: true
add-reviewers: false
add-tested: false
# branch-regexp: .*
ci-timeout: 180min
batch: false
git-timeout: 120s
gitlab-url: ''
impersonate-approvers: false
project-regexp: "@MODULE@"
auth-token-file: '/configuration/secrets/marge-bot.token'
# auth-token: ''
ssh-key-file: '/configuration/secrets/marge-bot-ssh-key'
# ssh-key: |
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment