sshping 0.5.1

SSH-based ping that measures interactive character echo latency and file transfer throughput. Pronounced "shipping".
# Based on typst's release action:
# https://github.com/typst/typst/blob/main/.github/workflows/release.yml

name: Check and Test Build
on:
  push:
    branches:
      - "**"
    tags-ignore:
      - "**"
  workflow_dispatch:

jobs:
  format:
    name: code format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: rustfmt

      - name: Run Rustfmt
        run: cargo +nightly fmt --all -- --check

  check:
    name: clippy check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2

      - name: Run Clippy
        run: cargo clippy --locked --all-targets -- -D warnings

  unit-test:
    name: unit test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - name: Run tests
        run: cargo test --locked

  build-test:
    name: build on ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    needs: [check, unit-test]
    permissions:
      contents: write
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-musl
            os: ubuntu-24.04
          - target: aarch64-unknown-linux-musl
            os: ubuntu-24.04-arm
          - target: x86_64-apple-darwin
            os: macos-26-intel
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-pc-windows-msvc
            os: windows-latest
          - target: aarch64-pc-windows-msvc
            os: windows-11-arm

    steps:
      - uses: actions/checkout@v7

      - name: Install Cross-Compilation Tools
        if: contains(matrix.target, 'linux-musl')
        run: |
          sudo apt-get update
          sudo apt-get install -y musl-tools pkg-config libssl-dev

      - uses: dtolnay/rust-toolchain@stable
        with:
          target: ${{ matrix.target }}

      - uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.target }}

      - name: Run Cargo
        run: cargo build --locked --target ${{ matrix.target }}

  integration-test:
    name: sshping-${{ matrix.test.name }}
    runs-on: ubuntu-latest
    timeout-minutes: 15
    needs: [check, unit-test]
    strategy:
      fail-fast: false
      matrix:
        test:
          - name: agent-auth
            script: test_agent_auth.sh
          - name: file-key
            script: test_file_key.sh
          - name: wrong-password
            script: test_wrong_password.sh
          - name: echo
            script: test_echo.sh
          - name: speed
            script: test_speed.sh
          - name: default-key
            script: test_default_key.sh
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - name: Setup SSH server
        run: bash .github/scripts/setup-sshd.sh

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

      - name: Run test
        run: bash .github/scripts/tests/${{ matrix.test.script }}