| 
									
										
										
										
											2021-09-07 15:21:49 +08:00
										 |  |  | load( | 
					
						
							| 
									
										
										
										
											2021-09-07 17:15:04 +08:00
										 |  |  |     'scripts/drone/steps/lib.star', | 
					
						
							| 
									
										
										
										
											2021-09-07 15:21:49 +08:00
										 |  |  |     'initialize_step', | 
					
						
							| 
									
										
										
										
											2021-11-16 01:14:33 +08:00
										 |  |  |     'download_grabpl', | 
					
						
							| 
									
										
										
										
											2021-09-07 15:21:49 +08:00
										 |  |  |     'slack_step', | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-07 17:15:04 +08:00
										 |  |  | load('scripts/drone/vault.star', 'from_secret', 'github_token', 'pull_secret', 'drone_token') | 
					
						
							| 
									
										
										
										
											2021-09-07 15:21:49 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | def pipeline( | 
					
						
							|  |  |  |     name, edition, trigger, steps, ver_mode, services=[], platform='linux', depends_on=[], | 
					
						
							|  |  |  |     is_downstream=False, install_deps=True, | 
					
						
							|  |  |  |     ): | 
					
						
							|  |  |  |     if platform != 'windows': | 
					
						
							| 
									
										
										
										
											2021-11-16 18:46:44 +08:00
										 |  |  |         grabpl_step = [download_grabpl()] | 
					
						
							| 
									
										
										
										
											2021-09-07 15:21:49 +08:00
										 |  |  |         platform_conf = { | 
					
						
							|  |  |  |             'platform': { | 
					
						
							|  |  |  |                 'os': 'linux', | 
					
						
							|  |  |  |                 'arch': 'amd64' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             # A shared cache is used on the host | 
					
						
							|  |  |  |             # To avoid issues with parallel builds, we run this repo on single build agents | 
					
						
							|  |  |  |             'node': { | 
					
						
							|  |  |  |                 'type': 'no-parallel' | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     else: | 
					
						
							| 
									
										
										
										
											2021-11-16 18:46:44 +08:00
										 |  |  |         grabpl_step = [] | 
					
						
							| 
									
										
										
										
											2021-09-07 15:21:49 +08:00
										 |  |  |         platform_conf = { | 
					
						
							|  |  |  |             'platform': { | 
					
						
							|  |  |  |                 'os': 'windows', | 
					
						
							|  |  |  |                 'arch': 'amd64', | 
					
						
							|  |  |  |                 'version': '1809', | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     pipeline = { | 
					
						
							|  |  |  |         'kind': 'pipeline', | 
					
						
							|  |  |  |         'type': 'docker', | 
					
						
							|  |  |  |         'name': name, | 
					
						
							|  |  |  |         'trigger': trigger, | 
					
						
							|  |  |  |         'services': services, | 
					
						
							| 
									
										
										
										
											2021-11-16 01:14:33 +08:00
										 |  |  |         'steps': grabpl_step + initialize_step( | 
					
						
							| 
									
										
										
										
											2021-09-07 15:21:49 +08:00
										 |  |  |             edition, platform, is_downstream=is_downstream, install_deps=install_deps, ver_mode=ver_mode, | 
					
						
							|  |  |  |         ) + steps, | 
					
						
							|  |  |  |         'depends_on': depends_on, | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     pipeline.update(platform_conf) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if edition in ('enterprise', 'enterprise2'): | 
					
						
							|  |  |  |         pipeline['image_pull_secrets'] = [pull_secret] | 
					
						
							|  |  |  |         # We have a custom clone step for enterprise | 
					
						
							|  |  |  |         pipeline['clone'] = { | 
					
						
							|  |  |  |             'disable': True, | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return pipeline | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def notify_pipeline(name, slack_channel, trigger, depends_on=[]): | 
					
						
							|  |  |  |     trigger = dict(trigger, status = ['failure']) | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |         'kind': 'pipeline', | 
					
						
							|  |  |  |         'type': 'docker', | 
					
						
							|  |  |  |         'platform': { | 
					
						
							|  |  |  |             'os': 'linux', | 
					
						
							|  |  |  |             'arch': 'amd64', | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         'name': name, | 
					
						
							|  |  |  |         'trigger': trigger, | 
					
						
							|  |  |  |         'steps': [ | 
					
						
							|  |  |  |             slack_step(slack_channel), | 
					
						
							|  |  |  |         ], | 
					
						
							|  |  |  |         'depends_on': depends_on, | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 |