#!/usr/bin/env python3 # This file is part of Cockpit. # # Copyright (C) 2016 Red Hat, Inc. # # Cockpit is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # Cockpit is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with Cockpit; If not, see . import os import subprocess import sys import time import task from task import github, REDHAT_STORE TRIGGERS = { "centos-7": [ "centos-7@cockpit-project/starter-kit", ], "continuous-atomic": [ "continuous-atomic@cockpit-project/cockpit-ostree", ], "debian-testing": [ "debian-testing" ], "debian-stable": [ "debian-stable" ], "fedora-29": [ "fedora-atomic", "fedora-29@cockpit-project/cockpit-podman", ], "fedora-30": [ "fedora-30", "fedora-30/selenium-chrome", "fedora-30/selenium-firefox", "fedora-30/selenium-edge", "fedora-30/container-bastion", "fedora-30@cockpit-project/starter-kit", "fedora-30@cockpit-project/cockpit-podman", "fedora-30@weldr/lorax", "fedora-30/live-iso@weldr/lorax", "fedora-30/qcow2@weldr/lorax", "fedora-30/chrome@weldr/cockpit-composer", "fedora-30/firefox@weldr/cockpit-composer", "fedora-30/edge@weldr/cockpit-composer", ], "fedora-atomic": [ "fedora-atomic", "fedora-atomic@cockpit-project/cockpit-ostree", ], "fedora-testing": [ "fedora-testing" ], "fedora-i386": [ "fedora-i386" ], "ubuntu-1804": [ "ubuntu-1804" ], "ubuntu-stable": [ "ubuntu-stable" ], "openshift": [ # FIXME: need to test a rhel-7.x branch here, once we can ], "ipa": [ "fedora-30", "ubuntu-1804", "debian-stable" ], "selenium": [ "fedora-30/selenium-chrome", "fedora-30/selenium-firefox", ], "rhel-7-7": [ "rhel-7-7/firefox@weldr/cockpit-composer", "rhel-7-7@cockpit-project/cockpit/rhel-7.7", ], "rhel-8-0": [ "rhel-8-0", "rhel-8-0-distropkg", ], "rhel-8-1": [ "rhel-8-1", "rhel-8-1@cockpit-project/cockpit/rhel-8.1", "rhel-8-1@cockpit-project/cockpit/rhel-8-appstream", "rhel-8-1/chrome@weldr/cockpit-composer", "rhel-8-1@cockpit-project/cockpit-podman", ], "rhel-atomic": [ "rhel-atomic@cockpit-project/cockpit-ostree", ] } STORES = { "rhel-7-7": REDHAT_STORE, "rhel-8-0": REDHAT_STORE, "rhel-8-1": REDHAT_STORE, "rhel-atomic": REDHAT_STORE, "windows-10": REDHAT_STORE, } BOTS = os.path.abspath(os.path.dirname(__file__)) BASE = os.path.normpath(os.path.join(BOTS, "..")) sys.dont_write_bytecode = True def run(image, verbose=False, **kwargs): if not image: raise RuntimeError("no image specified") triggers = TRIGGERS.get(image, [ ]) store = STORES.get(image, None) # Cleanup any extraneous disk usage elsewhere subprocess.check_call([ os.path.join(BOTS, "vm-reset") ]) cmd = [ os.path.join(BOTS, "image-create"), "--verbose", "--upload" ] if store: cmd += [ "--store", store ] cmd += [ image ] os.environ['VIRT_BUILDER_NO_CACHE'] = "yes" ret = subprocess.call(cmd) if ret: return ret branch = task.branch(image, "images: Update {0} image".format(image), pathspec="bots/images", **kwargs) if branch: pull = task.pull(branch, run_tests=False, **kwargs) # Trigger this pull request api = github.GitHub() head = pull["head"]["sha"] for trigger in triggers: api.post("statuses/{0}".format(head), { "state": "pending", "context": trigger, "description": github.NOT_TESTED_DIRECT }) # Wait until all of the statuses are present so the no-test label can # safely be removed by the task api for retry in range(20): if all(status in triggers for status in api.statuses(head).keys()): break time.sleep(6) else: raise RuntimeError("Failed to confirm the presence of all triggers") if __name__ == '__main__': task.main(function=run, title="Refresh image")