feat(CHR-1): Complete self-contained Chronicle with local SQLite backend #10
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: PR Coverage Comment | |
| on: | |
| pull_request: | |
| types: [opened, synchronize] | |
| jobs: | |
| coverage-comment: | |
| name: π¬ Coverage Comment | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: π Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: π¦ Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: π₯ Install root dependencies | |
| run: npm ci | |
| - name: π Setup Dashboard | |
| working-directory: apps/dashboard | |
| run: | | |
| npm ci | |
| npm run test -- --coverage --watchAll=false --passWithNoTests | |
| continue-on-error: true | |
| - name: π Setup Python with uv | |
| uses: astral-sh/setup-uv@v3 | |
| with: | |
| version: "latest" | |
| - name: πͺ Setup Hooks | |
| working-directory: apps/hooks | |
| run: | | |
| uv python install 3.11 | |
| uv sync | |
| uv run pytest --cov=src --cov-report=json --cov-report=lcov || true | |
| continue-on-error: true | |
| - name: π Generate coverage analysis | |
| run: | | |
| npm run coverage:report || true | |
| npm run coverage:badges || true | |
| - name: π¬ Post coverage comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| let dashboardCoverage = null; | |
| let hooksCoverage = null; | |
| let dashboardStatus = 'β'; | |
| let hooksStatus = 'β'; | |
| // Try to read dashboard coverage | |
| try { | |
| const dashboardData = JSON.parse(fs.readFileSync('apps/dashboard/coverage/coverage-summary.json', 'utf8')); | |
| dashboardCoverage = dashboardData.total.lines.pct; | |
| dashboardStatus = dashboardCoverage >= 80 ? 'β ' : 'β'; | |
| } catch (error) { | |
| console.log('Dashboard coverage not available:', error.message); | |
| dashboardStatus = 'β οΈ'; | |
| } | |
| // Try to read hooks coverage | |
| try { | |
| const hooksData = JSON.parse(fs.readFileSync('apps/hooks/coverage.json', 'utf8')); | |
| hooksCoverage = hooksData.totals.percent_covered; | |
| hooksStatus = hooksCoverage >= 60 ? 'β ' : 'β'; | |
| } catch (error) { | |
| console.log('Hooks coverage not available:', error.message); | |
| hooksStatus = 'β οΈ'; | |
| } | |
| // Calculate overall status | |
| const overallPassing = dashboardStatus === 'β ' && hooksStatus === 'β '; | |
| const overallStatus = overallPassing ? 'π All coverage thresholds met!' : | |
| (dashboardStatus === 'β οΈ' || hooksStatus === 'β οΈ') ? | |
| 'β οΈ Coverage data unavailable' : | |
| 'π¨ Coverage thresholds not met'; | |
| const comment = `## π Coverage Report | |
| | Component | Coverage | Threshold | Status | | |
| |-----------|----------|-----------|--------| | |
| | π Dashboard | ${dashboardCoverage ? dashboardCoverage.toFixed(1) + '%' : 'N/A'} | 80% | ${dashboardStatus} | | |
| | πͺ Hooks | ${hooksCoverage ? hooksCoverage.toFixed(1) + '%' : 'N/A'} | 60% | ${hooksStatus} | | |
| ${overallStatus} | |
| ### π Coverage Details | |
| ${dashboardCoverage ? `- **Dashboard**: ${dashboardCoverage.toFixed(1)}% line coverage` : '- **Dashboard**: Coverage data not available'} | |
| ${hooksCoverage ? `- **Hooks**: ${hooksCoverage.toFixed(1)}% line coverage` : '- **Hooks**: Coverage data not available'} | |
| ### π Next Steps | |
| ${!overallPassing ? ` | |
| **To improve coverage:** | |
| \`\`\`bash | |
| # Run coverage locally | |
| npm run test:coverage | |
| # Check specific coverage | |
| npm run test:coverage:dashboard | |
| npm run test:coverage:hooks | |
| # Generate detailed reports | |
| npm run coverage:report | |
| \`\`\` | |
| π See [Coverage Guide](./docs/guides/coverage.md) for detailed instructions. | |
| ` : 'β¨ Great work! All coverage requirements are met.'} | |
| --- | |
| *π€ This comment is automatically updated when coverage changes.*`; | |
| // Find existing comment | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const existingComment = comments.find(comment => | |
| comment.body.includes('π Coverage Report') && comment.user.type === 'Bot' | |
| ); | |
| if (existingComment) { | |
| // Update existing comment | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existingComment.id, | |
| body: comment | |
| }); | |
| } else { | |
| // Create new comment | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: comment | |
| }); | |
| } |