Mohammed Naser | eb46b6c | 2022-08-29 21:45:29 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | import yaml |
| 4 | |
Mohammed Naser | eba1a76 | 2022-08-29 22:05:09 -0400 | [diff] [blame] | 5 | PROJECTS = [ |
Mohammed Naser | 4a40c9e | 2022-08-29 22:10:23 -0400 | [diff] [blame] | 6 | "cinder", |
| 7 | "heat", |
| 8 | "senlin", |
| 9 | "octavia", |
| 10 | "barbican", |
| 11 | "designate", |
| 12 | "nova", |
| 13 | "neutron", |
| 14 | "monasca-notification", |
| 15 | "monasca-agent", |
| 16 | "keystone", |
| 17 | "horizon", |
| 18 | "monasca-api", |
| 19 | "ironic", |
| 20 | "glance", |
| 21 | "magnum", |
| 22 | "monasca-persister", |
| 23 | "placement", |
Mohammed Naser | eba1a76 | 2022-08-29 22:05:09 -0400 | [diff] [blame] | 24 | ] |
Mohammed Naser | 4a40c9e | 2022-08-29 22:10:23 -0400 | [diff] [blame] | 25 | RELEASES = ["xena", "wallaby", "yoga", "master"] |
Mohammed Naser | eb46b6c | 2022-08-29 21:45:29 -0400 | [diff] [blame] | 26 | |
Mohammed Naser | cebe64f | 2022-08-29 22:15:46 -0400 | [diff] [blame] | 27 | PROFILES = { |
| 28 | "cinder": "ceph qemu", |
| 29 | "nova": "ceph openvswitch configdrive qemu migration", |
| 30 | "neutron": "openvswitch vpn", |
| 31 | "keystone": "apache ldap openidc", |
| 32 | "horizon": "apache", |
| 33 | "monasca-api": "apache influxdb", |
| 34 | "ironic": "ipxe ipmi qemu tftp", |
| 35 | "glance": "ceph", |
| 36 | "monasca-persister": "influxdb", |
| 37 | "placement": "apache", |
| 38 | } |
| 39 | DIST_PACKAGES = { |
| 40 | "heat": "curl", |
| 41 | "designate": "bind9utils", |
| 42 | "nova": "ovmf qemu-efi-aarch64", |
| 43 | "neutron": "jq ethtool lshw", |
| 44 | "monasca-agent": "iproute2 libvirt-clients lshw", |
| 45 | "ironic": "ethtool lshw iproute2", |
| 46 | } |
| 47 | PIP_PACKAGES = { |
| 48 | "neutron": "neutron-vpnaas", |
| 49 | "monasca-agent": "libvirt-python python-glanceclient python-neutronclient python-novaclient py3nvml", |
| 50 | "horizon": "designate-dashboard heat-dashboard ironic-ui magnum-ui neutron-vpnaas-dashboard octavia-dashboard senlin-dashboard monasca-ui", |
| 51 | "ironic": "python-dracclient sushy", |
| 52 | "placement": "httplib2", |
| 53 | } |
Mohammed Naser | 503c1f8 | 2022-08-29 22:17:36 -0400 | [diff] [blame] | 54 | PLATFORMS = { |
| 55 | "nova": "linux/amd64,linux/arm64", |
| 56 | "neutron": "linux/amd64,linux/arm64", |
| 57 | } |
Mohammed Naser | cebe64f | 2022-08-29 22:15:46 -0400 | [diff] [blame] | 58 | |
Mohammed Naser | eb46b6c | 2022-08-29 21:45:29 -0400 | [diff] [blame] | 59 | |
| 60 | def get_ref_for_project(project, release): |
| 61 | return ( |
| 62 | open(f"images/openstack/projects/{project}/{release}/ref", "r").read().strip() |
| 63 | ) |
| 64 | |
| 65 | |
Mohammed Naser | eb46b6c | 2022-08-29 21:45:29 -0400 | [diff] [blame] | 66 | def get_build_args_for_project(project, release): |
| 67 | return { |
| 68 | "RELEASE": release, |
| 69 | "PROJECT": project, |
| 70 | "PROJECT_REF": get_ref_for_project(project, release), |
Mohammed Naser | cebe64f | 2022-08-29 22:15:46 -0400 | [diff] [blame] | 71 | "PROFILES": PROFILES.get(project, ""), |
| 72 | "DIST_PACKAGES": DIST_PACKAGES.get(project, ""), |
| 73 | "PIP_PACKAGES": PIP_PACKAGES.get(project, ""), |
Mohammed Naser | eb46b6c | 2022-08-29 21:45:29 -0400 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | |
Mohammed Naser | cbbdae7 | 2022-08-29 22:22:22 -0400 | [diff] [blame] | 77 | def get_image_build_job_for_project(project, release): |
Mohammed Naser | eb46b6c | 2022-08-29 21:45:29 -0400 | [diff] [blame] | 78 | build_args = get_build_args_for_project(project, release) |
| 79 | ref = get_ref_for_project(project, release) |
| 80 | |
| 81 | return { |
Mohammed Naser | 4a40c9e | 2022-08-29 22:10:23 -0400 | [diff] [blame] | 82 | "name": "Build openstack/{}".format(project), |
Mohammed Naser | eb46b6c | 2022-08-29 21:45:29 -0400 | [diff] [blame] | 83 | "uses": "docker/build-push-action@v3.1.1", |
| 84 | "with": { |
| 85 | "context": "images/openstack", |
Mohammed Naser | e1d0067 | 2022-08-29 23:32:15 -0400 | [diff] [blame] | 86 | "cache-from": f"type=gha,scope={project}-{release}", |
| 87 | "cache-to": "type=gha,mode=max,scope={project}-{release}", |
Mohammed Naser | eb46b6c | 2022-08-29 21:45:29 -0400 | [diff] [blame] | 88 | "push": True, |
Mohammed Naser | 503c1f8 | 2022-08-29 22:17:36 -0400 | [diff] [blame] | 89 | "platforms": PLATFORMS.get(project, "linux/amd64"), |
Mohammed Naser | eb46b6c | 2022-08-29 21:45:29 -0400 | [diff] [blame] | 90 | "build-args": "\n".join([f"{k}={v}" for k, v in build_args.items()]), |
| 91 | "tags": f"quay.io/vexxhost/{project}:{ref}", |
| 92 | }, |
| 93 | } |
| 94 | |
| 95 | |
Mohammed Naser | cbbdae7 | 2022-08-29 22:22:22 -0400 | [diff] [blame] | 96 | def get_image_promote_job_for_project(project, release): |
| 97 | ref = get_ref_for_project(project, release) |
| 98 | |
| 99 | return { |
| 100 | "name": "Promote openstack/{}".format(project), |
| 101 | "uses": "akhilerm/tag-push-action@v2.0.0", |
| 102 | "with": { |
| 103 | "src": f"quay.io/vexxhost/{project}:{ref}", |
| 104 | "dst": f"quay.io/vexxhost/{project}:{release}", |
| 105 | }, |
| 106 | } |
| 107 | |
| 108 | |
Mohammed Naser | eb46b6c | 2022-08-29 21:45:29 -0400 | [diff] [blame] | 109 | for release in RELEASES: |
Mohammed Naser | 7a37c99 | 2022-08-29 21:47:49 -0400 | [diff] [blame] | 110 | workflow_name = f"test-{release}" |
| 111 | |
Mohammed Naser | eb46b6c | 2022-08-29 21:45:29 -0400 | [diff] [blame] | 112 | workflow = { |
| 113 | "name": f"test-{release}", |
| 114 | "on": { |
| 115 | "pull_request": {}, |
| 116 | "push": {"branches": ["main"]}, |
| 117 | }, |
| 118 | "jobs": { |
| 119 | "build-images": { |
| 120 | "runs-on": "ubuntu-latest", |
Mohammed Naser | 4a40c9e | 2022-08-29 22:10:23 -0400 | [diff] [blame] | 121 | "steps": [ |
| 122 | {"uses": "actions/checkout@v3.0.2"}, |
| 123 | {"uses": "docker/setup-qemu-action@v2.0.0"}, |
| 124 | {"uses": "docker/setup-buildx-action@v2.0.0"}, |
| 125 | { |
| 126 | "uses": "docker/login-action@v2.0.0", |
| 127 | "with": { |
| 128 | "registry": "quay.io", |
| 129 | "username": "${{ secrets.QUAY_USERNAME }}", |
| 130 | "password": "${{ secrets.QUAY_ROBOT_TOKEN }}", |
| 131 | }, |
| 132 | }, |
| 133 | ] |
Mohammed Naser | cbbdae7 | 2022-08-29 22:22:22 -0400 | [diff] [blame] | 134 | + [ |
| 135 | get_image_build_job_for_project(project, release) |
| 136 | for project in PROJECTS |
| 137 | ] |
Mohammed Naser | 4a40c9e | 2022-08-29 22:10:23 -0400 | [diff] [blame] | 138 | + [ |
| 139 | # molecule |
Mohammed Naser | cbbdae7 | 2022-08-29 22:22:22 -0400 | [diff] [blame] | 140 | ] |
| 141 | + [ |
| 142 | get_image_promote_job_for_project(project, release) |
| 143 | for project in PROJECTS |
Mohammed Naser | 4a40c9e | 2022-08-29 22:10:23 -0400 | [diff] [blame] | 144 | ], |
Mohammed Naser | eb46b6c | 2022-08-29 21:45:29 -0400 | [diff] [blame] | 145 | } |
| 146 | }, |
| 147 | } |
| 148 | |
Mohammed Naser | 7a37c99 | 2022-08-29 21:47:49 -0400 | [diff] [blame] | 149 | with open(f".github/workflows/{workflow_name}.yml", "w") as fd: |
| 150 | yaml.dump(workflow, fd, sort_keys=False) |