Reduce piplines in build to reduce parallelism and notifications

This commit is contained in:
IamTheFij 2020-01-10 16:01:48 -08:00
parent c9eaaaa45c
commit 67c02a3e6f

View File

@ -3,7 +3,7 @@ def main(ctx):
pipelines = [] pipelines = []
# Run tests # Run tests
pipelines += build_test_pipelines() pipelines += run_tests()
# Add pypi push pipeline # Add pypi push pipeline
pipelines += push_to_pypi(ctx) pipelines += push_to_pypi(ctx)
@ -23,52 +23,26 @@ 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 run_tests():
test_pipelines = [ return [{
test_pipeline("python:3.5"),
test_pipeline("python:3.6"),
test_pipeline("python:3.7"),
test_pipeline("python:3.8"),
test_pipeline("python:3"),
test_pipeline("pypy:3.6", "pypy3", "pypy3"),
test_pipeline("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
def wait_for_all_tests(test_pipelines, name="py-tests"):
depends_on = []
for pipeline in test_pipelines:
depends_on.append(pipeline["name"])
return {
"kind": "pipeline", "kind": "pipeline",
"name": name, "name": "tests",
"steps": [],
"depends_on": depends_on,
}
# Builds a single test pipeline
def test_pipeline(docker_tag, python_cmd="python", tox_env="py3"):
return {
"kind": "pipeline",
"name": "test {}".format(docker_tag.replace(":", "")),
"workspace": get_workspace(), "workspace": get_workspace(),
"steps": [ "steps": [
tox(docker_tag, python_cmd, tox_env), tox_step("python:3.5"),
tox_step("python:3.6"),
tox_step("python:3.7"),
tox_step("python:3.8"),
tox_step("python:3"),
tox_step("pypy:3.6", "pypy3", "pypy3"),
tox_step("pypy:3", "pypy3", "pypy3"),
notify_step(), notify_step(),
] ],
} }]
# Builds a single python test step # Builds a single python test step
def tox(docker_tag, python_cmd="python", tox_env="py3"): def tox_step(docker_tag, python_cmd="python", tox_env="py3"):
return { return {
"name": "test {}".format(docker_tag.replace(":", "")), "name": "test {}".format(docker_tag.replace(":", "")),
"image": docker_tag, "image": docker_tag,
@ -114,6 +88,8 @@ def push_to_pypi(ctx):
return [{ return [{
"kind": "pipeline", "kind": "pipeline",
"name": "deploy to pypi", "name": "deploy to pypi",
"depends_on": ["tests"],
"workspace": get_workspace(),
"trigger": { "trigger": {
"event": ["tag"], "event": ["tag"],
"ref": [ "ref": [
@ -121,8 +97,6 @@ def push_to_pypi(ctx):
"refs/tags/v*", "refs/tags/v*",
], ],
}, },
"depends_on": ["py-tests"],
"workspace": get_workspace(),
"steps": [ "steps": [
{ {
"name": "push to test pypi", "name": "push to test pypi",
@ -186,7 +160,7 @@ def push_to_docker(ctx):
return [{ return [{
"kind": "pipeline", "kind": "pipeline",
"name": "push to docker", "name": "push to docker",
"depends_on": ["py-tests"], "depends_on": ["tests"],
"workspace": get_workspace(), "workspace": get_workspace(),
"trigger": { "trigger": {
"event": ["tag", "push"], "event": ["tag", "push"],