Skip to content

Commit 3f81f6b

Browse files
committed
Add CICD for AWS IVS stream.
1 parent c5e1b7b commit 3f81f6b

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

.github/workflows/test.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: "Test"
33
on:
44
push:
55
pull_request:
6+
workflow_dispatch:
67

78
permissions: read-all
89

@@ -152,6 +153,109 @@ jobs:
152153
run: exit 1
153154
runs-on: ubuntu-22.04
154155

156+
ivs:
157+
name: "FFmpeg with AWS IVS"
158+
# The IVS test requires AWS credentials, which is not available for pull requests.
159+
if: github.event_name != 'pull_request'
160+
#needs: build
161+
steps:
162+
- name: Configure AWS credentials
163+
uses: aws-actions/configure-aws-credentials@v4
164+
with:
165+
aws-access-key-id: ${{ secrets.AWS_IVS_AKID }}
166+
aws-secret-access-key: ${{ secrets.AWS_IVS_AKSECRET }}
167+
aws-region: us-west-2
168+
- name: Check AWS credentials
169+
run: |
170+
set -euo pipefail
171+
aws sts get-caller-identity
172+
- name: Checkout repository
173+
uses: actions/checkout@v4
174+
- name: Create IVS Participant Token
175+
id: create-token
176+
run: |
177+
set -euo pipefail
178+
179+
sudo apt-get update
180+
sudo apt-get install -y jq
181+
182+
# Set duration in minutes, default is 720 (12 hours).
183+
echo "::add-mask::${{ secrets.AWS_IVS_STAGE }}"
184+
TOKEN=$(aws ivs-realtime create-participant-token\
185+
--region us-west-2 \
186+
--user-id publisher-user --capabilities PUBLISH \
187+
--stage-arn "${{ secrets.AWS_IVS_STAGE }}" \
188+
--duration 10 |jq -r '.participantToken.token')
189+
190+
echo "::add-mask::$TOKEN"
191+
echo "token=${TOKEN}" >> $GITHUB_OUTPUT
192+
- name: Build FFmpeg
193+
run: |
194+
set -euo pipefail
195+
196+
# Install dependencies
197+
sudo apt-get update
198+
sudo apt-get install -y nasm pkg-config libssl-dev libopus-dev libx264-dev
199+
200+
# Build FFmpeg with WebRTC support
201+
./configure --enable-muxer=whip --enable-openssl --enable-version3 \
202+
--enable-libx264 --enable-gpl --enable-libopus
203+
make -j$(nproc)
204+
./ffmpeg -version && ./ffmpeg -muxers 2>/dev/null |grep whip
205+
- name: Streaming with FFmpeg
206+
run: |
207+
set -euo pipefail
208+
TOKEN="${{ steps.create-token.outputs.token }}"
209+
nohup ./ffmpeg -t 30 -re -i bbb-4mbps-baseline-opus.mp4 -c copy \
210+
-f whip -authorization "$TOKEN" "https://global.whip.live-video.net" \
211+
1>ffstdout.log 2>ffstderr.log &
212+
- name: Check IVS Streaming
213+
id: streaming
214+
run: |
215+
set -euo pipefail
216+
217+
# Check streams in IVS.
218+
for ((i=0; i<10; i++)); do
219+
SESSION=$(aws ivs-realtime list-stage-sessions \
220+
--region us-west-2 --stage-arn "${{ secrets.AWS_IVS_STAGE }}" \
221+
--query 'stageSessions[?endTime==`null`]' |jq -r '.[0]?.sessionId')
222+
223+
if [[ "$SESSION" != "" && "$SESSION" != "null" ]]; then
224+
STREAM=$(aws ivs-realtime list-participants \
225+
--region us-west-2 --stage-arn "${{ secrets.AWS_IVS_STAGE }}" \
226+
--session-id "${SESSION}" --filter-by-published |jq -r '.participants[0].participantId')
227+
fi
228+
229+
if [[ "$STREAM" != "" ]]; then
230+
echo 'Test OK';
231+
echo "has_stream=true" >> $GITHUB_OUTPUT
232+
break;
233+
fi
234+
sleep 3
235+
done
236+
237+
if [[ "$STREAM" == "" ]]; then
238+
echo "Stream not found: $STREAM"
239+
echo "has_stream=false" >> $GITHUB_OUTPUT
240+
fi
241+
- name: Stop FFmpeg normally
242+
run: |
243+
pkill -SIGINT ffmpeg && sleep 3 ||
244+
echo "FFmpeg process not found or already stopped."
245+
- name: Show FFmpeg Stdout Log
246+
run: cat ffstdout.log
247+
- name: Show FFmpeg Stderr Log
248+
run: cat ffstderr.log
249+
- name: Check FFmpeg Exit Log
250+
run: |
251+
set -euo pipefail
252+
cat ffstderr.log |grep 'Exiting normally' && exit 0
253+
echo "Exiting normally not found in ffstderr.log" && exit 1
254+
- name: Check Stream Existence
255+
if: ${{ steps.streaming.outputs.has_stream == 'false' }}
256+
run: exit 1
257+
runs-on: ubuntu-22.04
258+
155259
asan:
156260
name: "FFmpeg with Asan"
157261
needs: build
@@ -705,6 +809,7 @@ jobs:
705809
needs:
706810
- fate
707811
- srs
812+
- ivs
708813
- asan
709814
- openssl-1-0-1k
710815
- openssl-1-0-2

0 commit comments

Comments
 (0)