include:
  - project: nanto/infra
    ref: v0.7.1
    file: /gitlab/ai-review.gitlab-ci.yml
  - project: nanto/infra
    ref: v0.7.1
    file: /gitlab/pituitary-governance.gitlab-ci.yml

stages:
  - lint
  - test
  - review

default:
  before_script:
    - export PATH="$HOME/.cargo/bin:$PATH"
    - export CARGO_HOME="${CI_PROJECT_DIR}/.cache/cargo"
    - export CARGO_TARGET_DIR="${CI_PROJECT_DIR}/target"

fmt-check:
  stage: lint
  script:
    - cargo fmt -- --check

clippy:
  stage: lint
  script:
    - cargo clippy --all-targets --all-features -- -D warnings

test:
  stage: test
  script:
    - cargo test --all-targets --all-features

build:
  stage: test
  script:
    - cargo build --all-targets --all-features

ai-precheck:
  extends: .nanto-ai-precheck
  stage: lint

ai-review:
  extends: .nanto-ai-review
  stage: review
  allow_failure: true

# Pituitary governance: spec / doc / code drift detection.
# See .pituitary/pituitary.toml for terminology rules and source bundles.
#
# Both jobs are advisory while we validate the gate end-to-end. The
# infra template's `.nanto-pituitary-precheck` already sets
# `allow_failure: true`; we re-state it here on the precheck to keep
# the rollout posture explicit at the consumer site, and add it on
# `pituitary-mr` (which is fail-closed by default in the template).
# Flip both back to default `false` once one MR cycle has confirmed
# the install + binary-discovery path runs cleanly on the runner.
pituitary-precheck:
  extends: .nanto-pituitary-precheck
  stage: lint
  allow_failure: true

pituitary-mr:
  extends: .nanto-pituitary-mr
  stage: review
  allow_failure: true
