name: 'Pull Request' on: pull_request: types: [opened, reopened, synchronize] jobs: # Build the dual CJS/ESM output once on a modern Node (the SWC toolchain requires # Node >= 16.14), then share dist/ with the test matrix so older Node versions are # exercised against the compiled runtime without having to run the build themselves. build: name: 'Build' runs-on: ubuntu-latest steps: - name: 'Checkout latest code' uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} - name: Set up node uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' - name: Install dependencies run: npm ci --ignore-scripts - name: Build dist (CJS + ESM) run: npm run build - name: Type check run: npm run test:types - name: Upload dist uses: actions/upload-artifact@v4 with: name: dist path: dist/ retention-days: 1 test: name: Node ${{ matrix.node }} needs: build runs-on: ubuntu-latest strategy: matrix: node: [14, 16, 18, 20, 22] steps: - name: 'Checkout latest code' uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} - name: Set up node uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} cache: 'npm' - name: Install NPM (if node 14) run: if [ "${{ matrix.node }}" == "14" ]; then npm install -g npm@9; fi - name: Install dependencies run: npm ci --ignore-scripts - name: Download prebuilt dist uses: actions/download-artifact@v4 with: name: dist path: dist/ - name: Run tests against prebuilt dist run: npm run test:prebuilt lint: name: 'ESLint' runs-on: ubuntu-latest steps: - name: Checkout latest code uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} - name: Set up node uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' - name: Install dependencies run: npm ci --ignore-scripts - name: Run ESLint run: npm run lint:check prettier: name: 'Prettier' runs-on: ubuntu-latest steps: - name: Checkout latest code uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} - name: Set up node uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' - name: Install dependencies run: npm ci --ignore-scripts - name: Run Prettier run: npm run prettier:check