Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 1 | package image_repositories |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "strings" |
| 6 | ) |
| 7 | |
Mohammed Naser | f849fdf | 2022-10-07 18:28:29 +0000 | [diff] [blame] | 8 | var FORKED_PROJECTS map[string]bool = map[string]bool{ |
| 9 | "keystone": true, |
| 10 | } |
Mohammed Naser | 96c23ef | 2022-09-08 19:19:23 -0400 | [diff] [blame] | 11 | var EXTRAS map[string]string = map[string]string{} |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 12 | var PROFILES map[string]string = map[string]string{ |
| 13 | "cinder": "ceph qemu", |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 14 | "glance": "ceph", |
Mohammed Naser | 57e6b87 | 2022-09-06 17:46:29 -0400 | [diff] [blame] | 15 | "horizon": "apache", |
| 16 | "ironic": "ipxe ipmi qemu tftp", |
| 17 | "keystone": "apache ldap openidc", |
| 18 | "monasca-api": "apache influxdb", |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 19 | "monasca-persister": "influxdb", |
Mohammed Naser | 57e6b87 | 2022-09-06 17:46:29 -0400 | [diff] [blame] | 20 | "neutron": "openvswitch vpn", |
| 21 | "nova": "ceph openvswitch configdrive qemu migration", |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 22 | "placement": "apache", |
| 23 | } |
| 24 | var DIST_PACAKGES map[string]string = map[string]string{ |
Mohammed Naser | fdc71b7 | 2022-09-14 14:30:44 -0400 | [diff] [blame] | 25 | "cinder": "kubectl lsscsi nvme-cli sysfsutils udev util-linux", |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 26 | "designate": "bind9utils", |
Mohammed Naser | 85b896c | 2022-09-08 22:19:19 -0400 | [diff] [blame] | 27 | "glance": "kubectl lsscsi nvme-cli sysfsutils udev util-linux", |
Mohammed Naser | 57e6b87 | 2022-09-06 17:46:29 -0400 | [diff] [blame] | 28 | "heat": "curl", |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 29 | "ironic": "ethtool lshw iproute2", |
Mohammed Naser | 57e6b87 | 2022-09-06 17:46:29 -0400 | [diff] [blame] | 30 | "monasca-agent": "iproute2 libvirt-clients lshw", |
| 31 | "neutron": "jq ethtool lshw", |
Mohammed Naser | 69f67fe | 2022-10-26 17:14:01 -0400 | [diff] [blame] | 32 | "nova": "ovmf qemu-efi-aarch64 lsscsi nvme-cli sysfsutils udev util-linux ndctl", |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 33 | } |
| 34 | var PIP_PACKAGES map[string]string = map[string]string{ |
Mohammed Naser | 5aafa20 | 2022-12-21 18:30:05 +0000 | [diff] [blame] | 35 | "cinder": "purestorage", |
Mohammed Naser | 96c23ef | 2022-09-08 19:19:23 -0400 | [diff] [blame] | 36 | "glance": "glance_store[cinder]", |
Mohammed Naser | 7f45988 | 2022-11-02 15:42:32 -0400 | [diff] [blame] | 37 | "horizon": "git+https://github.com/openstack/designate-dashboard.git@stable/${{ matrix.release }} git+https://github.com/openstack/heat-dashboard.git@stable/${{ matrix.release }} git+https://github.com/openstack/ironic-ui.git@stable/${{ matrix.release }} git+https://github.com/openstack/magnum-ui.git@stable/${{ matrix.release }} git+https://github.com/openstack/neutron-vpnaas-dashboard.git@stable/${{ matrix.release }} git+https://github.com/openstack/octavia-dashboard.git@stable/${{ matrix.release }} git+https://github.com/openstack/senlin-dashboard.git@stable/${{ matrix.release }} git+https://github.com/openstack/monasca-ui.git@stable/${{ matrix.release }}", |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 38 | "ironic": "python-dracclient sushy", |
Mohammed Naser | 490599e | 2023-01-16 12:31:04 -0500 | [diff] [blame] | 39 | "magnum": "magnum-cluster-api==0.2.7", |
Mohammed Naser | 57e6b87 | 2022-09-06 17:46:29 -0400 | [diff] [blame] | 40 | "monasca-agent": "libvirt-python python-glanceclient python-neutronclient python-novaclient py3nvml", |
| 41 | "neutron": "neutron-vpnaas", |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 42 | "placement": "httplib2", |
| 43 | } |
| 44 | var PLATFORMS map[string]string = map[string]string{ |
| 45 | "nova": "linux/amd64,linux/arm64", |
| 46 | "neutron": "linux/amd64,linux/arm64", |
| 47 | } |
| 48 | |
| 49 | func NewBuildWorkflow(project string) *GithubWorkflow { |
Mohammed Naser | 96c23ef | 2022-09-08 19:19:23 -0400 | [diff] [blame] | 50 | extras := "" |
| 51 | if val, ok := EXTRAS[project]; ok { |
| 52 | extras = fmt.Sprintf("[%s]", val) |
| 53 | } |
| 54 | |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 55 | profiles := "" |
| 56 | if val, ok := PROFILES[project]; ok { |
| 57 | profiles = val |
| 58 | } |
| 59 | |
| 60 | distPackages := "" |
| 61 | if val, ok := DIST_PACAKGES[project]; ok { |
| 62 | distPackages = val |
| 63 | } |
| 64 | |
okozachenko1203 | 98aedb6 | 2023-02-01 01:28:34 +1100 | [diff] [blame^] | 65 | pipPackages := "cryptography python-binary-memcached" |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 66 | if val, ok := PIP_PACKAGES[project]; ok { |
Mohammed Naser | dc5784e | 2022-10-18 23:49:35 -0400 | [diff] [blame] | 67 | pipPackages += fmt.Sprintf(" %s", val) |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | platforms := "linux/amd64" |
| 71 | if val, ok := PLATFORMS[project]; ok { |
| 72 | platforms = val |
| 73 | } |
| 74 | |
Mohammed Naser | f849fdf | 2022-10-07 18:28:29 +0000 | [diff] [blame] | 75 | gitRepo := fmt.Sprintf("https://github.com/openstack/%s", project) |
| 76 | if _, ok := FORKED_PROJECTS[project]; ok { |
| 77 | gitRepo = fmt.Sprintf("https://github.com/vexxhost/%s", project) |
| 78 | } |
| 79 | |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 80 | buildArgs := []string{ |
Mohammed Naser | 19c4e4e | 2022-12-03 15:14:02 -0500 | [diff] [blame] | 81 | "BUILDER_IMAGE=quay.io/vexxhost/openstack-builder-${{ matrix.from }}", |
Mohammed Naser | 67abe6a | 2022-12-03 14:24:12 -0500 | [diff] [blame] | 82 | "RUNTIME_IMAGE=quay.io/vexxhost/openstack-runtime-${{ matrix.from }}", |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 83 | "RELEASE=${{ matrix.release }}", |
| 84 | fmt.Sprintf("PROJECT=%s", project), |
Mohammed Naser | f849fdf | 2022-10-07 18:28:29 +0000 | [diff] [blame] | 85 | fmt.Sprintf("PROJECT_REPO=%s", gitRepo), |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 86 | "PROJECT_REF=${{ env.PROJECT_REF }}", |
Mohammed Naser | 96c23ef | 2022-09-08 19:19:23 -0400 | [diff] [blame] | 87 | fmt.Sprintf("EXTRAS=%s", extras), |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 88 | fmt.Sprintf("PROFILES=%s", profiles), |
| 89 | fmt.Sprintf("DIST_PACKAGES=%s", distPackages), |
| 90 | fmt.Sprintf("PIP_PACKAGES=%s", pipPackages), |
| 91 | } |
| 92 | |
| 93 | return &GithubWorkflow{ |
| 94 | Name: "build", |
Mohammed Naser | 6d6b2c9 | 2022-09-06 15:24:23 -0400 | [diff] [blame] | 95 | Concurrency: GithubWorkflowConcurrency{ |
| 96 | Group: "${{ github.head_ref || github.run_id }}", |
| 97 | CancelInProgress: true, |
| 98 | }, |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 99 | On: GithubWorkflowTrigger{ |
Mohammed Naser | 6d6b2c9 | 2022-09-06 15:24:23 -0400 | [diff] [blame] | 100 | PullRequest: GithubWorkflowPullRequest{ |
| 101 | Types: []string{"opened", "synchronize", "reopened"}, |
| 102 | }, |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 103 | Push: GithubWorkflowPush{ |
| 104 | Branches: []string{"main"}, |
| 105 | }, |
| 106 | }, |
| 107 | Jobs: map[string]GithubWorkflowJob{ |
| 108 | "image": { |
| 109 | RunsOn: "ubuntu-latest", |
| 110 | Strategy: GithubWorkflowStrategy{ |
Mohammed Naser | 67abe6a | 2022-12-03 14:24:12 -0500 | [diff] [blame] | 111 | Matrix: map[string]interface{}{ |
| 112 | "from": []string{"focal", "jammy"}, |
| 113 | "release": []string{"wallaby", "xena", "yoga", "zed"}, |
| 114 | "exclude": []map[string]string{ |
| 115 | { |
| 116 | "from": "focal", |
| 117 | "release": "zed", |
| 118 | }, |
| 119 | { |
| 120 | "from": "jammy", |
| 121 | "release": "wallaby", |
| 122 | }, |
| 123 | { |
| 124 | "from": "jammy", |
| 125 | "release": "xena", |
| 126 | }, |
| 127 | }, |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 128 | }, |
| 129 | }, |
| 130 | Steps: []GithubWorkflowStep{ |
| 131 | { |
| 132 | Name: "Install QEMU static binaries", |
| 133 | Uses: "docker/setup-qemu-action@v2", |
| 134 | }, |
| 135 | { |
| 136 | Name: "Configure Buildkit", |
| 137 | Uses: "docker/setup-buildx-action@v2", |
| 138 | }, |
| 139 | { |
| 140 | Name: "Checkout project", |
| 141 | Uses: "actions/checkout@v3", |
| 142 | }, |
| 143 | { |
| 144 | Name: "Setup environment variables", |
| 145 | Run: "echo PROJECT_REF=$(cat manifest.yml | yq \".${{ matrix.release }}.sha\") >> $GITHUB_ENV", |
| 146 | }, |
| 147 | { |
| 148 | Name: "Authenticate with Quay.io", |
| 149 | Uses: "docker/login-action@v2", |
Mohammed Naser | 07493fc | 2022-09-06 17:33:20 -0400 | [diff] [blame] | 150 | If: "${{ github.event_name == 'push' }}", |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 151 | With: map[string]string{ |
| 152 | "registry": "quay.io", |
| 153 | "username": "${{ secrets.QUAY_USERNAME }}", |
| 154 | "password": "${{ secrets.QUAY_ROBOT_TOKEN }}", |
| 155 | }, |
| 156 | }, |
| 157 | { |
| 158 | Name: "Build image", |
| 159 | Uses: "docker/build-push-action@v3", |
| 160 | With: map[string]string{ |
| 161 | "context": ".", |
Mohammed Naser | 67abe6a | 2022-12-03 14:24:12 -0500 | [diff] [blame] | 162 | "cache-from": "type=gha,scope=${{ matrix.from }}-${{ matrix.release }}", |
| 163 | "cache-to": "type=gha,mode=max,scope=${{ matrix.from }}-${{ matrix.release }}", |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 164 | "platforms": platforms, |
Mohammed Naser | 07493fc | 2022-09-06 17:33:20 -0400 | [diff] [blame] | 165 | "push": "${{ github.event_name == 'push' }}", |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 166 | "build-args": strings.Join(buildArgs, "\n"), |
Mohammed Naser | 67abe6a | 2022-12-03 14:24:12 -0500 | [diff] [blame] | 167 | "tags": fmt.Sprintf("quay.io/vexxhost/%s:${{ env.PROJECT_REF }}-${{ matrix.from }}", project), |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 168 | }, |
| 169 | }, |
| 170 | { |
| 171 | Name: "Promote image", |
| 172 | Uses: "akhilerm/tag-push-action@v2.0.0", |
Mohammed Naser | 686e5c4 | 2022-12-03 14:29:03 -0500 | [diff] [blame] | 173 | If: `github.event_name == 'push' && ((matrix.from == 'focal') || (matrix.from == 'jammy' && matrix.release != 'yoga'))`, |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 174 | With: map[string]string{ |
Mohammed Naser | 67abe6a | 2022-12-03 14:24:12 -0500 | [diff] [blame] | 175 | "src": fmt.Sprintf("quay.io/vexxhost/%s:${{ env.PROJECT_REF }}-${{ matrix.from }}", project), |
Mohammed Naser | dabb1dc | 2022-09-06 14:45:59 -0400 | [diff] [blame] | 176 | "dst": fmt.Sprintf("quay.io/vexxhost/%s:${{ matrix.release }}", project), |
| 177 | }, |
| 178 | }, |
| 179 | }, |
| 180 | }, |
| 181 | }, |
| 182 | } |
| 183 | } |