Skip to content

Commit abc208b

Browse files
authored
Filter workflow runs based on name (DataDog#21774)
* Filter runs based on name * Changelog
1 parent fba9966 commit abc208b

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

ddev/changelog.d/21774.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixes duplicate results when filtering specific artifacts in the `ddev size` command

ddev/src/ddev/cli/size/utils/common_funcs.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ def get_last_dependency_sizes_artifact(
995995
size of that commit.
996996
'''
997997
size_type = 'compressed' if compressed else 'uncompressed'
998-
app.display(f"Retrieving dependency sizes for {commit} ({platform}, py{py_version}, {size_type})")
998+
app.display(f"\nRetrieving dependency sizes for {commit} ({platform}, py{py_version}, {size_type})")
999999

10001000
dep_sizes_json = get_dep_sizes_json(app, commit, platform, py_version)
10011001
if not dep_sizes_json:
@@ -1033,6 +1033,11 @@ def get_dep_sizes_json(app: Application, current_commit: str, platform: str, py_
10331033
def get_run_id(app: Application, commit: str, workflow: str) -> str | None:
10341034
app.display_debug(f"Fetching workflow run ID for {commit} ({os.path.basename(workflow)})")
10351035

1036+
if workflow == MEASURE_DISK_USAGE_WORKFLOW:
1037+
jq = f'.[] | select(.name == "Measure Disk Usage [{commit}]") | .databaseId'
1038+
else:
1039+
jq = '.[-1].databaseId'
1040+
10361041
result = subprocess.run(
10371042
[
10381043
'gh',
@@ -1043,14 +1048,13 @@ def get_run_id(app: Application, commit: str, workflow: str) -> str | None:
10431048
'-c',
10441049
commit,
10451050
'--json',
1046-
'databaseId',
1051+
'databaseId,name',
10471052
'--jq',
1048-
'.[-1].databaseId',
1053+
jq,
10491054
],
10501055
capture_output=True,
10511056
text=True,
10521057
)
1053-
10541058
run_id = result.stdout.strip() if result.stdout else None
10551059
if run_id:
10561060
app.display_debug(f"Workflow run ID: {run_id}")
@@ -1065,7 +1069,7 @@ def get_current_sizes_json(app: Application, run_id: str, platform: str, py_vers
10651069
'''
10661070
Downloads the dependency sizes json for a given run id and platform when dependencies were resolved.
10671071
'''
1068-
app.display(f"Retrieving dependency sizes artifact (run={run_id}, platform={platform})")
1072+
app.display(f"\nRetrieving dependency sizes artifact (run={run_id}, platform={platform})")
10691073
with tempfile.TemporaryDirectory() as tmpdir:
10701074
app.display_debug(f"Downloading artifacts to {tmpdir}...")
10711075
try:

0 commit comments

Comments
 (0)