name: Install Smoke

on:
  push:
    branches: [main]
  pull_request:
  workflow_dispatch:

jobs:
  install-smoke:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout CLI
        uses: actions/checkout@v4

      - name: Setup pnpm (corepack retry)
        run: |
          set -euo pipefail
          corepack enable
          for attempt in 1 2 3; do
            if corepack prepare pnpm@10.23.0 --activate; then
              pnpm -v
              exit 0
            fi
            echo "corepack prepare failed (attempt $attempt/3). Retrying..."
            sleep $((attempt * 10))
          done
          exit 1

      - name: Install pnpm deps (minimal)
        run: pnpm install --ignore-scripts --frozen-lockfile

      - name: Run installer docker tests
        env:
          CLAWDBOT_INSTALL_URL: https://openclaw.ai/install.sh
          CLAWDBOT_INSTALL_CLI_URL: https://openclaw.ai/install-cli.sh
          CLAWDBOT_NO_ONBOARD: "1"
          CLAWDBOT_INSTALL_SMOKE_SKIP_CLI: "1"
          CLAWDBOT_INSTALL_SMOKE_SKIP_NONROOT: ${{ github.event_name == 'pull_request' && '1' || '0' }}
          CLAWDBOT_INSTALL_SMOKE_SKIP_PREVIOUS: "1"
        run: pnpm test:install:smoke
