name: ci

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

jobs:
  build-test:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    env:
      NODE_OPTIONS: --max-old-space-size=4096
    steps:
      - name: Checkout repository
        uses: actions/checkout@v5

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

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

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

      # Run all tasks using workspace filters

      - name: Ensure staging a release works.
        env:
          GH_TOKEN: ${{ github.token }}
        run: ./codex-cli/scripts/stage_release.sh

      - name: Ensure root README.md contains only ASCII and certain Unicode code points
        run: ./scripts/asciicheck.py README.md
      - name: Check root README ToC
        run: python3 scripts/readme_toc.py README.md

      - name: Ensure codex-cli/README.md contains only ASCII and certain Unicode code points
        run: ./scripts/asciicheck.py codex-cli/README.md
      - name: Check codex-cli/README ToC
        run: python3 scripts/readme_toc.py codex-cli/README.md
