Skip to content

Commit

Permalink
add TCP/UDP ports check in github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrtc committed Feb 18, 2024
1 parent 6fc0cdc commit 185abaf
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 37 deletions.
33 changes: 28 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,42 @@ jobs:
tests:
name: Integration Tests
runs-on: ubuntu-latest

services:
chat-server:
image: chat-server:latest
ports:
- 8080:8080
- 3478-3495:3478-3495/udp
options: --name chat-server

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive

- name: Run server and tests
- name: Build and run chat server in Docker
run: |
cargo run --release --package sfu --example chat -- -d --level info > sfu.log 2>&1 & echo $! > server_pid.txt
cargo test --release --no-fail-fast -- --show-output > test.log 2>&1 || true
docker build -t chat-server ./scripts/.
docker run -d --name chat-server -p 8080:8080 -p 3478-3495:3478-3495/udp chat-server
sleep 5
docker logs chat-server > sfu.log
- name: Check TCP Port 8080
run: nc -zv 127.0.0.1 8080 || echo "TCP port 8080 is not accessible"

- name: Check UDP Port 3478
run: nc -zv 127.0.0.1 -u 3478 || echo "UDP port 3478 is not accessible"

- name: Check UDP Port 3495
run: nc -zv 127.0.0.1 -u 3495 || echo "UDP port 3495 is not accessible"

- name: Run integration tests
run: cargo test --release --no-fail-fast -- --show-output > test.log 2>&1 || true

- name: Shutdown server
run: kill -INT $(cat server_pid.txt) || true
- name: Shutdown chat server
run: docker stop chat-server && docker rm chat-server

- name: Upload logs as artifact
uses: actions/upload-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion examples/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::str::FromStr;
use std::sync::Arc;
use waitgroup::WaitGroup;

mod signal;
pub mod signal;

extern crate num_cpus;

Expand Down
28 changes: 28 additions & 0 deletions scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Use rust image as base
FROM rust:latest AS builder

# Set working directory inside the container
WORKDIR /usr/src/app

# Copy the Rust project files into the container
COPY . .

# Build the Rust project
RUN cargo build --release --package sfu --example chat

# Use a smaller base image for runtime
FROM debian:buster-slim

# Set working directory inside the container
WORKDIR /usr/src/app

# Copy the built executable from the builder stage
COPY --from=builder /usr/src/app/target/release/examples/chat .

# Expose the TCP port the signal server will listen on
EXPOSE 8080
# Expose the UDP ports the media server will listen on
EXPOSE 3478-3495/udp

# Command to run the server
CMD ["./chat -d --level info"]
File renamed without changes.
11 changes: 0 additions & 11 deletions tests/rtcp_test.rs

This file was deleted.

10 changes: 0 additions & 10 deletions tests/rtp_test.rs

This file was deleted.

10 changes: 0 additions & 10 deletions tests/signaling_test.rs

This file was deleted.

0 comments on commit 185abaf

Please sign in to comment.