test: add unit tests for file watcher setup module #291
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 | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - 'docs/**' | |
| pull_request: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - 'docs/**' | |
| jobs: | |
| build-test: | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| # Required to checkout the code | |
| contents: read | |
| # Required to put a comment into the pull-request | |
| pull-requests: write | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - run: corepack enable | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: lts/* | |
| cache: pnpm | |
| - name: 📦 Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: 👀 Lint | |
| run: pnpm lint | |
| - name: 🧪 Test | |
| run: pnpm test:run --coverage | |
| - name: 📊 Vitest Coverage Report | |
| uses: davelosert/vitest-coverage-report-action@v2 | |
| if: github.event_name == 'pull_request' | |
| with: | |
| json-summary-path: ./coverage/coverage-summary.json | |
| json-final-path: ./coverage/coverage-final.json | |
| - name: 📊 Update coverage badge | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| run: | | |
| # Extract coverage percentage | |
| COVERAGE=$(node -e " | |
| const data = require('./coverage/coverage-summary.json'); | |
| console.log(Math.round(data.total.lines.pct)); | |
| ") | |
| # Determine badge color | |
| if [ "$COVERAGE" -ge 80 ]; then | |
| COLOR="brightgreen" | |
| elif [ "$COVERAGE" -ge 60 ]; then | |
| COLOR="green" | |
| elif [ "$COVERAGE" -ge 40 ]; then | |
| COLOR="yellow" | |
| else | |
| COLOR="red" | |
| fi | |
| echo "Coverage: $COVERAGE%, Color: $COLOR" | |
| # Update README | |
| sed -i "s|coverage-[0-9]*%25-[a-z]*|coverage-${COVERAGE}%25-${COLOR}|g" README.md | |
| # Check if changed | |
| if git diff --quiet README.md; then | |
| echo "No coverage change" | |
| else | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add README.md | |
| git commit -m "chore: update coverage badge to ${COVERAGE}%" | |
| git push | |
| fi | |
| - name: 🚀 Build | |
| run: pnpm build |