Skip to content

Commit

Permalink
Merge pull request #764 from conda-forge/beckermr-patch-1
Browse files Browse the repository at this point in the history
feat: add run-names to workflows
  • Loading branch information
beckermr authored Nov 5, 2024
2 parents c07d77b + 7c980d5 commit 56bfb15
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: automerge

run-name: >-
automerge: conda-forge/${{ inputs.repo }}@${{ inputs.sha }} [uuid=${{ inputs.uuid }}]
on:
workflow_dispatch:
inputs:
Expand All @@ -11,6 +14,10 @@ on:
description: 'the commit SHA to possibly merge'
required: true
type: string
uuid:
description: 'a unique identifier for this run'
required: true
type: string

env:
PY_COLORS: 1
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/webservices-workflow-dispatch.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: webservices-workflow-dispatch

run-name: >-
${{ inputs.task }}: conda-forge/${{ inputs.repo }}#${{ inputs.pr_number }} [container=${{ inputs.container_tag }}, requested_version=${{ inputs.requested_version }}, uuid=${{ inputs.uuid }}]
on:
workflow_dispatch:
inputs:
Expand All @@ -24,6 +27,10 @@ on:
required: false
type: string
default: 'null'
uuid:
description: 'a unique identifier for this run'
required: true
type: string

env:
PY_COLORS: 1
Expand Down
5 changes: 5 additions & 0 deletions conda_forge_webservices/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import shutil
import tempfile
import textwrap
import uuid
from ruamel.yaml import YAML
import requests
from requests.exceptions import RequestException
Expand Down Expand Up @@ -993,6 +994,7 @@ def rerender(full_name, pr_num):
inject_app_token_into_feedstock_readonly(full_name, repo=repo)

_, repo_name = full_name.split("/")
uid = uuid.uuid4().hex
ref = __version__.replace("+", ".")
workflow = gh.get_repo("conda-forge/conda-forge-webservices").get_workflow(
"webservices-workflow-dispatch.yml"
Expand All @@ -1004,6 +1006,7 @@ def rerender(full_name, pr_num):
"repo": repo_name,
"pr_number": str(pr_num),
"container_tag": ref,
"uuid": uid,
},
)

Expand All @@ -1017,6 +1020,7 @@ def update_version(full_name, pr_num, input_ver):
inject_app_token_into_feedstock(full_name, repo=repo)
inject_app_token_into_feedstock_readonly(full_name, repo=repo)

uid = uuid.uuid4().hex
_, repo_name = full_name.split("/")
ref = __version__.replace("+", ".")
workflow = gh.get_repo("conda-forge/conda-forge-webservices").get_workflow(
Expand All @@ -1030,6 +1034,7 @@ def update_version(full_name, pr_num, input_ver):
"pr_number": str(pr_num),
"container_tag": ref,
"requested_version": str(input_ver) or "null",
"uuid": uid,
},
)
return not running
Expand Down
3 changes: 3 additions & 0 deletions conda_forge_webservices/linting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
from pathlib import Path
from typing import TypedDict
import uuid

from git import GitCommandError, Repo
import conda_smithy.lint_recipe
Expand Down Expand Up @@ -41,6 +42,7 @@ def lint_via_github_actions(full_name: str, pr_num: int) -> bool:
if should_skip:
return False

uid = uuid.uuid4().hex
ref = __version__.replace("+", ".")
workflow = gh.get_repo("conda-forge/conda-forge-webservices").get_workflow(
"webservices-workflow-dispatch.yml"
Expand All @@ -52,6 +54,7 @@ def lint_via_github_actions(full_name: str, pr_num: int) -> bool:
"repo": repo_name,
"pr_number": str(pr_num),
"container_tag": ref,
"uuid": uid,
},
)

Expand Down
10 changes: 9 additions & 1 deletion conda_forge_webservices/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import tornado.locks
import hmac
import hashlib
import uuid
import json
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
import atexit
Expand Down Expand Up @@ -746,6 +747,7 @@ def _dispatch_automerge_job(repo, sha):
break

if not skip_test_pr:
uid = uuid.uuid4().hex
ref = __version__.replace("+", ".")
workflow = gh.get_repo("conda-forge/conda-forge-webservices").get_workflow(
"automerge.yml"
Expand All @@ -755,11 +757,17 @@ def _dispatch_automerge_job(repo, sha):
inputs={
"repo": repo,
"sha": sha,
"uuid": uid,
},
)

if running:
LOGGER.info(" automerge job dispatched: conda-forge/%s@%s", repo, sha)
LOGGER.info(
" automerge job dispatched: conda-forge/%s@%s [uuid=%s]",
repo,
sha,
uid,
)
else:
LOGGER.info(" automerge job dispatch failed")
else:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_live_automerge.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def test_live_automerge(pytestconfig):
merged = True
break
elif tot > 0:
uid = uuid.uuid4().hex
cfws_repo = gh.get_repo(
"conda-forge/conda-forge-webservices"
)
Expand All @@ -113,6 +114,7 @@ def test_live_automerge(pytestconfig):
"cf-autotick-bot-test-package-feedstock"
),
"sha": pr.head.sha,
"uuid": uid,
},
)

Expand Down
3 changes: 3 additions & 0 deletions tests/test_live_linter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import time
import uuid

import github

Expand Down Expand Up @@ -90,6 +91,7 @@ def test_linter_pr(pytestconfig):
repo = gh.get_repo("conda-forge/conda-forge-webservices")

for pr_number, _, _ in TEST_CASES:
uid = uuid.uuid4().hex
pr = repo.get_pull(pr_number)
workflow = repo.get_workflow("webservices-workflow-dispatch.yml")
workflow.create_dispatch(
Expand All @@ -99,6 +101,7 @@ def test_linter_pr(pytestconfig):
"repo": "conda-forge-webservices",
"pr_number": str(pr_number),
"container_tag": conda_forge_webservices.__version__.replace("+", "."),
"uid": uid,
},
)

Expand Down
3 changes: 3 additions & 0 deletions tests/test_live_rerender.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import subprocess
import tempfile
import time
import uuid

import conda_forge_webservices
import github
Expand All @@ -13,6 +14,7 @@

def _run_test(branch):
print("sending workflow dispatch event to rerender...", flush=True)
uid = uuid.uuid4().hex
gh = github.Github(auth=github.Auth.Token(os.environ["GH_TOKEN"]))
repo = gh.get_repo("conda-forge/conda-forge-webservices")
workflow = repo.get_workflow("webservices-workflow-dispatch.yml")
Expand All @@ -23,6 +25,7 @@ def _run_test(branch):
"repo": "cf-autotick-bot-test-package-feedstock",
"pr_number": "445",
"container_tag": conda_forge_webservices.__version__.replace("+", "."),
"uuid": uid,
},
)

Expand Down
3 changes: 3 additions & 0 deletions tests/test_live_version_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import subprocess
import tempfile
import time
import uuid

import github
import requests
Expand Down Expand Up @@ -121,6 +122,7 @@ def _pr_title(new=None):

def _run_test(branch, version):
print("sending workflow dispatch event to version updater...", flush=True)
uid = uuid.uuid4().hex
repo = GH.get_repo("conda-forge/conda-forge-webservices")
workflow = repo.get_workflow("webservices-workflow-dispatch.yml")
workflow.create_dispatch(
Expand All @@ -131,6 +133,7 @@ def _run_test(branch, version):
"pr_number": str(PR_NUM),
"container_tag": conda_forge_webservices.__version__.replace("+", "."),
"requested_version": version or "null",
"uuid": uid,
},
)

Expand Down

0 comments on commit 56bfb15

Please sign in to comment.