blob: 5622777651d72c6601b50b5faaeb339c397cb36e [file] [log] [blame]
#!/usr/bin/env python3
import yaml
PROJECTS = [
"cinder",
"heat",
"senlin",
"octavia",
"barbican",
"designate",
"nova",
"neutron",
"monasca-notification",
"monasca-agent",
"keystone",
"horizon",
"monasca-api",
"ironic",
"glance",
"magnum",
"monasca-persister",
"placement",
]
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",
}
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_platforms_for_project(project):
try:
return (
open(f"images/openstack/projects/{project}/platforms", "r").read().strip()
)
except FileNotFoundError:
return "linux/amd64"
def get_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": "type=gha",
"cache-to": "type=gha,mode=max",
"push": True,
"platforms": get_platforms_for_project(project),
"build-args": "\n".join([f"{k}={v}" for k, v in build_args.items()]),
"tags": f"quay.io/vexxhost/{project}:{ref}",
},
}
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_job_for_project(project, release) for project in PROJECTS]
+ [
# molecule
# promote image if it is the default branch
],
}
},
}
with open(f".github/workflows/{workflow_name}.yml", "w") as fd:
yaml.dump(workflow, fd, sort_keys=False)