chore: prepare repo for open-source release #88
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: Test & Coverage | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| test: | |
| name: Run Tests & Coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js 20 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9.7.0 | |
| - name: Authenticate npm registry | |
| run: echo "//registry.npmjs.org/:_authToken=${{ secrets.TEST_NPM_TOKEN }}" > ~/.npmrc | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build packages | |
| run: pnpm build | |
| # ── Bundle size budget ────────────────────────────────────── | |
| # Fail if the react-elements ESM bundle exceeds 60KB. | |
| # Current size: ~49KB (14+ components). Budget gives room for | |
| # growth but catches accidental dependency bundling. | |
| - name: Check bundle size | |
| run: | | |
| BUNDLE="packages/react/dist/index.js" | |
| SIZE=$(wc -c < "$BUNDLE" | tr -d ' ') | |
| MAX_SIZE=60000 | |
| echo "Bundle: $BUNDLE" | |
| echo "Size: $SIZE bytes (budget: $MAX_SIZE bytes)" | |
| if [ "$SIZE" -gt "$MAX_SIZE" ]; then | |
| echo "::error::Bundle size $SIZE exceeds budget of $MAX_SIZE bytes" | |
| exit 1 | |
| fi | |
| echo "✅ Bundle size within budget" | |
| - name: Run tests | |
| run: pnpm test | |
| - name: Run test coverage | |
| run: pnpm test:coverage | |
| # ── Next.js integration test ──────────────────────────────── | |
| # Packs the built react-elements as a tarball and installs it | |
| # in a real Next.js app — exactly like a consumer would. | |
| # Catches SSR, bundling, and Server Component compatibility issues | |
| # that unit tests can't detect. | |
| - name: Pack react-elements | |
| run: | | |
| cd packages/react | |
| pnpm pack --pack-destination /tmp | |
| echo "TARBALL=$(ls /tmp/unlayer-react-elements-*.tgz)" >> $GITHUB_ENV | |
| - name: Next.js integration build | |
| run: | | |
| cd tests/nextjs-integration | |
| npm install "$TARBALL" | |
| npm run build | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: false | |
| verbose: true | |
| - name: Upload coverage artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-reports | |
| path: | | |
| packages/*/coverage/ | |
| coverage/ | |
| retention-days: 30 |