# ╔══════════════════════════════════════════════════════════════════════╗
# ║                      CI/CD PIPELINE                                  ║
# ║                   Validation and testing for CI                      ║
# ╚══════════════════════════════════════════════════════════════════════╝

# Help for CI module
help:
    @echo "CI/CD MODULE"
    @echo ""
    @echo "Full pipeline:"
    @echo "  just ci::pipeline       Run complete CI pipeline"
    @echo "  just ci::quick          Quick CI check (fmt + lint + test)"
    @echo ""
    @echo "Individual checks:"
    @echo "  just ci::check          Format + lint check"
    @echo "  just ci::test-all       Run all tests"
    @echo "  just ci::build-all      Build all features"
    @echo "  just ci::validate       Validate Nickel schemas"
    @echo ""
    @echo "Release checks:"
    @echo "  just ci::release-check  Validate release build"

# === FULL PIPELINE ===

# Run complete CI pipeline
[doc("Complete CI pipeline: format + lint + test + build + validate")]
pipeline:
    @echo "=== CI Pipeline ==="
    @just ci::check
    @just ci::validate
    @just ci::test-all
    @just ci::build-all
    @echo "✓ CI pipeline completed successfully"

# Quick CI check (for fast feedback)
[doc("Quick CI: format + lint + test (default features)")]
quick:
    @echo "=== Quick CI Check ==="
    @just ci::check
    @just test::all
    @echo "✓ Quick CI passed"

# === INDIVIDUAL CHECKS ===

# Format and lint check
[doc("Check code format and run linter")]
check:
    @echo "=== Checking format and linting ==="
    cargo fmt --all -- --check
    cargo clippy --workspace --all-features -- -D warnings
    @echo "✓ Format and lint check passed"

# Run all tests (all features)
[doc("Run all tests with all features")]
test-all:
    @echo "=== Running all tests ==="
    cargo test --workspace --all-features
    @echo "✓ All tests passed"

# Build all feature combinations
[doc("Build all feature combinations")]
build-all:
    @echo "=== Building all features ==="
    cargo build --workspace
    cargo build --workspace --all-features
    @echo "✓ All builds successful"

# Validate Nickel schemas
[doc("Validate all Nickel configuration schemas")]
validate:
    @echo "=== Validating Nickel schemas ==="
    @just nickel::validate-all
    @echo "✓ Nickel validation passed"

# === RELEASE CHECKS ===

# Validate release build
[doc("Validate release build (optimized)")]
release-check:
    @echo "=== Validating release build ==="
    cargo build --workspace --all-features --release
    cargo test --workspace --all-features --release
    @echo "✓ Release build validated"
