Merge phase 1: modern toolchain (still JS) #1
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 ] | |
| pull_request: | |
| jobs: | |
| # tsdown/rolldown require Node >=22.18 to run; vitest requires >=20. The | |
| # published library itself only requires Node >=18 (see `engines` in | |
| # package.json) — that promise is checked separately by `dist-smoke` below, | |
| # against the pre-built output, without needing the build tooling to run. | |
| test: | |
| name: Lint, typecheck, build & unit test (Node ${{ matrix.node-version }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [ 22, 24, latest ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: npm | |
| - run: npm ci | |
| - run: npm run lint | |
| - run: npm run typecheck | |
| - run: npm run build | |
| - run: npm run test:unit | |
| - if: matrix.node-version == 'latest' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist | |
| retention-days: 1 | |
| dist-smoke: | |
| name: Published dist works on Node ${{ matrix.node-version }} | |
| runs-on: ubuntu-latest | |
| needs: test | |
| strategy: | |
| matrix: | |
| node-version: [ 18, 20 ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: npm | |
| - run: npm ci --omit=dev | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist | |
| - run: | | |
| node -e " | |
| const WPAPI = require('./dist/index.cjs'); | |
| const wp = new WPAPI({ endpoint: 'http://localhost/wp-json' }); | |
| if (typeof wp.posts !== 'function') throw new Error('CJS entry did not bootstrap'); | |
| " | |
| node --input-type=module -e " | |
| import WPAPI from './dist/index.mjs'; | |
| const wp = new WPAPI({ endpoint: 'http://localhost/wp-json' }); | |
| if (typeof wp.posts !== 'function') throw new Error('ESM entry did not bootstrap'); | |
| " | |
| integration: | |
| name: Integration tests (wp-env) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - run: npm ci | |
| - run: npm run env:start | |
| - run: npm run env:seed | |
| - run: npm run test:integration | |
| # `npm run env:logs` defaults to `--watch`, which never exits; pass | |
| # `--no-watch` directly so this step prints once and completes. | |
| - if: always() | |
| run: npx @wordpress/env logs development --no-watch | |
| - if: always() | |
| run: npm run env:stop |