sshbind 0.1.0

SSHBind is a Rust library that securely binds remote services behind multiple SSH jump hosts to a local socket, enabling seamless access with encrypted credential management, TOTP-based two-factor authentication, and automatic reconnection.
Documentation
name: CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  # Build the main package once and cache it
  build:
    name: "Build Package"
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Nix
        uses: DeterminateSystems/nix-installer-action@main
        with:
          extra-conf: |
            system-features = nixos-test benchmark big-parallel kvm

      - name: Setup Magic Nix Cache
        uses: DeterminateSystems/magic-nix-cache-action@main

      - name: Build sshbind package
        run: nix build -L --show-trace

      - name: Build static checks (pre-build for integration tests)
        run: |
          # Determine the system based on OS
          if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
            SYSTEM="x86_64-linux"
          else
            SYSTEM="aarch64-darwin"
          fi

          # Build common dependencies that integration tests need
          nix build .#checks.$SYSTEM.sshbind -L --show-trace
          nix build .#checks.$SYSTEM.sshbind-clippy -L --show-trace
          nix build .#checks.$SYSTEM.sshbind-fmt -L --show-trace

  # Quick static checks
  static-checks:
    name: "${{ matrix.check }} on ${{ matrix.os }}"
    runs-on: ${{ matrix.os }}
    needs: build
    strategy:
      matrix:
        os: [ubuntu-latest]
        check: [sshbind-audit, sshbind-deny, sshbind-doc, pre-commit-check]
      fail-fast: false
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Nix
        uses: DeterminateSystems/nix-installer-action@main

      - name: Setup Magic Nix Cache
        uses: DeterminateSystems/magic-nix-cache-action@main

      - name: Run Check - ${{ matrix.check }}
        run: |
          # Determine the system based on OS
          if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
            SYSTEM="x86_64-linux"
          else
            SYSTEM="aarch64-darwin"
          fi

          echo "Running check on system: $SYSTEM"
          nix build .#checks.$SYSTEM.${{ matrix.check }} -L --show-trace

  # NixOS integration tests - depend on build to reuse cached binary
  nixos-integration-tests:
    name: "NixOS Integration Test - ${{ matrix.test }} on ${{ matrix.os }}"
    runs-on: ${{ matrix.os }}
    needs: build
    strategy:
      matrix:
        os: [ubuntu-latest]
        test: [simple, cli, performance]
      fail-fast: false
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Nix
        uses: DeterminateSystems/nix-installer-action@main
        with:
          extra-conf: |
            system-features = nixos-test benchmark big-parallel kvm

      - name: Setup Magic Nix Cache
        uses: DeterminateSystems/magic-nix-cache-action@main

      - name: Run NixOS Integration Test - ${{ matrix.test }}
        run: |
          # Determine the system based on OS
          if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
            SYSTEM="x86_64-linux"
          else
            SYSTEM="aarch64-darwin"
          fi

          echo "Running test on system: $SYSTEM"
          # The binary should already be cached from the build job
          nix build .#checks.$SYSTEM.${{ matrix.test }} -L --show-trace

  # Overall flake check (runs everything but benefits from cached builds)
  flake-check:
    name: "Flake Check"
    runs-on: ${{ matrix.os }}
    needs: [build, static-checks, nixos-integration-tests]
    strategy:
      matrix:
        os: [ubuntu-latest]
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Nix
        uses: DeterminateSystems/nix-installer-action@main
        with:
          extra-conf: |
            system-features = nixos-test benchmark big-parallel kvm

      - name: Setup Magic Nix Cache
        uses: DeterminateSystems/magic-nix-cache-action@main

      # This should be very fast since everything is already cached
      - name: Run flake check (should use cached builds)
        run: nix flake check -L --show-trace