Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"dependencies": {
"minimatch": "0.0.0-local"
"minimatch": "3.0.5"
Comment on lines 3 to +4
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use correct minimatch import for v3

Upgrading .github/scripts/package.json to minimatch@3.0.5 switches to the CommonJS default export (module.exports = minimatch), but scripts in this repo import with destructuring (e.g., const { minimatch } = require('minimatch') in merge_manager.js and pr-context-graphql.js). With v3 this evaluates to undefined, so calls like minimatch(filename, pattern, …) will throw at runtime whenever those scripts execute. Either update the import sites to const minimatch = require('minimatch') or pin a version that still provides a named export.

Useful? React with 👍 / 👎.

}
}
38 changes: 38 additions & 0 deletions tests/workflows/fixtures/keepalive/missing_instruction_token.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"repo": {"owner": "stranske", "repo": "Workflows"},
"now": "2024-05-18T12:00:00Z",
"clear_token_defaults": true,
"env": {
"OPTIONS_JSON": "{}",
"DRY_RUN": "false",
"CLEAR_TOKEN_DEFAULTS": "true",
"clear_token_defaults": "true",
"ACTIONS_BOT_PAT": "",
"SERVICE_BOT_PAT": ""
},
"pulls": [
{
"number": 909,
"labels": ["agents:keepalive"],
"comments": [
{
"user": {"login": "triage-bot"},
"body": "@codex plan-and-execute",
"created_at": "2024-05-18T08:30:00Z"
},
{
"user": {"login": "chatgpt-codex-connector"},
"body": "Checklist\n- [ ] Verify metrics\n- [x] Stage summary",
"created_at": "2024-05-18T08:45:00Z"
},
{
"id": 123456,
"user": {"login": "stranske-automation-bot"},
"body": "<!-- keepalive-round: 1 -->\n<!-- codex-keepalive-marker -->\n\n@codex plan-and-execute\n\n**Keepalive Round 1**\n\nContinue incremental work toward acceptance criteria. Use the current checklist and update task statuses.\nPost an updated summary when this round completes.\n\nCodex, 1/2 checklist item remains unchecked (completed 1).",
"created_at": "2024-05-18T09:00:00Z",
"updated_at": "2024-05-18T09:00:00Z"
}
]
}
]
}
41 changes: 30 additions & 11 deletions tests/workflows/test_keepalive_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,21 @@ def _assert_missing_instruction_token(
assert payload.get("dispatch_events") == []


def _assert_missing_dispatch_token(
result: subprocess.CompletedProcess[str],
) -> None:
expected_message = "GitHub token is required for keepalive dispatch"
combined_output = (result.stderr or "") + (result.stdout or "")
if result.returncode != 0:
assert expected_message in combined_output
return

payload = _parse_harness_payload(result)
failed = payload.get("logs", {}).get("failedMessage") or ""
assert expected_message in failed
assert payload.get("dispatch_events") == []


def _parse_harness_payload(result: subprocess.CompletedProcess[str]) -> dict:
try:
return json.loads(result.stdout or "{}")
Expand Down Expand Up @@ -641,29 +656,33 @@ def test_keepalive_fails_when_required_labels_missing() -> None:

def test_keepalive_requires_instruction_token() -> None:
_require_node()
scenario_path = FIXTURES_DIR / "missing_dispatch_token.json"
scenario_path = FIXTURES_DIR / "missing_instruction_token.json"
assert scenario_path.exists(), "Scenario fixture missing"
result = _run_harness(
scenario_path,
extra_env={"CLEAR_TOKEN_DEFAULTS": "true", "clear_token_defaults": "true"},
)
result = _run_harness(scenario_path)
_assert_missing_instruction_token(result)


def test_keepalive_requires_dispatch_token() -> None:
_require_node()
scenario_path = FIXTURES_DIR / "missing_dispatch_token.json"
assert scenario_path.exists(), "Scenario fixture missing"
# Force token defaults to be cleared so CI-provided tokens do not mask failures.
result = _run_harness(
scenario_path,
extra_env={"CLEAR_TOKEN_DEFAULTS": "true", "clear_token_defaults": "true"},
)
result = _run_harness(scenario_path)
if result.returncode != 0:
_assert_missing_instruction_token(result)
combined_output = (result.stderr or "") + (result.stdout or "")
if "GitHub token is required to author keepalive instructions" in combined_output:
_assert_missing_instruction_token(result)
else:
_assert_missing_dispatch_token(result)
return

payload = _parse_harness_payload(result)
failed_message = payload.get("logs", {}).get("failedMessage") or ""
if failed_message:
if "GitHub token is required to author keepalive instructions" in failed_message:
_assert_missing_instruction_token(result)
else:
_assert_missing_dispatch_token(result)
return
dispatch_tokens = payload.get("dispatch_tokens")
comment_tokens = payload.get("comment_tokens")
if dispatch_tokens is None or comment_tokens is None:
Expand Down
Loading