|
| 1 | +name: Test Build Artifacts |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master, 'feat/**', 'fix/**', 'ci/**'] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +jobs: |
| 9 | + test: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + format: [cjs, esm] |
| 15 | + |
| 16 | + name: Artifact — ${{ matrix.format }} |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Setup Node |
| 22 | + uses: actions/setup-node@v4 |
| 23 | + with: |
| 24 | + node-version: 20.x |
| 25 | + cache: 'yarn' |
| 26 | + |
| 27 | + - name: Install dependencies |
| 28 | + run: yarn install --frozen-lockfile |
| 29 | + |
| 30 | + - name: Build |
| 31 | + run: yarn build |
| 32 | + |
| 33 | + - name: Smoke test CJS artifact |
| 34 | + if: matrix.format == 'cjs' |
| 35 | + run: | |
| 36 | + node -e " |
| 37 | + const m = require('./dist/index.js'); |
| 38 | + const component = m.default || m; |
| 39 | + if (typeof component !== 'function') { |
| 40 | + console.error('CJS default export is not a function, got:', typeof component); |
| 41 | + process.exit(1); |
| 42 | + } |
| 43 | + console.log('CJS OK — default export is a function'); |
| 44 | + " |
| 45 | +
|
| 46 | + - name: Smoke test ESM artifact |
| 47 | + if: matrix.format == 'esm' |
| 48 | + run: | |
| 49 | + # Verify ES module syntax is present (export keyword) and file is non-empty. |
| 50 | + # A full dynamic import would require React as an ESM peer which varies by version, |
| 51 | + # so we validate structure and let the React-version matrix cover runtime behaviour. |
| 52 | + if ! grep -q "^export " dist/index.es.js; then |
| 53 | + echo "ESM artifact missing top-level export statement" |
| 54 | + exit 1 |
| 55 | + fi |
| 56 | + echo "ESM OK — top-level export found" |
| 57 | + node -e " |
| 58 | + const fs = require('fs'); |
| 59 | + const size = fs.statSync('./dist/index.es.js').size; |
| 60 | + if (size < 100) { console.error('ESM artifact suspiciously small:', size, 'bytes'); process.exit(1); } |
| 61 | + console.log('ESM artifact size OK:', size, 'bytes'); |
| 62 | + " |
| 63 | +
|
| 64 | + - name: Type declarations exist |
| 65 | + run: | |
| 66 | + if [ ! -f dist/index.d.ts ]; then |
| 67 | + echo "dist/index.d.ts is missing" |
| 68 | + exit 1 |
| 69 | + fi |
| 70 | + echo "Type declarations OK" |
0 commit comments