Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 203 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
name: RootStream CI

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

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
build-type: [release, debug]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
pkg-config \
libdrm-dev \
libva-dev \
libsodium-dev \
libopus-dev \
libasound2-dev \
libsdl2-dev \
libgtk-3-dev \
libavahi-client-dev \
libqrencode-dev \
libpng-dev

- name: Build (${{ matrix.build-type }})
run: |
if [ "${{ matrix.build-type }}" = "debug" ]; then
make DEBUG=1
else
make
fi

- name: Verify binary
run: |
./rootstream --help || true
file ./rootstream
ldd ./rootstream || true

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: rootstream-${{ matrix.build-type }}
path: rootstream

unit-tests:
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
pkg-config \
libdrm-dev \
libva-dev \
libsodium-dev \
libopus-dev \
libasound2-dev \
libsdl2-dev \
libgtk-3-dev \
libavahi-client-dev \
libqrencode-dev \
libpng-dev

- name: Build tests
run: make test-build

- name: Run crypto tests
run: ./tests/unit/test_crypto

- name: Run encoding tests
run: ./tests/unit/test_encoding

integration-tests:
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
pkg-config \
libdrm-dev \
libva-dev \
libsodium-dev \
libopus-dev \
libasound2-dev \
libsdl2-dev \
libgtk-3-dev \
libavahi-client-dev \
libqrencode-dev \
libpng-dev \
xvfb

- name: Build
run: make

- name: Run integration tests
run: |
# Some tests need a display
xvfb-run --auto-servernum ./tests/integration/test_stream.sh || \
./tests/integration/test_stream.sh

code-quality:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
cppcheck \
clang-tools

- name: Run cppcheck
run: |
cppcheck --enable=warning,style,performance \
--suppress=missingIncludeSystem \
--error-exitcode=0 \
src/ include/

- name: Check for common issues
run: |
# Check for TODO/FIXME counts (informational)
echo "=== TODOs and FIXMEs ==="
grep -rn "TODO\|FIXME" src/ include/ || echo "None found"

# Check for potential security issues
echo ""
echo "=== Potential security patterns ==="
grep -rn "strcpy\|sprintf\|gets" src/ || echo "None found (good!)"

memory-check:
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
pkg-config \
libdrm-dev \
libva-dev \
libsodium-dev \
libopus-dev \
libasound2-dev \
libsdl2-dev \
libgtk-3-dev \
libavahi-client-dev \
libqrencode-dev \
libpng-dev \
valgrind

- name: Build with debug symbols
run: make DEBUG=1 test-build

- name: Run valgrind on unit tests
run: |
valgrind --leak-check=full \
--show-leak-kinds=definite \
--error-exitcode=0 \
./tests/unit/test_crypto 2>&1 | tee valgrind-crypto.log

valgrind --leak-check=full \
--show-leak-kinds=definite \
--error-exitcode=0 \
./tests/unit/test_encoding 2>&1 | tee valgrind-encoding.log

- name: Upload valgrind logs
uses: actions/upload-artifact@v4
with:
name: valgrind-logs
path: valgrind-*.log
68 changes: 66 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,15 @@ ICONDIR := $(SHAREDIR)/icons/hicolor
DESKTOPDIR := $(SHAREDIR)/applications
SYSTEMDDIR := $(HOME)/.config/systemd/user

# Test binaries
TEST_CRYPTO := tests/unit/test_crypto
TEST_ENCODING := tests/unit/test_encoding

# ============================================================================
# Build Rules
# ============================================================================

.PHONY: all clean install uninstall deps check help player
.PHONY: all clean install uninstall deps check help player test test-build test-unit test-integration test-clean

# Default target
all: $(TARGET) $(PLAYER)
Expand Down Expand Up @@ -311,7 +315,7 @@ uninstall:
# Cleaning
# ============================================================================

clean:
clean: test-clean
@echo "🧹 Cleaning build artifacts..."
@rm -f $(OBJS) $(DEPS) $(TARGET) $(PLAYER)
@rm -f src/*.o src/*.d
Expand Down Expand Up @@ -373,16 +377,76 @@ help:
@echo " format Format source code"
@echo " help Show this help"
@echo ""
@echo "Testing:"
@echo " test Run all tests (unit + integration)"
@echo " test-build Build test binaries"
@echo " test-unit Run unit tests only"
@echo " test-integration Run integration tests only"
@echo " test-clean Remove test artifacts"
@echo ""
@echo "Build options:"
@echo " DEBUG=1 Build with debug symbols"
@echo " PREFIX=/path Install prefix (default: /usr/local)"
@echo ""
@echo "Examples:"
@echo " make # Build"
@echo " make DEBUG=1 # Debug build"
@echo " make test # Run all tests"
@echo " make install # Install to /usr/local"
@echo " sudo make PREFIX=/usr install # Install to /usr"

# ============================================================================
# Testing
# ============================================================================

# Build all test binaries
test-build: $(TEST_CRYPTO) $(TEST_ENCODING)

# Build and run all tests
test: test-unit test-integration

# Run unit tests
test-unit: test-build
@echo ""
@echo "╔════════════════════════════════════════════════╗"
@echo "║ Running Unit Tests ║"
@echo "╚════════════════════════════════════════════════╝"
@echo ""
@./$(TEST_CRYPTO)
@./$(TEST_ENCODING)
@echo ""
@echo "✓ All unit tests passed"

# Run integration tests
test-integration: $(TARGET)
@echo ""
@echo "╔════════════════════════════════════════════════╗"
@echo "║ Running Integration Tests ║"
@echo "╚════════════════════════════════════════════════╝"
@echo ""
@./tests/integration/test_stream.sh

# Build crypto test
$(TEST_CRYPTO): tests/unit/test_crypto.c src/crypto.c
@echo "🔨 Building crypto tests..."
@mkdir -p tests/unit
@$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(LIBS)
@echo "✓ Built: $@"

# Build encoding test (standalone, doesn't need hardware)
$(TEST_ENCODING): tests/unit/test_encoding.c
@echo "🔨 Building encoding tests..."
@mkdir -p tests/unit
@$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
@echo "✓ Built: $@"

# Clean test artifacts
test-clean:
@echo "🧹 Cleaning test artifacts..."
@rm -f $(TEST_CRYPTO) $(TEST_ENCODING)
@rm -f tests/unit/*.o
@echo "✓ Test clean complete"

# ============================================================================
# Special targets
# ============================================================================
Expand Down
8 changes: 8 additions & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Test binaries
unit/test_crypto
unit/test_encoding

# Test artifacts
*.o
*.log
*.tmp
Loading
Loading