sailfork / t3code-github / .repos/ alchemy-effect/ .github/ workflows/ cloudflare-tools.yml

name: Cloudflare Tools

on:
  push:
    branches: [main]
    paths:
      - "submodules/distilled"
      - "packages/cloudflare-runtime/**"
      - "packages/cloudflare-test-tools/**"
      - "packages/frontend-frameworks/**"
      - "packages/node-utils/**"
      - "scripts/package-build.ts"
      - "scripts/ensure-built.ts"
      - "patches/**"
      - "package.json"
      - "pnpm-lock.yaml"
      - "pnpm-workspace.yaml"
      - "tsconfig.json"
      - ".github/workflows/cloudflare-tools.yml"
  pull_request:
    types: [opened, reopened, synchronize]
    paths:
      - "submodules/distilled"
      - "packages/cloudflare-runtime/**"
      - "packages/cloudflare-test-tools/**"
      - "packages/frontend-frameworks/**"
      - "packages/node-utils/**"
      - "scripts/package-build.ts"
      - "scripts/ensure-built.ts"
      - "patches/**"
      - "package.json"
      - "pnpm-lock.yaml"
      - "pnpm-workspace.yaml"
      - "tsconfig.json"
      - ".github/workflows/cloudflare-tools.yml"
  workflow_dispatch:

permissions:
  contents: read

concurrency:
  group: cloudflare-tools-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          - blacksmith-8vcpu-ubuntu-2404
          - blacksmith-6vcpu-macos-latest
          - blacksmith-8vcpu-windows-2025
    steps:
      - name: Checkout repository
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - name: Checkout distilled
        run: git submodule update --init --depth=1 --checkout -- submodules/distilled

      - name: Setup pnpm, Node.js, Bun and install dependencies
        uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0
        with:
          cache: true
          install: true
          require-lockfile: true

      # The Browser Rendering suite launches the pinned Chrome build
      # (BROWSER_VERSION), which it otherwise downloads (~145 MB) at test time
      # into wrangler's cache. A stalled download times out every session test.
      - name: Cache Chrome for the Browser Rendering binding
        uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
        with:
          path: |
            ~/.cache/.wrangler/chrome
            ~/Library/Caches/.wrangler/chrome
            ~/AppData/Local/xdg.cache/.wrangler/chrome
          key: browser-rendering-chrome-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('packages/cloudflare-runtime/src/core/bindings/browser/BrowserOptions.shared.ts') }}

      # Type checking is OS-independent and runs once in check.yml
      # (`pnpm typecheck`). Test builds what it needs via ensure:built.
      - name: Test
        run: pnpm test:cloudflare-packages
        env:
          # Limit concurrent package test runs on the smaller runners.
          pnpm_config_workspace_concurrency: ${{ runner.os == 'Windows' && '3' || runner.os == 'macOS' && '2' || '' }}
          # No Docker daemon for Linux images on these runners; the Linux job
          # runs the container suites (see packages/cloudflare-runtime/vitest.config.ts).
          ALCHEMY_TEST_EXCLUDE_LINUX_CONTAINERS: ${{ runner.os != 'Linux' && '1' || '' }}