docs: record the hospital story evidence and the limit on its error h… #298
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
| # ============================================================================= | |
| # TODO Tracker Workflow | |
| # ============================================================================= | |
| # Scans codebase for TODO/FIXME comments and creates GitHub issues. | |
| # Runs weekly and on-demand to ensure no TODOs are forgotten. | |
| # | |
| # Creates issues with: | |
| # - File location and line number | |
| # - TODO context (surrounding code) | |
| # - Labels: todo, needs-triage | |
| # ============================================================================= | |
| name: TODO Tracker | |
| on: | |
| schedule: | |
| # Run weekly on Monday at 9am UTC | |
| - cron: '0 9 * * 1' | |
| workflow_dispatch: | |
| push: | |
| branches: [main] | |
| paths: | |
| - '**/*.go' | |
| - '**/*.ts' | |
| - '**/*.tsx' | |
| permissions: | |
| contents: read | |
| issues: write | |
| jobs: | |
| scan-todos: | |
| name: Scan for TODOs | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Scan for TODO comments | |
| id: todos | |
| run: | | |
| echo "Scanning for TODO/FIXME comments..." | |
| # Create output file | |
| TODOS_FILE=$(mktemp) | |
| # Scan Go files | |
| grep -rn "TODO\|FIXME\|HACK\|XXX" \ | |
| --include="*.go" \ | |
| --exclude-dir=vendor \ | |
| --exclude-dir=.git \ | |
| . >> "$TODOS_FILE" 2>/dev/null || true | |
| # Scan TypeScript/JavaScript files | |
| grep -rn "TODO\|FIXME\|HACK\|XXX" \ | |
| --include="*.ts" \ | |
| --include="*.tsx" \ | |
| --include="*.js" \ | |
| --include="*.jsx" \ | |
| --exclude-dir=node_modules \ | |
| --exclude-dir=dist \ | |
| --exclude-dir=.git \ | |
| . >> "$TODOS_FILE" 2>/dev/null || true | |
| # Count TODOs | |
| TODO_COUNT=$(wc -l < "$TODOS_FILE" | tr -d ' ') | |
| echo "Found $TODO_COUNT TODO items" | |
| echo "count=$TODO_COUNT" >> $GITHUB_OUTPUT | |
| # Save for later steps | |
| echo "todos_file=$TODOS_FILE" >> $GITHUB_OUTPUT | |
| # Output summary | |
| if [ "$TODO_COUNT" -gt 0 ]; then | |
| echo "### TODO Items Found: $TODO_COUNT" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| File | Line | Comment |" >> $GITHUB_STEP_SUMMARY | |
| echo "|------|------|---------|" >> $GITHUB_STEP_SUMMARY | |
| head -50 "$TODOS_FILE" | while IFS=: read -r file line content; do | |
| # Escape pipe characters for markdown | |
| safe_content=$(echo "$content" | sed 's/|/\\|/g' | head -c 100) | |
| echo "| $file | $line | $safe_content |" >> $GITHUB_STEP_SUMMARY | |
| done | |
| if [ "$TODO_COUNT" -gt 50 ]; then | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "_...and $((TODO_COUNT - 50)) more_" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| else | |
| echo "### No TODO items found" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| - name: Check for new TODOs | |
| if: github.event_name == 'push' | |
| run: | | |
| echo "Checking for new TODOs in this commit..." | |
| # Get changed files | |
| git diff --name-only HEAD~1 HEAD 2>/dev/null | while read file; do | |
| if [[ "$file" =~ \.(go|ts|tsx|js|jsx)$ ]]; then | |
| # Check for TODOs in changed lines | |
| git diff HEAD~1 HEAD -- "$file" | grep "^+" | grep -i "TODO\|FIXME" && \ | |
| echo "::warning file=$file::New TODO found in $file" | |
| fi | |
| done || true | |
| - name: Create summary issue (weekly) | |
| if: github.event_name == 'schedule' && steps.todos.outputs.count > 0 | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Check if summary issue already exists this week | |
| WEEK=$(date +%Y-W%V) | |
| EXISTING=$(gh issue list --label "todo" --search "TODO Summary $WEEK" --json number --jq '.[0].number' || echo "") | |
| if [ -n "$EXISTING" ]; then | |
| echo "Summary issue #$EXISTING already exists for this week" | |
| exit 0 | |
| fi | |
| # Create new summary issue | |
| BODY="## Weekly TODO Summary | |
| **Week:** $WEEK | |
| **Total TODOs:** ${{ steps.todos.outputs.count }} | |
| ### Action Required | |
| Please review and either: | |
| 1. Create specific issues for important TODOs | |
| 2. Fix the TODO and remove the comment | |
| 3. Add context if the TODO is intentional | |
| ### TODO Locations | |
| \`\`\` | |
| $(head -100 ${{ steps.todos.outputs.todos_file }}) | |
| \`\`\` | |
| --- | |
| _This issue was automatically created by the TODO Tracker workflow._" | |
| gh issue create \ | |
| --title "TODO Summary $WEEK: ${{ steps.todos.outputs.count }} items" \ | |
| --body "$BODY" \ | |
| --label "todo,needs-triage" |