k8s-maestro 1.0.4

A Kubernetes job orchestrator tool library
name: Rust

on:
  push:
    tags: [ "v*.*.*" ]
  pull_request:
    branches: [ "main" ]

env:
  CARGO_TERM_COLOR: always

jobs:
  # Unit tests - run without Docker/Kind
  unit-tests:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        override: true
    - name: Run unit tests
      run: cargo test --lib

  # Lint and format check
  lint:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        override: true
        components: clippy, rustfmt
    - name: Check formatting
      run: cargo fmt --check
    - name: Run clippy
      run: cargo clippy -- -D warnings

  # Integration tests - require Kind cluster
  integration-tests:
    runs-on: ubuntu-latest
    needs: [unit-tests, lint]
    steps:
    - uses: actions/checkout@v4
    - uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        override: true
    - name: Install Kind
      uses: helm/kind-action@v1
      with:
        cluster_name: test-cluster
        wait: 120s
    - name: Run integration tests (excludes E2E)
      run: cargo test --test '*' -- --ignored
      env:
        KUBECONFIG: /home/runner/.kube/config

  # E2E tests - require Kind cluster
  e2e-tests:
    runs-on: ubuntu-latest
    needs: [unit-tests, lint]
    steps:
    - uses: actions/checkout@v4
    - uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        override: true
    - name: Install Kind
      uses: helm/kind-action@v1
      with:
        cluster_name: e2e-cluster
        wait: 120s
    - name: Run E2E tests (requires Docker and is slow)
      run: cargo test --test '*' -- --ignored
      env:
        KUBECONFIG: /home/runner/.kube/config

  # Build release - depends on BOTH unit tests, integration tests, lint, AND E2E tests
  build:
    runs-on: ubuntu-latest
    needs: [unit-tests, lint, integration-tests, e2e-tests]
    steps:
    - uses: actions/checkout@v4
    - uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        override: true
    - name: Build Release
      run: cargo build --release