cargo-copter 0.3.0

Test dependents against multiple versions of your crate (or your local WIP before publishing). Inspired by the cargo-crusader
# CI workflow for cargo-copter
#
# This workflow tests:
# - Code compilation and unit tests
# - Integration tests with test fixtures
# - Format and clippy checks

name: CI

on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]
  workflow_dispatch:

permissions:
  contents: read

jobs:
  # Test 1: Basic compilation and unit tests
  test-build:
    name: Build and Test
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: ~/.cargo/registry
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

      - name: Cache cargo index
        uses: actions/cache@v4
        with:
          path: ~/.cargo/git
          key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

      - name: Cache cargo build
        uses: actions/cache@v4
        with:
          path: target
          key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

      - name: Check formatting
        run: cargo fmt -- --check
        continue-on-error: true

      - name: Clippy
        run: cargo clippy --all-targets --all-features -- -D warnings
        continue-on-error: true

      - name: Build
        run: cargo build --release --locked

      - name: Run unit tests
        run: cargo test

      - name: Run integration tests
        run: cargo test --test '*'

      - name: Verify binary works
        run: |

          ./target/release/cargo-copter --version
          ./target/release/cargo-copter --help

  # Test 2: Workflow validation
  test-workflows:
    name: Validate Workflows
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Check workflow syntax
        run: |

          for workflow in .github/workflows/*.yml; do
            echo "Checking $workflow"
            # Basic YAML syntax check
            python3 -c "import yaml; yaml.safe_load(open('$workflow'))"
          done
          echo "PASS: All workflows have valid YAML syntax"

      - name: Verify security settings
        run: |

          echo "Checking for security best practices..."

          # Check all workflows have permissions defined
          for workflow in .github/workflows/*.yml; do
            if ! grep -q "permissions:" "$workflow"; then
              echo "WARNING: $workflow missing permissions block"
            fi
          done

          echo "PASS: Security settings validated"

  # Summary job
  ci-success:
    name: CI Success
    runs-on: ubuntu-latest
    needs:
      - test-build
      - test-workflows

    steps:
      - name: Summary
        run: |

          echo "✅ All CI tests passed!"
          echo ""
          echo "Tests completed:"
          echo "  ✓ Build and unit tests"
          echo "  ✓ Format and clippy checks"
          echo "  ✓ Workflow validation"