build(deps): bump the keeper-deps group across 1 directory with 5 updates #8
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: Code Coverage | |
| on: | |
| pull_request: | |
| branches: [main, develop] | |
| push: | |
| branches: [main, develop] | |
| concurrency: | |
| group: coverage-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| coverage: | |
| name: Generate Coverage Reports | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # ============== RUST COVERAGE ============== | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Rust | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: contract | |
| - name: Install tarpaulin | |
| run: cargo install cargo-tarpaulin --locked | |
| continue-on-error: true | |
| - name: Generate Rust coverage | |
| working-directory: contract | |
| run: | | |
| mkdir -p ../coverage/rust | |
| cargo tarpaulin \ | |
| --out Xml \ | |
| --output-dir ../coverage/rust \ | |
| --timeout 600 \ | |
| --exclude-files "fuzz/*" \ | |
| --skip-clean \ | |
| --lib \ | |
| --tests \ | |
| --release 2>&1 || echo "⚠️ Rust coverage generation encountered errors (pre-existing codebase issues). This is expected and will be fixed." | |
| continue-on-error: true | |
| # ============== NODE.JS COVERAGE ============== | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install root dependencies | |
| run: npm ci | |
| - name: Install frontend dependencies | |
| working-directory: frontend | |
| run: npm ci | |
| - name: Generate frontend coverage | |
| working-directory: frontend | |
| run: npm run test:coverage | |
| continue-on-error: true | |
| - name: Create coverage directories | |
| run: | | |
| mkdir -p coverage/frontend | |
| mkdir -p coverage/rust | |
| - name: Move frontend coverage to root | |
| run: | | |
| if [ -d "frontend/coverage" ]; then | |
| cp -r frontend/coverage/* coverage/frontend/ || true | |
| fi | |
| shell: bash | |
| # ============== CODECOV UPLOAD ============== | |
| - name: Upload Rust coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./coverage/rust/cobertura.xml | |
| flags: rust | |
| name: rust-coverage | |
| fail_ci_if_error: false | |
| verbose: true | |
| - name: Upload frontend coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./coverage/frontend/coverage-final.json | |
| flags: frontend | |
| name: frontend-coverage | |
| fail_ci_if_error: false | |
| verbose: true | |
| # ============== PR COMMENT ============== | |
| - name: Comment PR with coverage summary | |
| if: github.event_name == 'pull_request' && always() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| let coverageComment = '## 📊 Code Coverage Report\n\n'; | |
| let hasContent = false; | |
| let rustAvailable = false; | |
| // Parse Rust coverage | |
| try { | |
| const xmlPath = './coverage/rust/cobertura.xml'; | |
| if (fs.existsSync(xmlPath)) { | |
| const xml = fs.readFileSync(xmlPath, 'utf8'); | |
| const lineRateMatch = xml.match(/line-rate="([\d.]+)"/); | |
| const branchRateMatch = xml.match(/branch-rate="([\d.]+)"/); | |
| if (lineRateMatch || branchRateMatch) { | |
| coverageComment += '### 🦀 Rust Backend (Contract)\n'; | |
| if (lineRateMatch) { | |
| const lineCoverage = (parseFloat(lineRateMatch[1]) * 100).toFixed(2); | |
| coverageComment += `- **Line Coverage**: ${lineCoverage}%\n`; | |
| } | |
| if (branchRateMatch) { | |
| const branchCoverage = (parseFloat(branchRateMatch[1]) * 100).toFixed(2); | |
| coverageComment += `- **Branch Coverage**: ${branchCoverage}%\n`; | |
| } | |
| coverageComment += '\n'; | |
| hasContent = true; | |
| rustAvailable = true; | |
| } | |
| } | |
| } catch (e) { | |
| console.log('Rust coverage not available'); | |
| } | |
| if (!rustAvailable) { | |
| coverageComment += '### 🦀 Rust Backend (Contract)\n⚠️ **Status**: Build errors in codebase - coverage not available\n_Will be enabled once contract code is updated_\n\n'; | |
| } | |
| // Parse Node.js coverage | |
| try { | |
| const summaryPath = './coverage/frontend/coverage-summary.json'; | |
| if (fs.existsSync(summaryPath)) { | |
| const summary = JSON.parse(fs.readFileSync(summaryPath, 'utf8')); | |
| const total = summary.total; | |
| coverageComment += '### 📱 Frontend (Next.js)\n'; | |
| coverageComment += `- **Statements**: ${total.statements.pct}%\n`; | |
| coverageComment += `- **Branches**: ${total.branches.pct}%\n`; | |
| coverageComment += `- **Functions**: ${total.functions.pct}%\n`; | |
| coverageComment += `- **Lines**: ${total.lines.pct}%\n\n`; | |
| hasContent = true; | |
| } | |
| } catch (e) { | |
| console.log('Frontend coverage not available'); | |
| } | |
| if (hasContent) { | |
| coverageComment += `---\n[View detailed report on Codecov](https://codecov.io/gh/${{ github.repository }}/pull/${{ github.event.number }})`; | |
| // Find or create bot comment | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const botComment = comments.find(comment => | |
| comment.user.type === 'Bot' && | |
| comment.body && | |
| comment.body.includes('Code Coverage Report') | |
| ); | |
| if (botComment) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body: coverageComment, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: coverageComment, | |
| }); | |
| } | |
| } |