170 lines
5.0 KiB
Python
Executable File
170 lines
5.0 KiB
Python
Executable File
#!/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 <http://www.gnu.org/licenses/>.
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
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",
|
|
"continuous-atomic@cockpit-project/cockpit/rhel-7.7",
|
|
],
|
|
"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-31": [
|
|
"fedora-31",
|
|
"fedora-31@cockpit-project/cockpit-podman",
|
|
],
|
|
"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": [
|
|
"rhel-7-7@cockpit-project/cockpit/rhel-7.7",
|
|
"rhel-7-8@cockpit-project/cockpit/rhel-7.8",
|
|
],
|
|
"ipa": [
|
|
"fedora-30",
|
|
"ubuntu-1804",
|
|
"debian-stable"
|
|
],
|
|
"selenium": [
|
|
"fedora-30/selenium-chrome",
|
|
"fedora-30/selenium-firefox",
|
|
"fedora-30/chrome@weldr/cockpit-composer",
|
|
"fedora-30/firefox@weldr/cockpit-composer",
|
|
"rhel-7-7/firefox@weldr/cockpit-composer",
|
|
"rhel-8-1/chrome@weldr/cockpit-composer",
|
|
],
|
|
"rhel-7-7": [
|
|
"rhel-7-7/firefox@weldr/cockpit-composer",
|
|
"rhel-7-7@cockpit-project/cockpit/rhel-7.7",
|
|
"rhel-atomic@cockpit-project/cockpit/rhel-7.7",
|
|
"continuous-atomic@cockpit-project/cockpit/rhel-7.7",
|
|
],
|
|
"rhel-7-8": [
|
|
"rhel-7-8@cockpit-project/cockpit/rhel-7.8",
|
|
],
|
|
"rhel-8-0": [
|
|
"rhel-8-0@cockpit-project/cockpit/rhel-8.0",
|
|
],
|
|
"rhel-8-1": [
|
|
"rhel-8-1",
|
|
"rhel-8-1-distropkg",
|
|
"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",
|
|
"rhel-atomic@cockpit-project/cockpit/rhel-7.7",
|
|
]
|
|
}
|
|
|
|
STORES = {
|
|
"rhel-7-7": REDHAT_STORE,
|
|
"rhel-7-8": 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, labels=['bot', 'no-test'], 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 })
|
|
|
|
if __name__ == '__main__':
|
|
task.main(function=run, title="Refresh image")
|