blob: f3de6bfe90b5b9b9e46fe2e1450d05c53467f266 [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"]
def get_ref_for_project(project, release):
return (
open(f"images/openstack/projects/{project}/{release}/ref", "r").read().strip()
)
def get_profiles_for_project(project):
try:
return open(f"images/openstack/projects/{project}/profiles", "r").read().strip()
except FileNotFoundError:
return ""
def get_dist_packages_for_project(project):
try:
return (
open(f"images/openstack/projects/{project}/dist-packages", "r")
.read()
.strip()
)
except FileNotFoundError:
return ""
def get_pip_packages_for_project(project):
try:
return (
open(f"images/openstack/projects/{project}/pip-packages", "r")
.read()
.strip()
)
except FileNotFoundError:
return ""
def get_build_args_for_project(project, release):
return {
"RELEASE": release,
"PROJECT": project,
"PROJECT_REF": get_ref_for_project(project, release),
"PROFILES": get_profiles_for_project(project),
"DIST_PACKAGES": get_dist_packages_for_project(project),
"PIP_PACKAGES": get_pip_packages_for_project(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)