# ty-context:github-workflow:begin
name: Harness Gates

on:
  pull_request:
  push:
    branches:
      - main
  workflow_dispatch:
    inputs:
      gate:
        description: "Make target to run"
        required: true
        default: "validate-context"
        type: choice
        options:
          - validate-context
          - validate-code-modularity
          - validate-harness

jobs:
  harness:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
        with:
          fetch-depth: 0
      - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
        with:
          node-version: "24"
      - name: Prepare source workspace CLI
        if: ${{ hashFiles('packages/ty-context/package.json') != '' }}
        run: |
          npm ci
          npm run build --workspace project-tiny-context-harness
      - name: Run harness gate
        run: make "${HARNESS_GATE}"
        env:
          HARNESS_GATE: ${{ github.event.inputs.gate || 'validate-harness' }}
          TY_CONTEXT_MODULARITY_BASE: ${{ github.event_name == 'pull_request' && format('origin/{0}', github.base_ref) || github.event.before || '' }}
# ty-context:github-workflow:end
