Skip to content

[Algorithms] Revamp algorithms API and provide algos as qd.funcs #1648

[Algorithms] Revamp algorithms API and provide algos as qd.funcs

[Algorithms] Revamp algorithms API and provide algos as qd.funcs #1648

name: Check deleted comments
on:
workflow_dispatch:
pull_request:
types:
- opened
- reopened
- synchronize
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
check-deleted-comments:
name: Check deleted comments
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Wait using dead-reckoning for builds to finish, before running, to save AI cost, if someone pushes many commits in a row
run: sleep 1800
- name: Get diff of changed files
id: changed
env:
BASE_REF: ${{ github.base_ref }}
run: |
git diff "origin/$BASE_REF...HEAD" \
-- '*.py' '*.cpp' '*.h' '*.hpp' '*.c' '*.cc' \
> /tmp/pr_diff.patch
if [ ! -s /tmp/pr_diff.patch ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "No relevant files changed."
else
echo "skip=false" >> "$GITHUB_OUTPUT"
echo "Diff written ($(wc -l < /tmp/pr_diff.patch) lines)"
fi
- name: Install Cursor CLI
if: steps.changed.outputs.skip != 'true'
run: |
curl https://cursor.com/install -fsS | bash
echo "$HOME/.cursor/bin" >> $GITHUB_PATH
- name: Check for unnecessarily deleted comments
if: steps.changed.outputs.skip != 'true'
env:
CURSOR_API_KEY: ${{ secrets.CURSOR_KEY_HUGH }}
run: |
RESULT=$(agent -p "$(cat <<'PROMPT'
The file /tmp/pr_diff.patch contains a unified diff of changes in this PR. Check for comments or docstrings that have been deleted (lines starting with -) without good reason.
A deletion is UNNECESSARY if:
- A comment explaining non-obvious logic, a trade-off, or a constraint was removed, and the code it described is still present
- A docstring was removed or significantly reduced without the function being deleted
A deletion is FINE if:
- The code the comment described was also deleted
- The comment is no longer correct
Use the @@ hunk headers and --- file headers to determine file paths and line numbers.
Do NOT modify any files.
Be precise: only flag clear violations, not borderline cases.
Stop after finding 10 violations.
If there are NO violations, your final output must start with the word PASS.
If there ARE violations, your final output must start with the word FAIL, followed by a list of violations (up to 10) in the format: <filepath>:<line_number>: <brief description>
PROMPT
)" --model claude-4.6-opus-high-thinking --mode ask --output-format text --trust)
echo "$RESULT"
if echo "$RESULT" | grep -qE "^FAIL([[:space:]]|$)"; then
exit 1
fi