Skip to content

Commit

Permalink
tasks: share common macos workflow code
Browse files Browse the repository at this point in the history
This will simplify adding new workflows without having to duplicate the
boilerplate
  • Loading branch information
chouquette committed Nov 14, 2023
1 parent 4896a45 commit ca6fd0a
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions tasks/github_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,29 @@
from .utils import DEFAULT_BRANCH, load_release_versions


def _trigger_macos_workflow(ctx, release_version, destination, retry_download, retry_interval, **kwargs):
env = load_release_versions(ctx, release_version)
github_action_ref = env["MACOS_BUILD_VERSION"]

run = trigger_macos_workflow(
github_action_ref=github_action_ref,
release_version=release_version,
**kwargs,
)

workflow_conclusion, workflow_url = follow_workflow_run(run)

if workflow_conclusion == "failure":
print_failed_jobs_logs(run)

print_workflow_conclusion(workflow_conclusion, workflow_url)

download_with_retry(download_artifacts, run, destination, retry_download, retry_interval)

if workflow_conclusion != "success":
raise Exit(code=1)


@task
def trigger_macos_build(
ctx,
Expand All @@ -25,14 +48,14 @@ def trigger_macos_build(
retry_download=3,
retry_interval=10,
):
env = load_release_versions(ctx, release_version)
github_action_ref = env["MACOS_BUILD_VERSION"]

run = trigger_macos_workflow(
_trigger_macos_workflow(
ctx,
release_version,
destination,
retry_download,
retry_interval,
workflow_name="macos.yaml",
github_action_ref=github_action_ref,
datadog_agent_ref=datadog_agent_ref,
release_version=release_version,
major_version=major_version,
python_runtimes=python_runtimes,
# Send pipeline id and bucket branch so that the package version
Expand All @@ -42,18 +65,6 @@ def trigger_macos_build(
version_cache_file_content=version_cache,
)

workflow_conclusion, workflow_url = follow_workflow_run(run)

if workflow_conclusion == "failure":
print_failed_jobs_logs(run)

print_workflow_conclusion(workflow_conclusion, workflow_url)

download_with_retry(download_artifacts, run, destination, retry_download, retry_interval)

if workflow_conclusion != "success":
raise Exit(code=1)


@task
def trigger_macos_test(
Expand All @@ -66,29 +77,18 @@ def trigger_macos_test(
retry_download=3,
retry_interval=10,
):
env = load_release_versions(ctx, release_version)
github_action_ref = env["MACOS_BUILD_VERSION"]

run = trigger_macos_workflow(
_trigger_macos_workflow(
ctx,
release_version,
destination,
retry_download,
retry_interval,
workflow_name="test.yaml",
github_action_ref=github_action_ref,
datadog_agent_ref=datadog_agent_ref,
python_runtimes=python_runtimes,
version_cache_file_content=version_cache,
)

workflow_conclusion, workflow_url = follow_workflow_run(run)

if workflow_conclusion == "failure":
print_failed_jobs_logs(run)

print_workflow_conclusion(workflow_conclusion, workflow_url)

download_with_retry(download_artifacts, run, destination, retry_download, retry_interval)

if workflow_conclusion != "success":
raise Exit(code=1)


@task
def lint_codeowner(_):
Expand Down

0 comments on commit ca6fd0a

Please sign in to comment.