Skip to content

Commit 5ce91f2

Browse files
committed
ci: improve pull request labelling logic
1 parent fa4849c commit 5ce91f2

1 file changed

Lines changed: 68 additions & 1 deletion

File tree

.github/workflows/pr-labels.yml

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ jobs:
9898
mkdir -p "$output_dir"
9999
echo "output_file=${output_file}" >> "$GITHUB_OUTPUT"
100100
- name: Run Codex labeling
101+
id: run_codex
101102
if: ${{ (github.event_name == 'workflow_dispatch' || steps.pr.outputs.is_fork != 'true') && github.actor != 'dependabot[bot]' }}
102103
uses: openai/codex-action@086169432f1d2ab2f4057540b1754d550f6a1189
103104
with:
@@ -113,6 +114,7 @@ jobs:
113114
PR_BASE_SHA: ${{ steps.pr.outputs.base_sha }}
114115
PR_HEAD_SHA: ${{ steps.pr.outputs.head_sha }}
115116
CODEX_OUTPUT_PATH: ${{ steps.codex-output.outputs.output_file }}
117+
CODEX_CONCLUSION: ${{ steps.run_codex.conclusion }}
116118
run: |
117119
python - <<'PY'
118120
import json
@@ -125,9 +127,12 @@ jobs:
125127
pr_base_sha = os.environ.get("PR_BASE_SHA")
126128
pr_head_sha = os.environ.get("PR_HEAD_SHA")
127129
codex_output_path = pathlib.Path(os.environ["CODEX_OUTPUT_PATH"])
130+
codex_conclusion = os.environ.get("CODEX_CONCLUSION", "").strip().lower()
128131
changed_files_path = pathlib.Path(".tmp/pr-labels/changed-files.txt")
129132
changes_diff_path = pathlib.Path(".tmp/pr-labels/changes.diff")
130133
134+
codex_ran = bool(codex_conclusion) and codex_conclusion != "skipped"
135+
131136
def read_file_at(commit, path):
132137
if not commit:
133138
return None
@@ -258,6 +263,68 @@ jobs:
258263
if dependencies_allowed:
259264
desired.add("dependencies")
260265
266+
if not codex_ran:
267+
feature_prefixes = {
268+
"feature:realtime": (
269+
"src/agents/realtime/",
270+
"tests/realtime/",
271+
"examples/realtime/",
272+
"docs/realtime/",
273+
),
274+
"feature:voice": (
275+
"src/agents/voice/",
276+
"tests/voice/",
277+
"examples/voice/",
278+
"docs/voice/",
279+
),
280+
"feature:mcp": (
281+
"src/agents/mcp/",
282+
"tests/mcp/",
283+
"examples/mcp/",
284+
"examples/hosted_mcp/",
285+
"docs/mcp/",
286+
),
287+
"feature:tracing": (
288+
"src/agents/tracing/",
289+
"tests/tracing/",
290+
"docs/tracing/",
291+
"examples/tracing/",
292+
),
293+
"feature:sessions": (
294+
"src/agents/memory/",
295+
"tests/memory/",
296+
"examples/memory/",
297+
"docs/memory/",
298+
),
299+
}
300+
301+
for label, prefixes in feature_prefixes.items():
302+
if any(path.startswith(prefix) for prefix in prefixes for path in changed_files):
303+
desired.add(label)
304+
305+
if any(
306+
"chatcmpl" in path or "chatcompletions" in path for path in changed_files
307+
):
308+
desired.add("feature:chat-completions")
309+
310+
if any("litellm" in path for path in changed_files):
311+
desired.add("feature:lite-llm")
312+
313+
excluded_core_prefixes = (
314+
"src/agents/realtime/",
315+
"src/agents/voice/",
316+
"src/agents/mcp/",
317+
"src/agents/tracing/",
318+
"src/agents/memory/",
319+
"src/agents/extensions/",
320+
)
321+
if any(
322+
path.startswith("src/agents/")
323+
and not path.startswith(excluded_core_prefixes)
324+
for path in changed_files
325+
):
326+
desired.add("feature:core")
327+
261328
allowed = {
262329
"documentation",
263330
"project",
@@ -299,7 +366,7 @@ jobs:
299366
).strip()
300367
existing = {label for label in result.splitlines() if label}
301368
302-
managed = set(allowed)
369+
managed = set(allowed) if codex_ran else set()
303370
to_add = sorted(desired - existing)
304371
to_remove = sorted((existing & managed) - desired)
305372

0 commit comments

Comments
 (0)