Bump the npm-minor-and-patch group across 1 directory with 17 updates #602
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: CI | |
| on: | |
| pull_request: | |
| branches: [main] | |
| paths-ignore: | |
| - '**/*.md' | |
| - 'docs/**' | |
| push: | |
| branches: [main] | |
| paths-ignore: | |
| - '**/*.md' | |
| - 'docs/**' | |
| concurrency: | |
| group: ci-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| lint-and-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run lint checks | |
| run: npm run lint | |
| - name: Run Jest tests with coverage | |
| run: npm run test:coverage | |
| - name: Upload coverage artifacts | |
| if: always() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 | |
| with: | |
| name: coverage | |
| path: coverage | |
| if-no-files-found: warn | |
| - name: Comment test coverage on PR | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const marker = '<!-- unit-test-coverage -->'; | |
| let coverageText = 'Coverage summary unavailable.'; | |
| if (fs.existsSync('coverage/coverage-summary.json')) { | |
| const coverage = JSON.parse(fs.readFileSync('coverage/coverage-summary.json', 'utf8')); | |
| const total = coverage.total || {}; | |
| const lines = total.lines?.pct ?? 'n/a'; | |
| const statements = total.statements?.pct ?? 'n/a'; | |
| const branches = total.branches?.pct ?? 'n/a'; | |
| const functions = total.functions?.pct ?? 'n/a'; | |
| coverageText = [ | |
| '### Unit Test Coverage', | |
| '', | |
| '| Metric | Coverage |', | |
| '| --- | ---: |', | |
| `| Lines | ${lines}% |`, | |
| `| Statements | ${statements}% |`, | |
| `| Branches | ${branches}% |`, | |
| `| Functions | ${functions}% |`, | |
| ].join('\n'); | |
| } | |
| const body = `${marker}\n${coverageText}`; | |
| const { owner, repo } = context.repo; | |
| const issue_number = context.issue.number; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner, | |
| repo, | |
| issue_number, | |
| }); | |
| const existing = comments.find((comment) => | |
| comment.user.type === 'Bot' && comment.body.includes(marker) | |
| ); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner, | |
| repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number, | |
| body, | |
| }); | |
| } |