Build: Drone starlark file cleanup (#59919)

* format drone starlark files with black

* clean up unused params

* more simplification

* more cleanup

* more cleanup
This commit is contained in:
Dan Cech
2022-12-07 09:13:57 +02:00
committed by GitHub
parent d0eeff2fa0
commit 440d8a3d88
23 changed files with 1449 additions and 1021 deletions
+41 -20
View File
@@ -4,25 +4,33 @@ load(
'slack_step',
)
load('scripts/drone/vault.star', 'from_secret', 'github_token', 'pull_secret', 'drone_token')
load(
'scripts/drone/vault.star',
'from_secret',
'pull_secret',
)
failure_template = 'Build {{build.number}} failed for commit: <https://github.com/{{repo.owner}}/{{repo.name}}/commit/{{build.commit}}|{{ truncate build.commit 8 }}>: {{build.link}}\nBranch: <https://github.com/{{ repo.owner }}/{{ repo.name }}/commits/{{ build.branch }}|{{ build.branch }}>\nAuthor: {{build.author}}'
drone_change_template = '`.drone.yml` and `starlark` files have been changed on the OSS repo, by: {{build.author}}. \nBranch: <https://github.com/{{ repo.owner }}/{{ repo.name }}/commits/{{ build.branch }}|{{ build.branch }}>\nCommit hash: <https://github.com/{{repo.owner}}/{{repo.name}}/commit/{{build.commit}}|{{ truncate build.commit 8 }}>'
def pipeline(
name, edition, trigger, steps, services=[], platform='linux', depends_on=[], environment=None, volumes=[],
):
name,
edition,
trigger,
steps,
services=[],
platform='linux',
depends_on=[],
environment=None,
volumes=[],
):
if platform != 'windows':
platform_conf = {
'platform': {
'os': 'linux',
'arch': 'amd64'
},
'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'
}
'node': {'type': 'no-parallel'},
}
else:
platform_conf = {
@@ -43,19 +51,23 @@ def pipeline(
'clone': {
'retries': 3,
},
'volumes': [{
'name': 'docker',
'host': {
'path': '/var/run/docker.sock',
},
}],
'volumes': [
{
'name': 'docker',
'host': {
'path': '/var/run/docker.sock',
},
}
],
'depends_on': depends_on,
'image_pull_secrets': [pull_secret],
}
if environment:
pipeline.update({
'environment': environment,
})
pipeline.update(
{
'environment': environment,
}
)
pipeline['volumes'].extend(volumes)
pipeline.update(platform_conf)
@@ -68,7 +80,10 @@ def pipeline(
return pipeline
def notify_pipeline(name, slack_channel, trigger, depends_on=[], template=None, secret=None):
def notify_pipeline(
name, slack_channel, trigger, depends_on=[], template=None, secret=None
):
trigger = dict(trigger)
return {
'kind': 'pipeline',
@@ -89,3 +104,9 @@ def notify_pipeline(name, slack_channel, trigger, depends_on=[], template=None,
}
# TODO: this overrides any existing dependencies because we're following the existing logic
# it should append to any existing dependencies
def with_deps(steps, deps=[]):
for step in steps:
step['depends_on'] = deps
return steps