BE-271: HashQL: Implement PostInline pass
#1177
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Check TODO Linear Tickets | |
| on: | |
| pull_request: | |
| types: [opened, edited, synchronize] | |
| jobs: | |
| check-todos: | |
| name: Check for TODO comments with PR ticket IDs | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - name: Extract ticket IDs from PR title | |
| id: extract-tickets | |
| env: | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| run: | | |
| echo "PR Title: $PR_TITLE" | |
| # Extract the prefix before the first colon (e.g., "H-1234" or "BE-123, FE-456") | |
| PREFIX=$(echo "$PR_TITLE" | cut -d':' -f1) | |
| echo "Prefix: $PREFIX" | |
| # Extract all ticket IDs matching LETTERS-NUMBERS pattern (case-insensitive) | |
| TICKETS=$(echo "$PREFIX" | grep -oiE '[A-Z]+-[0-9]+' | tr '[:lower:]' '[:upper:]' | sort -u | tr '\n' ' ') | |
| if [[ -z "$TICKETS" ]]; then | |
| echo "No ticket IDs found in PR title" | |
| echo "tickets=" >> $GITHUB_OUTPUT | |
| echo "has_tickets=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Found ticket IDs: $TICKETS" | |
| echo "tickets=$TICKETS" >> $GITHUB_OUTPUT | |
| echo "has_tickets=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Ensure ripgrep is installed | |
| if: steps.extract-tickets.outputs.has_tickets == 'true' | |
| run: | | |
| if ! command -v rg &> /dev/null; then | |
| echo "ripgrep not found, installing..." | |
| sudo apt-get update && sudo apt-get install -y ripgrep | |
| fi | |
| echo "ripgrep version: $(rg --version | head -1)" | |
| - name: Search for TODO comments with ticket IDs | |
| id: search-todos | |
| if: steps.extract-tickets.outputs.has_tickets == 'true' | |
| env: | |
| TICKETS: ${{ steps.extract-tickets.outputs.tickets }} | |
| run: | | |
| echo "Searching for TODO comments containing ticket IDs: $TICKETS" | |
| FOUND_TODOS="" | |
| EXIT_CODE=0 | |
| for TICKET in $TICKETS; do | |
| echo "" | |
| echo "==========================================" | |
| echo "Searching for references to $TICKET..." | |
| echo "==========================================" | |
| # Use ripgrep which respects .gitignore by default | |
| # Search for lines containing both "todo" (case-insensitive) and the ticket ID | |
| # This catches all formats: @todo H-1234, TODO(H-1234), todo: H-1234, H-1234 TODO, etc. | |
| # | |
| # Also search for Linear URLs containing the ticket within ~5 lines of a TODO | |
| # This catches multiline patterns like: | |
| # // TODO: fix this | |
| # // see: https://linear.app/hash/issue/H-1234 | |
| # Single-line: any line with both "todo" and the ticket ID | |
| # rg exits with 0 if matches found, 1 if no matches, 2+ on error | |
| SINGLE_LINE=$(rg -in "todo.*${TICKET}|${TICKET}.*todo" .) || { | |
| rc=$? | |
| if [[ $rc -ne 1 ]]; then | |
| echo "::error::ripgrep failed with exit code $rc" | |
| exit $rc | |
| fi | |
| } | |
| # Multiline: TODO within ~5 lines of Linear URL containing the ticket | |
| MULTILINE=$(rg -inU \ | |
| -e "todo[\s\S]{0,300}linear\.app/[^/]+/issue/${TICKET}" \ | |
| -e "linear\.app/[^/]+/issue/${TICKET}[\s\S]{0,300}todo" \ | |
| .) || { | |
| rc=$? | |
| if [[ $rc -ne 1 ]]; then | |
| echo "::error::ripgrep failed with exit code $rc" | |
| exit $rc | |
| fi | |
| } | |
| # Combine and deduplicate results | |
| MATCHES=$(echo -e "${SINGLE_LINE}\n${MULTILINE}" | grep -v '^$' | sort -u) || true | |
| if [[ -n "$MATCHES" ]]; then | |
| echo "::error::Found TODO comments or Linear URLs referencing $TICKET:" | |
| echo "$MATCHES" | |
| FOUND_TODOS="${FOUND_TODOS}### ${TICKET}"$'\n'"${MATCHES}"$'\n\n' | |
| EXIT_CODE=1 | |
| else | |
| echo "No TODO comments found for $TICKET" | |
| fi | |
| done | |
| if [[ $EXIT_CODE -eq 1 ]]; then | |
| echo "" | |
| echo "::error::TODOs associated with tickets in this PR were found in the codebase." | |
| echo "::error::Please resolve these TODOs before merging, as the associated ticket(s) will be marked as done." | |
| echo "" | |
| echo "## Found TODO comments" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "The following TODO comments reference ticket IDs from this PR's title." >> $GITHUB_STEP_SUMMARY | |
| echo "Please resolve these TODOs before merging, as the associated ticket(s) will be marked as done." >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "$FOUND_TODOS" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| exit 1 | |
| fi | |
| echo "No TODO comments found for any ticket IDs in the PR title" |