Skip to content

fix: resolve all lint errors and format code for CI #5

fix: resolve all lint errors and format code for CI

fix: resolve all lint errors and format code for CI #5

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
name: Test & Build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run TypeScript type check
run: npm run type-check
- name: Run ESLint
run: npm run lint
- name: Run tests
run: npm run test:coverage
- name: Check test coverage threshold
run: |
COVERAGE=$(cat coverage/coverage-summary.json | jq '.total.lines.pct')
echo "Coverage: $COVERAGE%"
if (( $(echo "$COVERAGE < 80" | bc -l) )); then
echo "Coverage is below 80%"
exit 1
fi
- name: Build library
run: npm run build
- name: Check bundle size
run: |
SIZE=$(du -sb dist | cut -f1)
GZIP_SIZE=$(gzip -c dist/*.js | wc -c)
GZIP_KB=$((GZIP_SIZE / 1024))
echo "Bundle size (gzipped): ${GZIP_KB}KB"
if [ $GZIP_KB -gt 150 ]; then
echo "Bundle size exceeds 150KB limit"
exit 1
fi
- name: Upload coverage to Codecov
if: matrix.node-version == '20.x'
uses: codecov/codecov-action@v3
with:
files: ./coverage/coverage-final.json
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
lint-format:
name: Lint & Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Check code formatting
run: npx prettier --check "src/**/*.{ts,tsx,css,md}"