apprtc 0.4.0

AppRTC P2P/SFU Server in Rust
Documentation
name: tests

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

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

env:
  CARGO_TERM_COLOR: always

jobs:
  tests:
    name: Integration Tests
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          submodules: recursive

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

      - name: Rust Cache
        uses: Swatinem/rust-cache@v2

      - name: Create logs directory
        run: mkdir -p logs

      - name: Build AppRTC, signaling, SFU, and tests
        run: cargo build --release --bins --tests

      - name: Start AppRTC before signaling and verify startup recovery
        run: |
          ./target/release/apprtc \
            --host-ip 127.0.0.1 --port 8080 --web-root web \
            --public-url https://127.0.0.1:8080 \
            --ws-url wss://127.0.0.1:8081/ws \
            --grpc-url https://127.0.0.1:50051 \
            --insecure-tls --tls \
            --debug --level info > ./logs/apprtc.log 2>&1 &
          apprtc_pid=$!
          sleep 2
          kill -0 "$apprtc_pid"
          ./target/release/signaling \
            --host-ip 127.0.0.1 --port 8081 \
            --grpc-port 50051 --tls \
            --debug --level info > ./logs/signaling.log 2>&1 &
          ./target/release/sfu \
            --host-ip 127.0.0.1 \
            --media-port-min 35000 --media-port-max 35000 \
            --grpc-url https://127.0.0.1:50051 --insecure-tls \
            --debug --level info > ./logs/sfu.log 2>&1 &
          for attempt in {1..30}; do
            if curl --silent --fail --insecure https://127.0.0.1:8080/status >/dev/null; then
              exit 0
            fi
            sleep 1
          done
          echo "AppRTC failed to become ready"
          cat ./logs/signaling.log
          cat ./logs/apprtc.log
          exit 1

      - name: Verify AppRTC reconnects after signaling restart
        run: |
          pkill -x signaling || true
          curl --silent --insecure https://127.0.0.1:8080/status >/dev/null || true
          ./target/release/signaling \
            --host-ip 127.0.0.1 --port 8081 \
            --grpc-port 50051 --tls \
            --debug --level info >> ./logs/signaling.log 2>&1 &
          for attempt in {1..30}; do
            if curl --silent --fail --insecure https://127.0.0.1:8080/status >/dev/null; then
              exit 0
            fi
            sleep 1
          done
          echo "AppRTC failed to reconnect to signaling"
          cat ./logs/signaling.log
          cat ./logs/apprtc.log
          exit 1

      - name: Run tests
        run: cargo test --no-fail-fast --test '*' -- --nocapture

      - name: Stop signaling and AppRTC servers
        if: always()
        run: |
          pkill -x sfu || true
          pkill -x signaling || true
          pkill -x apprtc || true

      - name: Upload logs as artifact
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: logs
          path: logs/