ping-rust 0.1.13

Menu-driven installer and manager for the shoes proxy server
name: CI

on:
  push:
  pull_request:

permissions:
  contents: read

jobs:
  ubuntu:
    name: Ubuntu ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-22.04, ubuntu-24.04]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
      - uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable
        with:
          components: rustfmt, clippy
      - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
      - name: Check one-click installer
        shell: bash
        run: |
          set -euo pipefail
          bash -n scripts/install.sh
          bash scripts/install.sh --help >/dev/null
          if bash scripts/install.sh --version invalid >/dev/null 2>&1; then
            echo "error: installer accepted an invalid version" >&2
            exit 1
          fi
          if bash scripts/install.sh --install-dir relative >/dev/null 2>&1; then
            echo "error: installer accepted a relative install directory" >&2
            exit 1
          fi
      - run: cargo fmt --all -- --check
      - run: cargo test --locked
      - name: Install stable shoes for chain traffic acceptance
        if: matrix.os == 'ubuntu-24.04'
        shell: bash
        env:
          SHOES_ARCHIVE_SHA256: e60ccde92490624d9ff399dd58e69d4d6943b33c5cc4f0b0d1509b0c644fbc2a
        run: |
          set -euo pipefail
          archive="$RUNNER_TEMP/shoes-v0.2.7.tar.gz"
          directory="$RUNNER_TEMP/shoes-v0.2.7"
          curl --fail --location --retry 3 --proto '=https' --tlsv1.2 \
            --output "$archive" \
            https://github.com/cfal/shoes/releases/download/v0.2.7/shoes-x86_64-unknown-linux-musl.tar.gz
          echo "$SHOES_ARCHIVE_SHA256  $archive" | sha256sum --check --strict
          mkdir -p "$directory"
          tar -xzf "$archive" -C "$directory"
          test -x "$directory/shoes"
      - name: Prove stable shoes chain traffic has no direct fallback
        if: matrix.os == 'ubuntu-24.04'
        env:
          PING_RUST_SHOES_E2E_BIN: ${{ runner.temp }}/shoes-v0.2.7/shoes
        run: cargo test --locked --test chain_proxy_e2e -- --nocapture
      - run: cargo clippy --locked --all-targets -- -D warnings
      - run: cargo build --locked --release

  distro-build:
    name: ${{ matrix.name }}
    runs-on: ubuntu-24.04
    container: ${{ matrix.image }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - name: Debian 12
            image: debian:12
            family: apt
          - name: Rocky Linux 9
            image: rockylinux:9
            family: rpm
          - name: AlmaLinux 9
            image: almalinux:9
            family: rpm
    steps:
      - name: Install build prerequisites
        shell: bash
        run: |
          if [ "${{ matrix.family }}" = "apt" ]; then
            apt-get update
            DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
              build-essential ca-certificates curl git gzip pkg-config tar
          else
            dnf install -y \
              ca-certificates gcc gcc-c++ git gzip make \
              pkgconf-pkg-config tar
          fi
      - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
      - uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable
      - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
        with:
          key: ${{ matrix.name }}
      - run: cargo test --locked
      - name: Install stable shoes for chain traffic acceptance
        if: matrix.name == 'Debian 12'
        shell: bash
        env:
          SHOES_ARCHIVE_SHA256: e60ccde92490624d9ff399dd58e69d4d6943b33c5cc4f0b0d1509b0c644fbc2a
        run: |
          set -euo pipefail
          archive="$RUNNER_TEMP/shoes-v0.2.7.tar.gz"
          directory="$RUNNER_TEMP/shoes-v0.2.7"
          curl --fail --location --retry 3 --proto '=https' --tlsv1.2 \
            --output "$archive" \
            https://github.com/cfal/shoes/releases/download/v0.2.7/shoes-x86_64-unknown-linux-musl.tar.gz
          echo "$SHOES_ARCHIVE_SHA256  $archive" | sha256sum --check --strict
          mkdir -p "$directory"
          tar -xzf "$archive" -C "$directory"
          test -x "$directory/shoes"
      - name: Prove stable shoes chain traffic has no direct fallback
        if: matrix.name == 'Debian 12'
        env:
          PING_RUST_SHOES_E2E_BIN: ${{ runner.temp }}/shoes-v0.2.7/shoes
        run: cargo test --locked --test chain_proxy_e2e -- --nocapture
      - run: cargo build --locked --release