Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion .github/workflows/qwen-code-pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ jobs:
echo "PR #${PR_NUMBER} is ${PR_STATE}; skipping acknowledgement." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
ACK_BODY="<!-- qwen-review-ack -->_Qwen Code review request accepted. Review is queued in [workflow run](${RUN_URL})._"
# Blank line after the marker, or none of the prose below renders. A
# line opening with `<!--` starts an HTML block that runs to the line
# containing the closing delimiter, and the REST of that line stays
# inside it — so gluing the text on shipped it as raw source with a
# dead link. Verified against GitHub's own renderer.
ACK_BODY="$(printf '<!-- qwen-review-ack -->\n\n_Qwen Code review request accepted. Review is queued in [workflow run](%s)._' "$RUN_URL")"
EXISTING_ACK_ID="$(
# -F would otherwise make gh api default to POST.
gh api "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" \
Expand Down
29 changes: 29 additions & 0 deletions scripts/tests/qwen-pr-review-workflow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2207,3 +2207,32 @@ describe('workflow expression length', () => {
expect(runReviewStep()).not.toContain('${{');
});
});

describe('bot comment markers', () => {
// A line that opens with `<!--` starts an HTML block, and that block runs to
// the line containing the closing delimiter INCLUSIVE — so the rest of that
// same line is still inside it and is never parsed as Markdown. The
// queued-acknowledgement comment glued its prose straight onto the marker and
// reached every PR as raw source with a dead link. Measured through GitHub's
// own renderer (POST /markdown, mode=gfm) on the exact bodies:
// marker + text -> 0 <a>, 0 <em>
// marker + "\n" + text -> 1 <a>, 1 <em>
// marker + "\n\n" + text -> 1 <a>, 1 <em>
it('never glues prose onto the end of a marker', () => {
const offenders = [];
const re = /<!--[^>]*-->/g;
Comment thread
wenshao marked this conversation as resolved.
Resolved
let m;
while ((m = re.exec(workflow)) !== null) {
Comment thread
wenshao marked this conversation as resolved.
Resolved
// Prose in a YAML or shell comment never reaches a comment body — and
// this rule is itself explained with an inline example of the bad form.
const lineStart = workflow.lastIndexOf('\n', m.index) + 1;
if (/^\s*#/.test(workflow.slice(lineStart, m.index))) continue;
const rest = workflow.slice(m.index + m[0].length);
// Fine: an escaped newline in the printf/format string that builds the
// body, or the marker ending the shell/jq string it was written into.
if (rest.startsWith('\\n') || /^["')\n]/.test(rest)) continue;
Comment thread
wenshao marked this conversation as resolved.
Resolved
Comment thread
wenshao marked this conversation as resolved.
Resolved
offenders.push(workflow.slice(m.index, m.index + 72).split('\n')[0]);
}
expect(offenders).toEqual([]);
});
});
Loading