name: Reusable test workflow on: workflow_call: {} env: DO_NOT_TRACK: "1" NEXT_TELEMETRY_DISABLED: "1" TURBO_TELEMETRY_DISABLED: "1" jobs: bun-test: name: "Bun (OS: ${{ matrix.os }})" # Tests normally finish in a few minutes; cap well above that so a hung # process fails fast instead of running to the 6h GitHub default. timeout-minutes: 15 defaults: run: # Explicit so `pipefail` is on, matching the other jobs here. shell: bash strategy: fail-fast: false matrix: # No windows-latest: Bun cannot migrate `package-lock.json`, so # `bun install` resolves every package from the registry, and Windows # harden-runner's DNS proxy drops those lookups (`no upstream DNS # servers available` for registry.npmjs.org, then `ConnectionRefused` # on each tarball). Re-add it once that proxy is reliable on Windows. os: - ubuntu-latest - macos-latest permissions: contents: read runs-on: ${{ matrix.os }} steps: - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1 with: # The wildcard entries below are background traffic from the Windows # and macOS runner images — push and notification services, media and # software CDNs, connectivity probes, certificate revocation and time # sync — not anything this repository requests. StepSecurity documents # wildcards for exactly this: "For services that rotate subdomains, # such as AWS or Azure CDNs, use wildcard patterns to prevent # repetitive alerts." Apple rotates its CDN names per lookup, so # naming them one at a time does not converge. Each wildcard is scoped # to a single vendor's own domain. The same list is used by every job # with a non-Linux runner so the three cannot drift apart. allowed-endpoints: > *.aaplimg.com:443 *.apple-cloudkit.com:443 *.apple-cloudkit.fe2.apple-dns.net:443 *.apple-dns.net:443 *.apple.com:443 *.c.lencr.org:80 *.cdn-apple.com:443 *.cloudflare.com:443 *.data.microsoft.com:443 *.digicert.com:443 *.digicert.com:80 *.events.data.microsoft.com:443 *.fastly-edge.com:443 *.fe2.apple-dns.net:443 *.g.aaplimg.com:443 *.iadsdk.apple.com:443 *.icloud.com:443 *.itunes.apple.com:443 *.ls.apple.com:443 *.microsoft.com:443 *.msftconnecttest.com:443 *.msftconnecttest.com:80 *.msftncsi.com:443 *.msftncsi.com:80 *.mzstatic.com:443 *.pcms.apple.com:443 *.pool.ntp.org:123 *.safebrowsing.apple:443 *.safebrowsing.apple:80 *.sectigo.com:443 *.sectigo.com:80 *.sls.update.microsoft.com:443 *.smoot.apple.com:443 *.stepsecurity.io:443 *.telemetry.mozilla.org:443 *.update.microsoft.com:443 *.usertrust.com:443 *.usertrust.com:80 *.wns.windows.com:443 *.wrr.me.apple-dns.net:443 0.pool.ntp.org:443 api.apple-cloudkit.com:443 api.apple-cloudkit.fe2.apple-dns.net:443 api.github.com:443 ${{ runner.os == 'macOS' && 'fpinit.itunes.apple.com:443' || '' }} ${{ runner.os == 'macOS' && 'gateway.icloud.com:443' || '' }} ${{ runner.os == 'macOS' && 's.mzstatic.com:443' || '' }} ${{ runner.os == 'macOS' && 'swdist.apple.com:443' || '' }} ${{ runner.os == 'macOS' && 'updates-http.cdn-apple.com:80' || '' }} ${{ runner.os == 'macOS' && 'xp.apple.com:443' || '' }} ${{ runner.os == 'Windows' && 'download.windowsupdate.com:80' || '' }} ${{ runner.os == 'Windows' && 'download.windowsupdate.com:443' || '' }} decide.arcjet.com:443 github.com:443 h3.apis.apple.map.fastly.net:443 login.live.com:443 mesu-cdn.origin-apple.com.akadns.net:443 objects.githubusercontent.com:443 ocsp.comodoca.com:443 prod.ingestion-edge.prod.dataservices.mozgcp.net:443 registry.npmjs.org:443 release-assets.githubusercontent.com:443 safebrowsing.googleapis.com:443 tas02.cwsmu.update.microsoft.com:443 # sudo/container lockdown is Linux-only; a no-op or error on other OS. disable-sudo-and-containers: ${{ runner.os == 'Linux' }} egress-policy: block - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 with: persist-credentials: false - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: bun-version: 1.2.19 - run: bun install && bun run build - run: bun test working-directory: arcjet-bun # Branch protection requires the check name `Run tests / Bun` (the # reusable workflow job name `Bun`, called from the `Run tests` job). bun: name: Bun if: always() needs: bun-test timeout-minutes: 2 permissions: contents: read runs-on: ubuntu-latest steps: - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1 with: # This job only reads a needs result, so it needs no endpoint of its # own. The list is still required: `block` with none at all also drops # harden-runner's own API and the runner's orchestrator calls, which it # then reports as unexpected network calls. allowed-endpoints: > api.github.com:443 github.com:443 disable-sudo-and-containers: true egress-policy: block - name: All Bun OS jobs passed run: test "${{ needs.bun-test.result }}" = "success" # `@arcjet/deno` was removed, so there are no Deno tests left to run. # This job is retained ONLY because branch protection requires the check # name `Run tests / Deno`; delete it once that requirement is dropped. deno: name: Deno if: always() timeout-minutes: 2 permissions: contents: read runs-on: ubuntu-latest steps: - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1 with: # Same as the Bun gate above: a non-empty list is what lets # harden-runner keep its own API and the runner's own calls allowed. allowed-endpoints: > api.github.com:443 github.com:443 disable-sudo-and-containers: true egress-policy: block - name: No Deno tests to run run: 'echo "@arcjet/deno was removed; nothing to test."' node-test: name: "Run tests (OS: ${{matrix.os}}, Node: ${{ matrix.node }})" runs-on: ${{ matrix.os }} timeout-minutes: 15 defaults: run: # Git Bash on Windows so `&&` and the pin-npm composite match Linux/macOS. shell: bash strategy: fail-fast: false matrix: node: - 22 - 24 - 26 os: - ubuntu-latest - windows-latest - macos-latest permissions: contents: read steps: # Environment security - name: Harden Runner uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1 with: # sudo/container lockdown is Linux-only; a no-op or error on other OS. disable-sudo-and-containers: ${{ runner.os == 'Linux' }} egress-policy: block # The wildcard entries below are background traffic from the Windows # and macOS runner images — push and notification services, media and # software CDNs, connectivity probes, certificate revocation and time # sync — not anything this repository requests. StepSecurity documents # wildcards for exactly this: "For services that rotate subdomains, # such as AWS or Azure CDNs, use wildcard patterns to prevent # repetitive alerts." Apple rotates its CDN names per lookup, so # naming them one at a time does not converge. Each wildcard is scoped # to a single vendor's own domain. The same list is used by every job # with a non-Linux runner so the three cannot drift apart. allowed-endpoints: > *.aaplimg.com:443 *.apple-cloudkit.com:443 *.apple-cloudkit.fe2.apple-dns.net:443 *.apple-dns.net:443 *.apple.com:443 *.c.lencr.org:80 *.cdn-apple.com:443 *.cloudflare.com:443 *.data.microsoft.com:443 *.digicert.com:443 *.digicert.com:80 *.events.data.microsoft.com:443 *.fastly-edge.com:443 *.fe2.apple-dns.net:443 *.g.aaplimg.com:443 *.iadsdk.apple.com:443 *.icloud.com:443 *.itunes.apple.com:443 *.ls.apple.com:443 *.microsoft.com:443 *.msftconnecttest.com:443 *.msftconnecttest.com:80 *.msftncsi.com:443 *.msftncsi.com:80 *.mzstatic.com:443 *.pcms.apple.com:443 *.pool.ntp.org:123 *.safebrowsing.apple:443 *.safebrowsing.apple:80 *.sectigo.com:443 *.sectigo.com:80 *.sls.update.microsoft.com:443 *.smoot.apple.com:443 *.stepsecurity.io:443 *.telemetry.mozilla.org:443 *.update.microsoft.com:443 *.usertrust.com:443 *.usertrust.com:80 *.wns.windows.com:443 *.wrr.me.apple-dns.net:443 0.pool.ntp.org:443 api.apple-cloudkit.com:443 api.apple-cloudkit.fe2.apple-dns.net:443 api.github.com:443 ${{ runner.os == 'macOS' && 'fpinit.itunes.apple.com:443' || '' }} ${{ runner.os == 'macOS' && 'gateway.icloud.com:443' || '' }} ${{ runner.os == 'macOS' && 's.mzstatic.com:443' || '' }} ${{ runner.os == 'macOS' && 'swdist.apple.com:443' || '' }} ${{ runner.os == 'macOS' && 'updates-http.cdn-apple.com:80' || '' }} ${{ runner.os == 'macOS' && 'xp.apple.com:443' || '' }} ${{ runner.os == 'Windows' && 'download.windowsupdate.com:80' || '' }} ${{ runner.os == 'Windows' && 'download.windowsupdate.com:443' || '' }} decide.arcjet.com:443 github.com:443 h3.apis.apple.map.fastly.net:443 login.live.com:443 mesu-cdn.origin-apple.com.akadns.net:443 nodejs.org:443 objects.githubusercontent.com:443 ocsp.comodoca.com:443 prod.ingestion-edge.prod.dataservices.mozgcp.net:443 registry.npmjs.org:443 release-assets.githubusercontent.com:443 safebrowsing.googleapis.com:443 tas02.cwsmu.update.microsoft.com:443 # Checkout # Most toolchains require checkout first - name: Checkout uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 with: persist-credentials: false - name: Wait for Windows DNS proxy if: runner.os == 'Windows' run: sleep 5 # Language toolchains - name: Install Node uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 with: node-version: ${{ matrix.node }} - name: Pin npm uses: ./.github/actions/pin-npm # Workflow - name: Install dependencies run: npm ci && npm run build - name: Run tests run: npm test transport-runtime: name: "@arcjet/transport proxy (${{ matrix.runtime }} ${{ matrix.bun-version || matrix.deno-version }})" runs-on: ubuntu-latest timeout-minutes: 15 strategy: fail-fast: false matrix: include: # Bun's native-fetch proxy support is exercised here (not under Node). # `HTTPS_PROXY` is set at process startup (by the npm script), which # Bun honors back to 1.3.0, the project's minimum supported Bun. - runtime: bun script: test-runtime-bun bun-version: 1.3.0 - runtime: bun script: test-runtime-bun bun-version: latest - runtime: deno script: test-runtime-deno deno-version: lts - runtime: deno script: test-runtime-deno deno-version: latest permissions: contents: read steps: - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1 with: allowed-endpoints: > api.github.com:443 deno.com:443 dl.deno.land:443 github.com:443 nodejs.org:443 objects.githubusercontent.com:443 registry.npmjs.org:443 release-assets.githubusercontent.com:443 disable-sudo-and-containers: true egress-policy: block - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 with: persist-credentials: false - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 with: node-version: 22 - name: Pin npm uses: ./.github/actions/pin-npm - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 if: matrix.runtime == 'bun' with: bun-version: ${{ matrix.bun-version }} - uses: denoland/setup-deno@22d081ff2d3a40755e97629de92e3bcbfa7cf2ed # v2.0.5 if: matrix.runtime == 'deno' with: deno-version: ${{ matrix.deno-version }} # Build the whole workspace first so `@arcjet/transport`'s dependencies # (`@arcjet/env`, `@arcjet/logger`) are available to the runtime test. - run: npm ci && npm run build - run: npm run ${{ matrix.script }} --workspace=@arcjet/transport arcjet-runtime: name: arcjet protect() (Cloudflare Workers) runs-on: ubuntu-latest timeout-minutes: 15 permissions: contents: read steps: - uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1 with: # The runtime test calls a local mock DecideService server, so the # Arcjet decide endpoint is never hit. `workers.cloudflare.com` is # contacted by miniflare's bundled workerd on startup (not by the # test) and must be allowed so harden-runner doesn't block it. allowed-endpoints: > api.github.com:443 github.com:443 nodejs.org:443 objects.githubusercontent.com:443 registry.npmjs.org:443 release-assets.githubusercontent.com:443 workers.cloudflare.com:443 disable-sudo-and-containers: true egress-policy: block - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 with: persist-credentials: false - uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0 with: node-version: 24 - name: Pin npm uses: ./.github/actions/pin-npm # Build the whole workspace first so the SDK's dependencies (including the # `workerd` entries of `@arcjet/transport` and `@arcjet/analyze-wasm`) are # available to the runtime test. - run: npm ci && npm run build - run: npm run test-runtime-cloudflare --workspace=arcjet