Updated golang to 1.25.0 #8
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 ] | |
| jobs: | |
| test: | |
| name: Run Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - 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 Docker Image | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: needs.test.result == 'success' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and cache Docker image | |
| uses: docker/build-push-action@v5 | |
| 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: 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@v4 | |
| - name: Download Docker image artifact | |
| uses: actions/download-artifact@v4 | |
| 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: Start stream-webpage container | |
| run: | | |
| docker run -d \ | |
| --name stream-webpage \ | |
| --network host \ | |
| -e FRAMERATE=60 \ | |
| -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: Setup FFmpeg | |
| uses: FedericoCarboni/setup-ffmpeg@v3 | |
| id: setup-ffmpeg | |
| - name: Wait for services to start | |
| run: | | |
| echo "Waiting for services to start..." | |
| sleep 60 | |
| - 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 | |
| echo "Checking stream properties with ffprobe..." | |
| echo "Using ffprobe from: ${{ steps.setup-ffmpeg.outputs.ffmpeg-path }}/ffprobe" | |
| timeout 30 "${{ steps.setup-ffmpeg.outputs.ffmpeg-path }}/ffprobe" -v quiet -print_format json -show_streams rtmp://localhost:1935/live/stream > stream_info.json 2>/dev/null || { | |
| echo "Stream not available yet, checking container logs..." | |
| docker logs stream-webpage | |
| docker logs $(docker ps -q --filter ancestor=tiangolo/nginx-rtmp) | |
| exit 1 | |
| } | |
| # Check if stream matches expected resolution | |
| height=$(cat stream_info.json | jq -r '.streams[0].height // empty') | |
| width=$(cat stream_info.json | jq -r '.streams[0].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 '.' | |
| 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 |