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
infrastructure/marge_bot/secrets
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.
[1]: https://github.com/smarkets/marge-bot
import os
from shutil import copyfile
from subprocess import call
MODULES = [
"cerbero",
"common",
"gst-build",
"gst-ci",
"gst-devtools",
"gst-docs",
"gst-editing-services",
"gst-examples",
"gst-integration-testsuites",
"gst-libav",
"gst-omx",
"gst-plugins-bad",
"gst-plugins-base",
"gst-plugins-good",
"gst-plugins-rs",
"gst-plugins-ugly",
"gst-python",
"gstreamer",
"gstreamer-project",
"gstreamer-rs",
"gstreamer-rs-sys",
"gstreamer-vaapi",
"gst-rtsp-server",
"gst-template",
"orc",
"www",
]
MESON_PORTS = [
"ffmpeg",
"x264",
"libffi",
"gl-headers",
]
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")
exit(1)
if not os.path.exists('generated'):
os.makedirs('generated')
# cleanup existing containers
stop_all()
remove_all()
# create the new containers
for module in MODULES:
create_container(module, module)
for name in MESON_PORTS:
create_container(name, f"meson-ports/{name}")
main()
add-part-of: true
add-reviewers: false
add-tested: false
# branch-regexp: .*
ci-timeout: 180min
batch: false
git-timeout: 120s
gitlab-url: 'https://gitlab.freedesktop.org'
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: |
# -----BEGIN OPENSSH PRIVATE KEY-----
# HELLO WORLD
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