blob: bc312825f4d554075d37b2973043b2178a494117 [file] [log] [blame]
Mohammed Naserdabb1dc2022-09-06 14:45:59 -04001package image_repositories
2
3import (
4 "fmt"
5 "strings"
6)
7
Mohammed Naserf849fdf2022-10-07 18:28:29 +00008var FORKED_PROJECTS map[string]bool = map[string]bool{
9 "keystone": true,
10}
Mohammed Naser96c23ef2022-09-08 19:19:23 -040011var EXTRAS map[string]string = map[string]string{}
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040012var PROFILES map[string]string = map[string]string{
13 "cinder": "ceph qemu",
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040014 "glance": "ceph",
Mohammed Naser57e6b872022-09-06 17:46:29 -040015 "horizon": "apache",
16 "ironic": "ipxe ipmi qemu tftp",
17 "keystone": "apache ldap openidc",
18 "monasca-api": "apache influxdb",
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040019 "monasca-persister": "influxdb",
Mohammed Naser57e6b872022-09-06 17:46:29 -040020 "neutron": "openvswitch vpn",
21 "nova": "ceph openvswitch configdrive qemu migration",
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040022 "placement": "apache",
23}
24var DIST_PACAKGES map[string]string = map[string]string{
Mohammed Naserfdc71b72022-09-14 14:30:44 -040025 "cinder": "kubectl lsscsi nvme-cli sysfsutils udev util-linux",
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040026 "designate": "bind9utils",
Mohammed Naser85b896c2022-09-08 22:19:19 -040027 "glance": "kubectl lsscsi nvme-cli sysfsutils udev util-linux",
Mohammed Naser57e6b872022-09-06 17:46:29 -040028 "heat": "curl",
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040029 "ironic": "ethtool lshw iproute2",
Mohammed Naser57e6b872022-09-06 17:46:29 -040030 "monasca-agent": "iproute2 libvirt-clients lshw",
31 "neutron": "jq ethtool lshw",
Mohammed Naser69f67fe2022-10-26 17:14:01 -040032 "nova": "ovmf qemu-efi-aarch64 lsscsi nvme-cli sysfsutils udev util-linux ndctl",
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040033}
34var PIP_PACKAGES map[string]string = map[string]string{
Mohammed Naser5aafa202022-12-21 18:30:05 +000035 "cinder": "purestorage",
Mohammed Naser96c23ef2022-09-08 19:19:23 -040036 "glance": "glance_store[cinder]",
Mohammed Naser7f459882022-11-02 15:42:32 -040037 "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 Naserdabb1dc2022-09-06 14:45:59 -040038 "ironic": "python-dracclient sushy",
Mohammed Naser490599e2023-01-16 12:31:04 -050039 "magnum": "magnum-cluster-api==0.2.7",
Mohammed Naser57e6b872022-09-06 17:46:29 -040040 "monasca-agent": "libvirt-python python-glanceclient python-neutronclient python-novaclient py3nvml",
41 "neutron": "neutron-vpnaas",
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040042 "placement": "httplib2",
43}
44var PLATFORMS map[string]string = map[string]string{
45 "nova": "linux/amd64,linux/arm64",
46 "neutron": "linux/amd64,linux/arm64",
47}
48
49func NewBuildWorkflow(project string) *GithubWorkflow {
Mohammed Naser96c23ef2022-09-08 19:19:23 -040050 extras := ""
51 if val, ok := EXTRAS[project]; ok {
52 extras = fmt.Sprintf("[%s]", val)
53 }
54
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040055 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
okozachenko120398aedb62023-02-01 01:28:34 +110065 pipPackages := "cryptography python-binary-memcached"
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040066 if val, ok := PIP_PACKAGES[project]; ok {
Mohammed Naserdc5784e2022-10-18 23:49:35 -040067 pipPackages += fmt.Sprintf(" %s", val)
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040068 }
69
70 platforms := "linux/amd64"
71 if val, ok := PLATFORMS[project]; ok {
72 platforms = val
73 }
74
Mohammed Naserf849fdf2022-10-07 18:28:29 +000075 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 Naserdabb1dc2022-09-06 14:45:59 -040080 buildArgs := []string{
Mohammed Naser19c4e4e2022-12-03 15:14:02 -050081 "BUILDER_IMAGE=quay.io/vexxhost/openstack-builder-${{ matrix.from }}",
Mohammed Naser67abe6a2022-12-03 14:24:12 -050082 "RUNTIME_IMAGE=quay.io/vexxhost/openstack-runtime-${{ matrix.from }}",
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040083 "RELEASE=${{ matrix.release }}",
84 fmt.Sprintf("PROJECT=%s", project),
Mohammed Naserf849fdf2022-10-07 18:28:29 +000085 fmt.Sprintf("PROJECT_REPO=%s", gitRepo),
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040086 "PROJECT_REF=${{ env.PROJECT_REF }}",
Mohammed Naser96c23ef2022-09-08 19:19:23 -040087 fmt.Sprintf("EXTRAS=%s", extras),
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040088 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 Naser6d6b2c92022-09-06 15:24:23 -040095 Concurrency: GithubWorkflowConcurrency{
96 Group: "${{ github.head_ref || github.run_id }}",
97 CancelInProgress: true,
98 },
Mohammed Naserdabb1dc2022-09-06 14:45:59 -040099 On: GithubWorkflowTrigger{
Mohammed Naser6d6b2c92022-09-06 15:24:23 -0400100 PullRequest: GithubWorkflowPullRequest{
101 Types: []string{"opened", "synchronize", "reopened"},
102 },
Mohammed Naserdabb1dc2022-09-06 14:45:59 -0400103 Push: GithubWorkflowPush{
104 Branches: []string{"main"},
105 },
106 },
107 Jobs: map[string]GithubWorkflowJob{
108 "image": {
109 RunsOn: "ubuntu-latest",
110 Strategy: GithubWorkflowStrategy{
Mohammed Naser67abe6a2022-12-03 14:24:12 -0500111 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 Naserdabb1dc2022-09-06 14:45:59 -0400128 },
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 Naser07493fc2022-09-06 17:33:20 -0400150 If: "${{ github.event_name == 'push' }}",
Mohammed Naserdabb1dc2022-09-06 14:45:59 -0400151 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 Naser67abe6a2022-12-03 14:24:12 -0500162 "cache-from": "type=gha,scope=${{ matrix.from }}-${{ matrix.release }}",
163 "cache-to": "type=gha,mode=max,scope=${{ matrix.from }}-${{ matrix.release }}",
Mohammed Naserdabb1dc2022-09-06 14:45:59 -0400164 "platforms": platforms,
Mohammed Naser07493fc2022-09-06 17:33:20 -0400165 "push": "${{ github.event_name == 'push' }}",
Mohammed Naserdabb1dc2022-09-06 14:45:59 -0400166 "build-args": strings.Join(buildArgs, "\n"),
Mohammed Naser67abe6a2022-12-03 14:24:12 -0500167 "tags": fmt.Sprintf("quay.io/vexxhost/%s:${{ env.PROJECT_REF }}-${{ matrix.from }}", project),
Mohammed Naserdabb1dc2022-09-06 14:45:59 -0400168 },
169 },
170 {
171 Name: "Promote image",
172 Uses: "akhilerm/tag-push-action@v2.0.0",
Mohammed Naser686e5c42022-12-03 14:29:03 -0500173 If: `github.event_name == 'push' && ((matrix.from == 'focal') || (matrix.from == 'jammy' && matrix.release != 'yoga'))`,
Mohammed Naserdabb1dc2022-09-06 14:45:59 -0400174 With: map[string]string{
Mohammed Naser67abe6a2022-12-03 14:24:12 -0500175 "src": fmt.Sprintf("quay.io/vexxhost/%s:${{ env.PROJECT_REF }}-${{ matrix.from }}", project),
Mohammed Naserdabb1dc2022-09-06 14:45:59 -0400176 "dst": fmt.Sprintf("quay.io/vexxhost/%s:${{ matrix.release }}", project),
177 },
178 },
179 },
180 },
181 },
182 }
183}