Dev #119
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 | |
on: | |
push: | |
branches: [main, dev] | |
pull_request: | |
branches: [main, dev] | |
workflow_dispatch: | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x, 22.x] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v5 | |
- 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 tests | |
run: npm test -- --run --reporter=verbose --reporter=junit --outputFile=test-report.junit.xml | |
- name: Upload test results to Codecov | |
if: ${{ !cancelled() }} | |
uses: codecov/test-results-action@v1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Upload test results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-results-${{ matrix.node-version }} | |
path: | | |
coverage/ | |
test-results/ | |
test-report.junit.xml | |
retention-days: 7 | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v5 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
- name: Run ESLint | |
run: npm run lint | |
- name: Check TypeScript | |
run: npx tsc --noEmit | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x, 22.x] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v5 | |
- 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: Build production | |
run: npm run build | |
- name: Build development | |
run: npm run build:dev | |
- name: Check build output | |
run: | | |
if [ ! -d "dist" ]; then | |
echo "Build failed: dist directory not found" | |
exit 1 | |
fi | |
echo "Build successful! Contents of dist:" | |
ls -la dist/ | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-${{ matrix.node-version }} | |
path: dist/ | |
retention-days: 7 | |
size-check: | |
name: Bundle Size Check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v5 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
- name: Build and analyze bundle | |
run: | | |
npm run build | |
echo "## Bundle Size Report" >> $GITHUB_STEP_SUMMARY | |
echo "| File | Size | Gzipped |" >> $GITHUB_STEP_SUMMARY | |
echo "|------|------|---------|" >> $GITHUB_STEP_SUMMARY | |
for file in dist/assets/*.js; do | |
if [ -f "$file" ]; then | |
size=$(du -h "$file" | cut -f1) | |
gzipped=$(gzip -c "$file" | wc -c | numfmt --to=iec) | |
filename=$(basename "$file") | |
echo "| $filename | $size | $gzipped |" >> $GITHUB_STEP_SUMMARY | |
fi | |
done | |
for file in dist/assets/*.css; do | |
if [ -f "$file" ]; then | |
size=$(du -h "$file" | cut -f1) | |
gzipped=$(gzip -c "$file" | wc -c | numfmt --to=iec) | |
filename=$(basename "$file") | |
echo "| $filename | $size | $gzipped |" >> $GITHUB_STEP_SUMMARY | |
fi | |
done |