-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (161 loc) · 5.73 KB
/
pr.yaml
File metadata and controls
193 lines (161 loc) · 5.73 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
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: 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 120
- 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
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 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