Skip to content

updated example picture in readme #16

updated example picture in readme

updated example picture in readme #16

Workflow file for this run

name: CI/CD
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: write
pull-requests: write
jobs:
test:
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: Type check
run: npm run typecheck
- name: Lint
run: npm run lint
- name: Check formatting
run: npm run format:check
- name: Run tests with coverage
run: npm run test:coverage
- name: Upload coverage reports
uses: codecov/codecov-action@v4
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
file: ./coverage/lcov.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
build:
runs-on: ubuntu-latest
needs: test
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: Build
run: npm run build
- name: Test build
run: npm run test:build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
name: build-artifacts
path: lib/
retention-days: 30
update-coverage-badge:
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests with coverage
run: npm run test:coverage
- name: Generate coverage badge
run: |
# Extract coverage percentage from lcov.info
if [ -f coverage/lcov.info ]; then
COVERAGE=$(cat coverage/lcov.info | grep -E "SF:.+\.ts$" | wc -l)
if [ $COVERAGE -gt 0 ]; then
PERCENTAGE=$(cat coverage/lcov.info | grep -E "SF:.+\.ts$" | xargs -I {} sh -c 'grep -A 1 "SF:{}" coverage/lcov.info | tail -1 | cut -d: -f2 | cut -d, -f1' | awk '{sum+=$1} END {print int(sum/NR)}')
else
PERCENTAGE=0
fi
else
echo "Warning: coverage/lcov.info not found"
PERCENTAGE=0
fi
# Determine color based on coverage
if [ $PERCENTAGE -ge 80 ]; then
COLOR=green
elif [ $PERCENTAGE -ge 60 ]; then
COLOR=yellow
else
COLOR=red
fi
# Create badge URL
BADGE_URL="https://img.shields.io/badge/coverage-${PERCENTAGE}%25-${COLOR}"
# Update README with new badge
if [ -f README.md ]; then
sed -i "s|https://img.shields.io/badge/coverage-[0-9]*%25-[a-z]*|${BADGE_URL}|g" README.md
echo "Updated coverage badge to ${PERCENTAGE}%"
else
echo "Warning: README.md not found"
fi
- name: Commit and push changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add README.md
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Update coverage badge [skip ci]"
git push
fi