Update build pipeline to notify on docker fail/success
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
64e6542a93
commit
ad4a3770e7
147
.drone.star
147
.drone.star
@ -3,17 +3,13 @@ def main(ctx):
|
|||||||
pipelines = []
|
pipelines = []
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
test_pipelines = build_test_pipelines()
|
pipelines += build_test_pipelines()
|
||||||
pipelines += test_pipelines
|
|
||||||
|
|
||||||
# Wait for all tests to complete
|
|
||||||
pipelines.append(wait_for_all_tests(test_pipelines))
|
|
||||||
|
|
||||||
# Add pypi push pipeline
|
# Add pypi push pipeline
|
||||||
pipelines.append(push_to_pypi(ctx))
|
pipelines += push_to_pypi(ctx)
|
||||||
|
|
||||||
# Add docker push pipelines
|
# Add docker push pipelines
|
||||||
pipelines += docker_pipelines()
|
pipelines += push_to_docker(ctx)
|
||||||
|
|
||||||
return pipelines
|
return pipelines
|
||||||
|
|
||||||
@ -28,7 +24,7 @@ def get_workspace():
|
|||||||
|
|
||||||
# Builds a list of all test pipelines to be executed
|
# Builds a list of all test pipelines to be executed
|
||||||
def build_test_pipelines():
|
def build_test_pipelines():
|
||||||
return [
|
test_pipelines = [
|
||||||
test("python:3.5"),
|
test("python:3.5"),
|
||||||
test("python:3.6"),
|
test("python:3.6"),
|
||||||
test("python:3.7"),
|
test("python:3.7"),
|
||||||
@ -38,16 +34,21 @@ def build_test_pipelines():
|
|||||||
test("pypy:3", "pypy3", "pypy3"),
|
test("pypy:3", "pypy3", "pypy3"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Converge all tests on a single pipeline "py-tests"
|
||||||
|
test_pipelines.append(wait_for_all_tests(test_pipelines))
|
||||||
|
|
||||||
|
return test_pipelines
|
||||||
|
|
||||||
|
|
||||||
# Waits for the completion of all test pipelines
|
# Waits for the completion of all test pipelines
|
||||||
def wait_for_all_tests(test_pipelines):
|
def wait_for_all_tests(test_pipelines, name="py-tests"):
|
||||||
depends_on = []
|
depends_on = []
|
||||||
for pipeline in test_pipelines:
|
for pipeline in test_pipelines:
|
||||||
depends_on.append(pipeline["name"])
|
depends_on.append(pipeline["name"])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"kind": "pipeline",
|
"kind": "pipeline",
|
||||||
"name": "py-tests",
|
"name": name,
|
||||||
"steps": [],
|
"steps": [],
|
||||||
"depends_on": depends_on,
|
"depends_on": depends_on,
|
||||||
}
|
}
|
||||||
@ -57,7 +58,7 @@ def wait_for_all_tests(test_pipelines):
|
|||||||
def test(docker_tag, python_cmd="python", tox_env="py3"):
|
def test(docker_tag, python_cmd="python", tox_env="py3"):
|
||||||
return {
|
return {
|
||||||
"kind": "pipeline",
|
"kind": "pipeline",
|
||||||
"name": "test-{}".format(docker_tag.replace(":", "")),
|
"name": "test {}".format(docker_tag.replace(":", "")),
|
||||||
"workspace": get_workspace(),
|
"workspace": get_workspace(),
|
||||||
"steps": [
|
"steps": [
|
||||||
{
|
{
|
||||||
@ -105,9 +106,9 @@ def notify_step():
|
|||||||
|
|
||||||
# Push package to pypi
|
# Push package to pypi
|
||||||
def push_to_pypi(ctx):
|
def push_to_pypi(ctx):
|
||||||
return {
|
return [{
|
||||||
"kind": "pipeline",
|
"kind": "pipeline",
|
||||||
"name": "deploy-pypi",
|
"name": "deploy to pypi",
|
||||||
"trigger": {
|
"trigger": {
|
||||||
"event": ["tag"],
|
"event": ["tag"],
|
||||||
"ref": [
|
"ref": [
|
||||||
@ -149,69 +150,39 @@ def push_to_pypi(ctx):
|
|||||||
},
|
},
|
||||||
notify_step(),
|
notify_step(),
|
||||||
]
|
]
|
||||||
}
|
}]
|
||||||
|
|
||||||
|
|
||||||
# Deploys image to docker hub
|
# Build and push docker image
|
||||||
def push_docker(tag_suffix, arch, repo):
|
def push_docker_step(tag_suffix, arch, repo):
|
||||||
return {
|
return {
|
||||||
"kind": "pipeline",
|
"name": "build",
|
||||||
"name": "deploy-docker-{}".format(tag_suffix),
|
"image": "plugins/docker",
|
||||||
"trigger": {
|
"settings": {
|
||||||
"event": ["tag", "push"],
|
"repo": "iamthefij/minitor",
|
||||||
"ref": [
|
"auto_tag": True,
|
||||||
"refs/heads/master",
|
"auto_tag_suffix": tag_suffix,
|
||||||
"refs/tags/v*",
|
"username": {
|
||||||
|
"from_secret": "docker_username",
|
||||||
|
},
|
||||||
|
"password": {
|
||||||
|
"from_secret": "docker_password",
|
||||||
|
},
|
||||||
|
"build_args": [
|
||||||
|
"ARCH={}".format(arch),
|
||||||
|
"REPO={}".format(repo),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"workspace": get_workspace(),
|
|
||||||
"steps": [
|
|
||||||
{
|
|
||||||
"name": "get qemu",
|
|
||||||
"image": "busybox",
|
|
||||||
"commands": ["sh ./get_qemu.sh {}".format(arch)],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "build",
|
|
||||||
"image": "plugins/docker",
|
|
||||||
"settings": {
|
|
||||||
"repo": "iamthefij/minitor",
|
|
||||||
"auto_tag": True,
|
|
||||||
"auto_tag_suffix": tag_suffix,
|
|
||||||
"username": {
|
|
||||||
"from_secret": "docker_username",
|
|
||||||
},
|
|
||||||
"password": {
|
|
||||||
"from_secret": "docker_password",
|
|
||||||
},
|
|
||||||
"build_args": [
|
|
||||||
"ARCH={}".format(arch),
|
|
||||||
"REPO={}".format(repo),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# generate all docker pipelines to push images and manifest
|
# Builds a pipeline to push to docker
|
||||||
def docker_pipelines():
|
def push_to_docker(ctx):
|
||||||
# build list of images to push
|
return [{
|
||||||
docker_pipelines = [
|
|
||||||
push_docker("linux-amd64", "x86_64", "library"),
|
|
||||||
push_docker("linux-arm", "arm", "arm32v6"),
|
|
||||||
push_docker("linux-arm64", "aarch64", "arm64v8"),
|
|
||||||
]
|
|
||||||
|
|
||||||
# build list of dependencies
|
|
||||||
pipeline_names = []
|
|
||||||
for pipeline in docker_pipelines:
|
|
||||||
pipeline_names.append(pipeline["name"])
|
|
||||||
|
|
||||||
# append manifest pipeline
|
|
||||||
docker_pipelines.append({
|
|
||||||
"kind": "pipeline",
|
"kind": "pipeline",
|
||||||
"name": "deploy-docker-manifest",
|
"name": "push to docker",
|
||||||
|
"depends_on": ["py-tests"],
|
||||||
|
"workspace": get_workspace(),
|
||||||
"trigger": {
|
"trigger": {
|
||||||
"event": ["tag"],
|
"event": ["tag"],
|
||||||
"ref": [
|
"ref": [
|
||||||
@ -219,23 +190,27 @@ def docker_pipelines():
|
|||||||
"refs/tags/v*",
|
"refs/tags/v*",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"workspace": get_workspace(),
|
"steps": [
|
||||||
"depends_on": pipeline_names,
|
push_docker_step("linux-amd64", "x86_64", "library"),
|
||||||
"steps": [{
|
push_docker_step("linux-arm", "arm", "arm32v6"),
|
||||||
"name": "publish manifest",
|
push_docker_step("linux-arm64", "aarch64", "arm64v8"),
|
||||||
"image": "plugins/manifest",
|
{
|
||||||
"settings": {
|
"name": "publish manifest",
|
||||||
"spec": "manifest.tmpl",
|
"image": "plugins/manifest",
|
||||||
"auto_tag": True,
|
"settings": {
|
||||||
"ignore_missing": True,
|
"spec": "manifest.tmpl",
|
||||||
"username": {
|
"auto_tag": True,
|
||||||
"from_secret": "docker_username",
|
"ignore_missing": True,
|
||||||
},
|
"username": {
|
||||||
"password": {
|
"from_secret": "docker_username",
|
||||||
"from_secret": "docker_password",
|
},
|
||||||
},
|
"password": {
|
||||||
}
|
"from_secret": "docker_password",
|
||||||
}],
|
},
|
||||||
})
|
}
|
||||||
|
},
|
||||||
|
notify_step(),
|
||||||
|
],
|
||||||
|
}]
|
||||||
|
|
||||||
return docker_pipelines
|
# vim: ft=python
|
||||||
|
Loading…
Reference in New Issue
Block a user