name: sdk

on:
  push:
    branches: [main]
  pull_request: {}

jobs:
  sdks:
    runs-on:
      group: codex-runners
      labels: codex-linux-x64
    timeout-minutes: 10
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Install Linux bwrap build dependencies
        shell: bash
        run: |
          set -euo pipefail
          sudo apt-get update -y
          sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends pkg-config libcap-dev

      - name: Setup pnpm
        uses: pnpm/action-setup@v4
        with:
          run_install: false

      - name: Setup Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 22
          cache: pnpm

      - uses: dtolnay/rust-toolchain@1.93.0

      - name: build codex
        run: cargo build --bin codex
        working-directory: codex-rs

      - name: Install dependencies
        run: pnpm install --frozen-lockfile

      - name: Build SDK packages
        run: pnpm -r --filter ./sdk/typescript run build

      - name: Lint SDK packages
        run: pnpm -r --filter ./sdk/typescript run lint

      - name: Test SDK packages
        run: pnpm -r --filter ./sdk/typescript run test
