Skip to content

refactor: comprehensive cleanup and critical bug fixes #387

refactor: comprehensive cleanup and critical bug fixes

refactor: comprehensive cleanup and critical bug fixes #387

Workflow file for this run

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:
runs-on: 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: 🚀 Build
run: pnpm build
- name: 📦 Cache build
uses: actions/cache/save@v4
with:
path: |
dist
node_modules
key: build-${{ github.sha }}
test-unit:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v5
- run: corepack enable
- uses: actions/setup-node@v6
with:
node-version: lts/*
- name: 📦 Restore build
uses: actions/cache/restore@v4
with:
path: |
dist
node_modules
key: build-${{ github.sha }}
- name: 🧪 Test (Unit + Integration)
run: pnpm test:unit --coverage
test-e2e:
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3]
steps:
- uses: actions/checkout@v5
- run: corepack enable
- uses: actions/setup-node@v6
with:
node-version: lts/*
# cache handled via build job
- name: 📦 Restore build
uses: actions/cache/restore@v4
with:
path: |
dist
node_modules
key: build-${{ github.sha }}
- name: 🧪 Test (E2E) - Shard ${{ matrix.shard }}/3
run: pnpm test:e2e --shard=${{ matrix.shard }}/3
coverage-report:
needs: test-unit
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v5
- run: corepack enable
- uses: actions/setup-node@v6
with:
node-version: lts/*
# cache handled via build job
- name: 📦 Restore build
uses: actions/cache/restore@v4
with:
path: |
dist
node_modules
key: build-${{ github.sha }}
- name: 🧪 Generate coverage
run: pnpm test:unit --coverage
- name: 📊 Vitest Coverage Report
uses: davelosert/vitest-coverage-report-action@v2
with:
json-summary-path: ./coverage/coverage-summary.json
json-final-path: ./coverage/coverage-final.json
coverage-badge:
needs: test-unit
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- run: corepack enable
- uses: actions/setup-node@v6
with:
node-version: lts/*
# cache handled via build job
- name: 📦 Restore build
uses: actions/cache/restore@v4
with:
path: |
dist
node_modules
key: build-${{ github.sha }}
- name: 🧪 Generate coverage
run: pnpm test:unit --coverage
- name: 📊 Update coverage badge
run: |
COVERAGE=$(node -e "
const data = require('./coverage/coverage-summary.json');
console.log(Math.round(data.total.lines.pct));
")
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"
sed -i "s|coverage-[0-9]*%25-[a-z]*|coverage-${COVERAGE}%25-${COLOR}|g" README.md
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