name: Monorepo Lint
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  lint-shell:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install ShellCheck
        run: sudo apt-get install -y shellcheck
      - name: Lint shell scripts
        run: |
          find bin/ scripts/ -name '*.sh' -type f | head -50 | while read f; do
            shellcheck -S warning "$f" || true
          done
      - name: Syntax check all scripts
        run: |
          find bin/ scripts/ -name '*.sh' -type f -exec bash -n {} \;
          echo "All scripts pass syntax check"

  lint-js:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - name: Check worker JS syntax
        run: |
          find workers/ -name '*.js' -type f | while read f; do
            node --check "$f" && echo "  OK: $f" || echo "  FAIL: $f"
          done
