name: CI

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

jobs:
  lint-and-audit:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          submodules: true

      - name: Setup pnpm
        uses: pnpm/action-setup@v4
        with:
          version: 9

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

      - name: Install dependencies
        run: pnpm install

      - name: Build (TypeScript check)
        run: pnpm run build

      - name: Main.ts line gate (baseline)
        run: pnpm run check:main-lines:baseline

      - name: Config tests
        run: pnpm run test:config

      - name: Core tests
        run: pnpm run test:core

      - name: Security audit
        run: pnpm audit --audit-level=high
        continue-on-error: true

      - name: Setup Bun
        uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest

      - name: Verify Bun subminer wrapper
        run: |
          chmod +x subminer
          ./subminer --help >/dev/null
