-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (48 loc) · 1.94 KB
/
ci.yml
File metadata and controls
55 lines (48 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: CI
on: [push]
jobs:
build:
name: Build, Lint, & Test Project
runs-on: ubuntu-latest
outputs:
coverage: ${{ steps.coverage.outputs.coverage }}
steps:
# Download the repository code to the GitHub Actions runner
- name: Checkout repository
uses: actions/checkout@v4
# Install pnpm package manager which is used by this project
# This ensures we use the same package manager as in development
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: "10.13.1"
# Install Node.js runtime and configure NPM registry authentication
# Cache pnpm dependencies to speed up future workflow runs
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22.17.1"
registry-url: "https://registry.npmjs.org"
cache: 'pnpm'
# Install all project dependencies using pnpm
- name: Install dependencies
run: pnpm install
# Build the package and prepare it for publishing
# This runs the build script that builds the ESM/CJS versions and copies files
- name: Build package for publishing
run: pnpm run build
# Run code linting to check for style and quality issues
- name: Run linter
run: pnpm run lint
# Run tests with coverage reporting and export coverage percentage
- name: Run tests
id: coverage
run: |
pnpm vitest run --coverage
COVERAGE=$(cat ./coverage/coverage-summary.json | jq '.total.statements.pct')
echo "Coverage: ${COVERAGE}%"
echo "coverage=${COVERAGE}" >> $GITHUB_OUTPUT
# Update coverage badge with the test coverage percentage (main branch only)
- name: Update coverage badge
if: github.ref == 'refs/heads/main'
run: curl -I "https://badge.egjiri.com/node-kit?coverage=${{ steps.coverage.outputs.coverage }}&token=${{ secrets.BADGE_API_KEY }}"