Skip to content

test: Implement frontend component tests for core UI (#294) #155

test: Implement frontend component tests for core UI (#294)

test: Implement frontend component tests for core UI (#294) #155

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
issues: write
pull-requests: write
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install root dependencies
run: npm install
- name: Install app dependencies
run: cd app && npm install
- name: Install api dependencies
run: cd api && npm install
- name: Install sdk dependencies
run: cd xstreamroll-sdk && npm install
- name: Install processing dependencies
run: cd xstreamroll-processing && npm install
- name: Lint — api
run: cd api && npm run lint
env:
DATABASE_URL: postgresql://test:test@localhost:5432/test
JWT_SECRET: test-secret
STREAM_API_KEY: test-api-key
- name: Lint — sdk
run: cd xstreamroll-sdk && npm run lint
- name: Lint — processing
run: cd xstreamroll-processing && npm run lint
- name: Lint — app
run: cd app && npm run lint
- name: Typecheck — api
run: cd api && npx tsc --noEmit
- name: Typecheck — sdk
run: cd xstreamroll-sdk && npx tsc --noEmit
- name: Typecheck — processing
run: cd xstreamroll-processing && npx tsc --noEmit
- name: Typecheck — app
run: cd app && npx tsc --noEmit
- name: Test — api (with coverage)
run: cd api && npm run test:cov
env:
DATABASE_URL: postgresql://test:test@localhost:5432/test
JWT_SECRET: test-secret
STREAM_API_KEY: test-api-key
- name: Test — sdk (with coverage)
run: cd xstreamroll-sdk && npm run test:cov
- name: Test — processing (with coverage)
run: cd xstreamroll-processing && npm run test:cov
- name: Test — app (with coverage)
run: cd app && npm run test:cov
- name: Upload api coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./api/coverage/lcov.info
flags: api
name: api-coverage
fail_ci_if_error: false
- name: Upload sdk coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./xstreamroll-sdk/coverage/lcov.info
flags: sdk
name: sdk-coverage
fail_ci_if_error: false
- name: Upload processing coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./xstreamroll-processing/coverage/lcov.info
flags: processing
name: processing-coverage
fail_ci_if_error: false
- name: Upload app coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./app/coverage/lcov.info
flags: app
name: app-coverage
fail_ci_if_error: false
bundle-analysis:
runs-on: ubuntu-latest
needs: quality
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install app dependencies
run: cd app && npm install
- name: Build app with analysis
run: cd app && npm run analyze
- name: List analyzer output
run: ls -la app/.next || true; ls -la app/.next/analyze || true
- name: Check bundle sizes
run: node .github/scripts/check-bundle-size.js
env:
BUNDLE_BUDGET_TOTAL: 5000000
BUNDLE_BUDGET_PER_LARGEST: 500000
- name: Upload analyzer artifacts
uses: actions/upload-artifact@v4
with:
name: app-bundle-analysis
path: app/.next/analyze
- name: Upload bundle summary
uses: actions/upload-artifact@v4
with:
name: app-bundle-summary
path: app/.next/analyze/summary.json
- name: Comment PR with summary
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v6
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const path = 'app/.next/analyze/summary.json';
if (fs.existsSync(path)) {
const summary = JSON.parse(fs.readFileSync(path, 'utf8'));
const body = `Bundle analysis summary:\n\n- Total JS size: ${summary.totalBytes} bytes\n- Largest file: ${summary.largestFile} (${summary.largestBytes} bytes)\n\nArtifacts: app-bundle-analysis`;
github.rest.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
});
} else {
console.log('No summary available')
}