name: D1 stress # #190: runs the Miniflare halves (D1, Durable Object SQLite, R2) of every package that tests with # the pinned Miniflare, many times on fresh runners, under the same load as CI # (`turbo --concurrency=2`). Run it by hand after a Miniflare bump or a change to its patch # (ADR-0012, addendum 2026-11-10); pull requests that touch the patch run it on their own. on: workflow_dispatch: inputs: runs: description: Runs per Node version type: number default: 10 hogs: description: Busy loops beside the tests (0 = CI's own load) type: number default: 4 pull_request: paths: - patches/miniflare@*.patch - .github/workflows/d1-stress.yml permissions: contents: read concurrency: group: d1-stress-${{ github.ref }} cancel-in-progress: true jobs: plan: runs-on: ubuntu-latest outputs: runs: ${{ steps.runs.outputs.runs }} steps: - id: runs env: # `github.event.inputs` holds strings, so a typed 0 stays "0" (truthy) and is not replaced # by the default; pull requests have no inputs and take the default. RUNS: ${{ github.event.inputs.runs || '10' }} run: | echo "runs=$(jq -nc --argjson n "$RUNS" '[range(1; ([[$n, 50] | min, 1] | max) + 1)]')" >> "$GITHUB_OUTPUT" d1: name: D1 halves (Node ${{ matrix.node }}, run ${{ matrix.run }}) needs: plan runs-on: ubuntu-latest timeout-minutes: 30 strategy: fail-fast: false # Leave concurrent-job slots for other pull requests' CI. max-parallel: 10 matrix: node: [24, 26] run: ${{ fromJSON(needs.plan.outputs.runs) }} steps: - uses: actions/checkout@v7 - uses: pnpm/action-setup@v6 - uses: actions/setup-node@v7 with: node-version: ${{ matrix.node }} cache: pnpm - run: pnpm install --frozen-lockfile # CI's test step (`turbo --concurrency=2`), plus one busy loop per vCPU: the proxy race needs a # preempted thread, and an oversubscribed runner preempts far more often than a quiet one. # `-t` keeps only the suites labelled "(Miniflare)". - name: Miniflare halves on an oversubscribed runner env: HOGS: ${{ github.event.inputs.hogs || '4' }} run: | for _ in $(seq "$HOGS"); do sh -c 'while :; do :; done' & done trap 'kill $(jobs -p) 2>/dev/null' EXIT pnpm turbo run test --concurrency=2 \ --filter=@cloudhal/storage --filter=@cloudhal/core-ts --filter=@cloudhal/api \ --filter=@cloudhal/schedules --filter=@cloudhal/comments --filter=@cloudhal/analytics \ -- -t '\(Miniflare\)'