Implement comprehensive CI/CD pipeline and project infrastructure #4
Workflow file for this run
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 Quality Check | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| pr-quality: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20.x" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Check PR title format | |
| run: | | |
| PR_TITLE="${{ github.event.pull_request.title }}" | |
| if [[ ! "$PR_TITLE" =~ ^(feat|fix|docs|style|refactor|test|chore|perf|ci)(\(.+\))?: .+ ]]; then | |
| echo "::error::PR title must follow conventional commits format: type(scope): description" | |
| exit 1 | |
| fi | |
| - name: Check for large files | |
| run: | | |
| find . -type f -size +1M -not -path "./node_modules/*" -not -path "./.git/*" | while read file; do | |
| echo "::warning::Large file detected: $file ($(du -h "$file" | cut -f1))" | |
| done | |
| - name: Lint commit messages | |
| run: | | |
| if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then | |
| git log --oneline HEAD~1..HEAD | while read line; do | |
| if [[ ! "$line" =~ ^[a-f0-9]+\ (feat|fix|docs|style|refactor|test|chore|perf|ci)(\(.+\))?: ]]; then | |
| echo "::warning::Commit message should follow conventional commits: $line" | |
| fi | |
| done | |
| fi | |
| - name: Check code coverage impact | |
| run: | | |
| npm run test:coverage | |
| echo "Coverage report generated - review coverage/lcov-report/index.html" | |
| - name: Comment PR with coverage | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| const fs = require("fs"); | |
| if (fs.existsSync("coverage/coverage-summary.json")) { | |
| const coverage = JSON.parse(fs.readFileSync("coverage/coverage-summary.json")); | |
| const total = coverage.total; | |
| const comment = `## Test Coverage Report | |
| | Metric | Percentage | Covered/Total | | |
| |--------|------------|---------------| | |
| | Lines | ${total.lines.pct}% | ${total.lines.covered}/${total.lines.total} | | |
| | Functions | ${total.functions.pct}% | ${total.functions.covered}/${total.functions.total} | | |
| | Branches | ${total.branches.pct}% | ${total.branches.covered}/${total.branches.total} | | |
| | Statements | ${total.statements.pct}% | ${total.statements.covered}/${total.statements.total} | | |
| Coverage thresholds: 70% minimum for all metrics.`; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); | |
| } | |