-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (119 loc) · 4.15 KB
/
pr.yaml
File metadata and controls
142 lines (119 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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: Run tests
run: |
echo "Running Go tests..."
go test -v -json ./... > test-results.json
- name: Report test results
uses: dorny/test-reporter@v1
if: always()
with:
name: Go Tests
path: test-results.json
reporter: golang-json
fail-on-error: true
integration-test:
name: Integration Test (${{ matrix.resolution }})
runs-on: ubuntu-latest
needs: test
if: needs.test.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: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: stream-webpage:test
load: true
- 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
- name: Setup FFmpeg
uses: FedericoCarboni/setup-ffmpeg@v3
- name: Wait for services to start
run: |
echo "Waiting for services to start..."
sleep 30
- 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..."
timeout 30 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 $(docker ps -q --filter ancestor=stream-webpage:test)
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