Updated release workflow to use imagetools so that all platforms have release tags added #42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Validation | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| concurrency: | |
| group: pr-validation-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| test: | |
| name: Run Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24' | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Run tests | |
| run: | | |
| echo "Running Go tests..." | |
| go test -v -json ./... > test-results.json | |
| - name: Report test results | |
| uses: dorny/test-reporter@v2 | |
| if: always() | |
| with: | |
| name: Go Tests | |
| path: test-results.json | |
| reporter: golang-json | |
| fail-on-error: true | |
| build-image: | |
| name: Build Test Docker Image | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: needs.test.result == 'success' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and cache Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: false | |
| tags: stream-webpage:test-${{ github.run_id }} | |
| outputs: type=docker,dest=/tmp/stream-webpage-${{ github.run_id }}.tar | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Upload Docker image artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docker-image-${{ github.run_id }} | |
| path: /tmp/stream-webpage-${{ github.run_id }}.tar | |
| retention-days: 1 | |
| integration-test: | |
| name: Run Integration Test (${{ matrix.resolution }}) | |
| runs-on: ubuntu-latest | |
| needs: [test, build-image] | |
| if: needs.test.result == 'success' && needs.build-image.result == 'success' | |
| strategy: | |
| matrix: | |
| resolution: [720p, 1080p, 2k] | |
| include: | |
| - resolution: 720p | |
| expected_height: 720 | |
| expected_width: 1280 | |
| - resolution: 1080p | |
| expected_height: 1080 | |
| expected_width: 1920 | |
| - resolution: 2k | |
| expected_height: 1440 | |
| expected_width: 2560 | |
| services: | |
| rtmp-server: | |
| image: tiangolo/nginx-rtmp | |
| ports: | |
| - 1935:1935 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Download Docker image artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: docker-image-${{ github.run_id }} | |
| path: /tmp | |
| - name: Load Docker image | |
| run: docker load -i /tmp/stream-webpage-${{ github.run_id }}.tar | |
| - name: Install ffmpeg | |
| run: | | |
| echo "Installing FFmpeg..." | |
| sudo apt-get update | |
| sudo apt-get install -y ffmpeg | |
| - name: Start stream-webpage container | |
| run: | | |
| docker run -d \ | |
| --name stream-webpage \ | |
| --network host \ | |
| -e FRAMERATE=30 \ | |
| -e LOG_FORMAT=json \ | |
| -e LOG_LEVEL=debug \ | |
| -e PORT=8080 \ | |
| -e RESOLUTION=${{ matrix.resolution }} \ | |
| -e RTMP_URL=rtmp://localhost:1935/live/stream \ | |
| -e WEBPAGE_URL="https://www.youtube.com/embed/xuCn8ux2gbs?autoplay=1&loop=1&playlist=xuCn8ux2gbs" \ | |
| stream-webpage:test-${{ github.run_id }} | |
| - name: Wait for services to start | |
| run: | | |
| echo "Waiting for services to start..." | |
| sleep 60 | |
| - name: Test Stream Container Health Endpoint | |
| run: | | |
| echo "Testing stream container health endpoint..." | |
| response=$(curl -s -w "%{http_code}" http://localhost:8080/health) | |
| http_code="${response: -3}" | |
| response_body="${response%???}" | |
| echo "HTTP Status: $http_code" | |
| echo "Response: $response_body" | |
| if [[ "$http_code" != "200" ]]; then | |
| echo "Health check failed with HTTP status: $http_code" | |
| exit 1 | |
| else | |
| echo "Health check passed" | |
| fi | |
| - name: Test RTMP stream | |
| run: | | |
| echo "Testing RTMP stream..." | |
| # Test if RTMP server is accessible and stream is available | |
| timeout 30 bash -c ' | |
| while ! nc -z localhost 1935; do | |
| echo "Waiting for RTMP server..." | |
| sleep 2 | |
| done | |
| echo "RTMP server is ready" | |
| ' | |
| # Use ffprobe to check stream properties and wait for video stream | |
| echo "Checking stream properties with ffprobe and waiting for video stream..." | |
| timeout 300 bash -c ' | |
| while true; do | |
| if ffprobe -v quiet -print_format json -show_streams rtmp://localhost:1935/live/stream > stream_info.json 2>/dev/null; then | |
| # Check if we have a video stream | |
| video_stream_count=$(cat stream_info.json | jq -r "[.streams[] | select(.codec_type == \"video\")] | length") | |
| if [ "$video_stream_count" -gt 0 ]; then | |
| echo "Video stream found! Stream is ready." | |
| break | |
| else | |
| echo "Only audio stream found, waiting for video stream..." | |
| fi | |
| else | |
| echo "Stream not yet available, retrying..." | |
| fi | |
| sleep 2 | |
| done | |
| ' || { | |
| echo "Timeout waiting for video stream, checking container logs..." | |
| docker logs stream-webpage | |
| exit 1 | |
| } | |
| # Check if stream matches expected resolution | |
| height=$(cat stream_info.json | jq -r '.streams[] | select(.codec_type == "video") | .height // empty') | |
| width=$(cat stream_info.json | jq -r '.streams[] | select(.codec_type == "video") | .width // empty') | |
| echo "Stream resolution: ${width}x${height}" | |
| echo "Expected resolution: ${{ matrix.expected_width }}x${{ matrix.expected_height }}" | |
| if [ "$height" = "${{ matrix.expected_height }}" ] && [ "$width" = "${{ matrix.expected_width }}" ]; then | |
| echo "✅ Stream is ${{ matrix.resolution }} as expected" | |
| else | |
| echo "❌ Stream is not ${{ matrix.resolution }}. Expected ${{ matrix.expected_width }}x${{ matrix.expected_height }}, got ${width}x${height}" | |
| cat stream_info.json | jq '.' | |
| docker logs stream-webpage | |
| exit 1 | |
| fi | |
| echo "✅ Integration test completed successfully" | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| echo "Stopping stream-webpage container..." | |
| docker stop stream-webpage || true | |
| docker rm stream-webpage || true |