|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ['**'] # run on pushes to all branches |
| 6 | + paths: |
| 7 | + - 'src/**' |
| 8 | + - 'plugins/**' |
| 9 | + - 'examples/**' |
| 10 | + - 'tests/**' |
| 11 | + - 'package.json' |
| 12 | + - 'vite.config.js' |
| 13 | + - 'vitest.config.js' |
| 14 | + - '.github/workflows/**' |
| 15 | + pull_request: |
| 16 | + branches: ['**'] # run on PRs against any branch |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: ci-${{ github.ref }} |
| 20 | + cancel-in-progress: true |
| 21 | + |
| 22 | +jobs: |
| 23 | + # Primary job: format/lint, webpack build, then tests with coverage. |
| 24 | + build-and-test: |
| 25 | + runs-on: ubuntu-24.04 |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Setup Node.js (from .nvmrc) |
| 31 | + uses: actions/setup-node@v4 |
| 32 | + with: |
| 33 | + node-version-file: .nvmrc |
| 34 | + cache: npm |
| 35 | + |
| 36 | + - name: Install dependencies |
| 37 | + run: | |
| 38 | + if [ -f package-lock.json ]; then |
| 39 | + npm ci |
| 40 | + else |
| 41 | + npm install |
| 42 | + fi |
| 43 | +
|
| 44 | + - name: Prettier check |
| 45 | + run: npm run format-check |
| 46 | + |
| 47 | + - name: ESLint |
| 48 | + run: npm run lint |
| 49 | + |
| 50 | + # Use the webpack build for CI stability (dist via webpack) |
| 51 | + - name: Build (webpack) |
| 52 | + run: npm run build |
| 53 | + |
| 54 | + - name: Run tests (with coverage) |
| 55 | + run: npm run test:coverage |
| 56 | + env: |
| 57 | + CI: true |
| 58 | + |
| 59 | + - name: Upload coverage artifact |
| 60 | + if: always() |
| 61 | + uses: actions/upload-artifact@v4 |
| 62 | + with: |
| 63 | + name: coverage |
| 64 | + path: coverage |
| 65 | + if-no-files-found: ignore |
| 66 | + |
| 67 | + # Secondary job: attempt Vite build with mitigations; doesn't fail the PR if it breaks. |
| 68 | + vite-build-linux: |
| 69 | + runs-on: ubuntu-24.04 |
| 70 | + continue-on-error: true |
| 71 | + needs: build-and-test |
| 72 | + steps: |
| 73 | + - name: Checkout |
| 74 | + uses: actions/checkout@v4 |
| 75 | + |
| 76 | + - name: Setup Node.js (from .nvmrc) |
| 77 | + uses: actions/setup-node@v4 |
| 78 | + with: |
| 79 | + node-version-file: .nvmrc |
| 80 | + cache: npm |
| 81 | + |
| 82 | + - name: Install dependencies |
| 83 | + run: | |
| 84 | + if [ -f package-lock.json ]; then |
| 85 | + npm ci |
| 86 | + else |
| 87 | + npm install |
| 88 | + fi |
| 89 | +
|
| 90 | + - name: Diagnostics (platform and rollup) |
| 91 | + run: | |
| 92 | + node -e "console.log('platform:', process.platform, 'arch:', process.arch, 'node:', process.version)" |
| 93 | + npm ls rollup @rollup/rollup-linux-x64-gnu vite || true |
| 94 | +
|
| 95 | + # Workaround: ensure Linux native binary is present. Harmless if already resolved. |
| 96 | + - name: Ensure rollup native linux package |
| 97 | + run: npm i -D @rollup/rollup-linux-x64-gnu@^4 || true |
| 98 | + |
| 99 | + - name: Vite build (library) |
| 100 | + run: npm run build:vite |
| 101 | + env: |
| 102 | + # Ask rollup to use JS fallback if native optional dep is still missing |
| 103 | + ROLLUP_SKIP_NODEJS_NATIVE: '1' |
0 commit comments