Skip to content
Merged
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
9 changes: 8 additions & 1 deletion .github/workflows/claude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ jobs:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
PR_ASSIGNEE: ${{ vars.CLAUDE_PR_ASSIGNEE }}
run: |
if [ -z "$CLAUDE_BRANCH" ]; then
echo "Claude did not create a branch. Skipping PR creation."
Expand All @@ -150,8 +151,14 @@ jobs:

BODY=$(printf "Closes #%s\n\nCreated automatically from Claude Code branch \`%s\`." "$ISSUE_NUMBER" "$CLAUDE_BRANCH")

ASSIGNEE_ARGS=()
if [ -n "$PR_ASSIGNEE" ]; then
ASSIGNEE_ARGS=(--assignee "$PR_ASSIGNEE")
fi

gh pr create \
--head "$CLAUDE_BRANCH" \
--base "$DEFAULT_BRANCH" \
--title "$TITLE" \
--body "$BODY"
--body "$BODY" \
"${ASSIGNEE_ARGS[@]}"
9 changes: 8 additions & 1 deletion templates/workflows/claude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ jobs:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
PR_ASSIGNEE: ${{ vars.CLAUDE_PR_ASSIGNEE }}
run: |
if [ -z "$CLAUDE_BRANCH" ]; then
echo "Claude did not create a branch. Skipping PR creation."
Expand All @@ -165,8 +166,14 @@ jobs:

BODY=$(printf "Closes #%s\n\nCreated automatically from Claude Code branch \`%s\`." "$ISSUE_NUMBER" "$CLAUDE_BRANCH")

ASSIGNEE_ARGS=()
if [ -n "$PR_ASSIGNEE" ]; then
ASSIGNEE_ARGS=(--assignee "$PR_ASSIGNEE")
fi

gh pr create \
--head "$CLAUDE_BRANCH" \
--base "$DEFAULT_BRANCH" \
--title "$TITLE" \
--body "$BODY"
--body "$BODY" \
"${ASSIGNEE_ARGS[@]}"
3 changes: 3 additions & 0 deletions test/claude-workflow-contract.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ describe('Claude workflow contracts', () => {
expect(workflow).toContain('name: Create pull request from Claude branch');
expect(workflow).toContain('GH_TOKEN: ${{ secrets.CLAUDE_PR_GITHUB_TOKEN || github.token }}');
expect(workflow).toContain('gh pr create');
expect(workflow).toContain('PR_ASSIGNEE: ${{ vars.CLAUDE_PR_ASSIGNEE }}');
expect(workflow).toContain('ASSIGNEE_ARGS=(--assignee "$PR_ASSIGNEE")');
expect(workflow).toContain('"${ASSIGNEE_ARGS[@]}"');
Comment on lines +66 to +68

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

for file in \
  .github/workflows/claude.yml \
  templates/workflows/claude.yml \
  test/claude-workflow-contract.test.js
do
  echo "== $file =="
  rg -n -C 8 'PR_ASSIGNEE|ASSIGNEE_ARGS|if \[ -n' "$file" || true
done

Repository: keito4/config

Length of output: 7147


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== test/claude-workflow-contract.test.js lines 1-90 =="
cat -n test/claude-workflow-conflow.test.js 2>/dev/null || sed -n '1,120p' test/claude-workflow-contract.test.js

echo
echo "== exact guard patterns =="
python3 - <<'PY'
from pathlib import Path
for path in ["test/claude-workflow-contract.test.js", "templates/workflows/claude.yml", ".github/workflows/claude.yml"]:
    p = Path(path)
    print(f"-- {path} --")
    if p.exists():
        s = p.read_text()
        for pat in [
            'ASSIGNEE_ARGS=()',
            'if [ -n "$PR_ASSIGNEE" ]; then',
            'ASSIGNEE_ARGS=(--assignee "$PR_ASSIGNEE")',
            '{"ASSIGNEE_ARGS[@]}"',
            'if [ -z "$PR_ASSIGNEE" ]; then',
            'PR_ASSIGNEE=""',
        ]:
            print(f"{pat!r}: {pat in s}")
PY

Repository: keito4/config

Length of output: 7003


Add coverage for the unset PR_ASSIGNEE branch.

The contract asserts that the non-empty ASSIGNEE_ARGS construction and expansion are present, but it does not assert ASSIGNEE_ARGS=() or if [ -n "$PR_ASSIGNEE" ]; then. Add those assertions so the test fails if the conditional guard is accidentally removed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/claude-workflow-contract.test.js` around lines 66 - 68, Add assertions
in the workflow contract test alongside the existing PR_ASSIGNEE checks for the
empty array initialization `ASSIGNEE_ARGS=()` and the `if [ -n "$PR_ASSIGNEE" ];
then` guard, ensuring the unset-assignee branch remains covered.

expect(workflow).toContain('git ls-remote --exit-code --heads origin "$CLAUDE_BRANCH"');
// 変更なしタスク(ブランチ未push)は正常終了として扱う(false failure 防止)
expect(workflow).toContain('Claude branch $CLAUDE_BRANCH was not pushed (no code changes). Skipping PR creation.');
Expand Down
Loading