blob: fbce7a03b8a9f70e7c9edb232d62c0e9e13b48a6 [file] [log] [blame]
#!/usr/bin/env python3
import yaml
PROJECTS = [
"barbican",
"cinder",
"designate",
"glance",
"heat",
"horizon",
"ironic",
"keystone",
"magnum",
"monasca-agent",
"monasca-api",
"monasca-notification",
"monasca-persister",
"neutron",
"nova",
"octavia",
"placement",
"senlin",
]
RELEASES = ["xena", "wallaby", "yoga", "master"]
PROFILES = {
"cinder": "ceph qemu",
"nova": "ceph openvswitch configdrive qemu migration",
"neutron": "openvswitch vpn",
"keystone": "apache ldap openidc",
"horizon": "apache",
"monasca-api": "apache influxdb",
"ironic": "ipxe ipmi qemu tftp",
"glance": "ceph",
"monasca-persister": "influxdb",
"placement": "apache",
}
DIST_PACKAGES = {
"heat": "curl",
"designate": "bind9utils",
"nova": "ovmf qemu-efi-aarch64",
"neutron": "jq ethtool lshw",
"monasca-agent": "iproute2 libvirt-clients lshw",
"ironic": "ethtool lshw iproute2",
}
PIP_PACKAGES = {
"neutron": "neutron-vpnaas",
"monasca-agent": "libvirt-python python-glanceclient python-neutronclient python-novaclient py3nvml",
"horizon": "designate-dashboard heat-dashboard ironic-ui magnum-ui neutron-vpnaas-dashboard octavia-dashboard senlin-dashboard monasca-ui",
"ironic": "python-dracclient sushy",
"placement": "httplib2",
}
PLATFORMS = {
"nova": "linux/amd64,linux/arm64",
"neutron": "linux/amd64,linux/arm64",
}
def get_ref_for_project(project, release):
return (
open(f"images/openstack/projects/{project}/{release}/ref", "r").read().strip()
)
def get_build_args_for_project(project, release):
return {
"RELEASE": release,
"PROJECT": project,
"PROJECT_REF": get_ref_for_project(project, release),
"PROFILES": PROFILES.get(project, ""),
"DIST_PACKAGES": DIST_PACKAGES.get(project, ""),
"PIP_PACKAGES": PIP_PACKAGES.get(project, ""),
}
def get_image_build_job_for_project(project, release):
build_args = get_build_args_for_project(project, release)
ref = get_ref_for_project(project, release)
return {
"name": "Build openstack/{}".format(project),
"uses": "docker/build-push-action@v3.1.1",
"with": {
"context": "images/openstack",
"cache-from": f"type=gha,scope={project}-{release}",
"cache-to": f"type=gha,mode=max,scope={project}-{release}",
"push": True,
"platforms": PLATFORMS.get(project, "linux/amd64"),
"build-args": "\n".join([f"{k}={v}" for k, v in build_args.items()]),
"tags": f"quay.io/vexxhost/{project}:{ref}",
},
}
def get_image_promote_job_for_project(project, release):
ref = get_ref_for_project(project, release)
return {
"name": "Promote openstack/{}".format(project),
"uses": "akhilerm/tag-push-action@v2.0.0",
"with": {
"src": f"quay.io/vexxhost/{project}:{ref}",
"dst": f"quay.io/vexxhost/{project}:{release}",
},
}
for release in RELEASES:
workflow_name = f"test-{release}"
workflow = {
"name": f"test-{release}",
"on": {
"pull_request": {},
"push": {"branches": ["main"]},
},
"jobs": {
"build-images": {
"runs-on": "ubuntu-latest",
"steps": [
{"uses": "actions/checkout@v3.0.2"},
{"uses": "docker/setup-qemu-action@v2.0.0"},
{"uses": "docker/setup-buildx-action@v2.0.0"},
{
"uses": "docker/login-action@v2.0.0",
"with": {
"registry": "quay.io",
"username": "${{ secrets.QUAY_USERNAME }}",
"password": "${{ secrets.QUAY_ROBOT_TOKEN }}",
},
},
]
+ [
get_image_build_job_for_project(project, release)
for project in PROJECTS
]
+ [
# molecule
]
+ [
get_image_promote_job_for_project(project, release)
for project in PROJECTS
],
}
},
}
with open(f".github/workflows/{workflow_name}.yml", "w") as fd:
yaml.dump(workflow, fd, sort_keys=False)