Skip to content

Commit eba9af8

Browse files
committed
Adding sample checks
1 parent 9e057c2 commit eba9af8

File tree

1 file changed

+178
-31
lines changed

1 file changed

+178
-31
lines changed

.github/workflows/samples.yml

Lines changed: 178 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ jobs:
1717
strategy:
1818
matrix:
1919
sample:
20-
- name: kvs_gstreamer_audio_video_sample
21-
args: -f sample.mp4
22-
- name: kvs_gstreamer_file_uploader_sample
23-
args: sample.mp4 0 audio-video
24-
# - name: kvs_gstreamer_multistream_sample
25-
# args: ""
26-
- name: kvs_gstreamer_sample
27-
args: sample.mp4
28-
- name: kvssink_gstreamer_sample
29-
args: sample.mp4
20+
# - name: kvs_gstreamer_audio_video_sample
21+
# args: -f sample.mp4
22+
# - name: kvs_gstreamer_file_uploader_sample
23+
# args: sample.mp4 0 audio-video
24+
- name: kvs_gstreamer_multistream_sample
25+
args: rtsp-urls.txt
26+
# - name: kvs_gstreamer_sample
27+
# args: sample.mp4
28+
# - name: kvssink_gstreamer_sample
29+
# args: sample.mp4
3030
runner:
31-
- id: macos-latest
32-
image: macos-latest
31+
- id: macos-13
32+
image: macos-13
3333

3434
- id: ubuntu-22.04
3535
image: ubuntu-latest
@@ -92,17 +92,14 @@ jobs:
9292
9393
- name: Build samples (Windows)
9494
if: runner.os == 'Windows'
95-
shell: cmd
9695
run: |
97-
@echo on
98-
set PATH=%PATH%;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Strawberry\c\bin;C:\Program Files\NASM;D:\a\amazon-kinesis-video-streams-producer-c\amazon-kinesis-video-streams-producer-c\open-source\lib;D:\a\amazon-kinesis-video-streams-producer-c\amazon-kinesis-video-streams-producer-c\open-source\bin
96+
$env:Path += ';C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Strawberry\c\bin;C:\Program Files\NASM;D:\producer\open-source\local\lib;D:\producer\open-source\local\bin'
97+
mkdir D:\producer
98+
Move-Item -Path "D:\a\amazon-kinesis-video-streams-producer-sdk-cpp\amazon-kinesis-video-streams-producer-sdk-cpp\*" -Destination "D:\producer"
99+
cd D:\producer
99100
git config --system core.longpaths true
100-
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
101-
mkdir build
102-
cd build
103-
cmake -G "NMake Makefiles" -DBUILD_GSTREAMER_PLUGIN=ON -DPKG_CONFIG_EXECUTABLE="D:\\gstreamer\\1.0\\msvc_x86_64\\bin\\pkg-config.exe" ..
104-
nmake
105-
mkdir "%KVS_DEBUG_DUMP_DATA_FILE_DIR%"
101+
dir
102+
.github\build_windows.bat
106103
107104
- name: Configure AWS Credentials
108105
uses: aws-actions/configure-aws-credentials@v4
@@ -112,8 +109,152 @@ jobs:
112109
aws-region: ${{ secrets.AWS_REGION }}
113110
role-duration-seconds: 10800
114111

112+
- name: Run multistream sample (Linux & Mac)
113+
if: (runner.os == 'Linux' || runner.os == 'macOS') && matrix.sample.name == 'kvs_gstreamer_multistream_sample'
114+
working-directory: ./build
115+
run: |
116+
set -x
117+
if [[ "$RUNNER_OS" == "Linux" ]]; then
118+
apt-get install -y docker.io ffmpeg
119+
else
120+
brew install ffmpeg
121+
brew install --cask docker
122+
open -a /Applications/Docker.app --args --unattended --accept-license
123+
echo "We are waiting for Docker to be up and running. It can take over 2 minutes..."
124+
while ! /Applications/Docker.app/Contents/Resources/bin/docker info &>/dev/null; do sleep 1; done
125+
126+
sudo ln -s ~/.docker/run/docker.sock /var/run/docker.sock
127+
fi
128+
129+
docker run -d --rm -it -e RTSP_PROTOCOLS=tcp -p 8554:8554 bluenviron/mediamtx:latest
130+
docker run -d --rm -it -e RTSP_PROTOCOLS=tcp -p 8555:8554 bluenviron/mediamtx:latest
131+
132+
(
133+
ffmpeg -re -f lavfi -i "testsrc=size=640x480:rate=10" -vcodec libx264 -x264-params keyint=25:scenecut=0 -f rtsp rtsp://localhost:8554/mystream
134+
) &
135+
(
136+
ffmpeg -re -f lavfi -i "testsrc=size=640x480:rate=10" -vcodec libx264 -x264-params keyint=25:scenecut=0 -f rtsp rtsp://localhost:8555/mystream
137+
) &
138+
139+
echo "rtsp://0.0.0.0:8554/mystream" > rtsp-urls.txt
140+
echo "rtsp://0.0.0.0:8555/mystream" >> rtsp-urls.txt
141+
142+
sleep 5
143+
gst-discoverer-1.0 rtsp://0.0.0.0:8554/mystream
144+
gst-discoverer-1.0 rtsp://0.0.0.0:8555/mystream
145+
146+
set +e # Disable exit on error for the timeout command
147+
timeout --preserve-status --signal=SIGINT --kill-after=15s 30s \
148+
./${{ matrix.sample.name }} demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
149+
EXIT_CODE=$?
150+
set -e # Re-enable exit on error
151+
152+
# 0: Process exited after interrupt with code 0
153+
# 1: Process exited with error code 1
154+
# 137: Process killed by SIGKILL (if the --kill-after timeout is reached)
155+
echo "Command exited with code: $EXIT_CODE"
156+
if [ $EXIT_CODE -ne 0 ]; then
157+
echo "Command did not exit gracefully after interrupt."
158+
exit 1
159+
fi
160+
161+
shell: bash
162+
env:
163+
GST_PLUGIN_PATH: ${{ github.workspace }}/build
164+
KVS_DEBUG_DUMP_DATA_FILE_DIR: ${{ github.workspace }}/build/debug_output
165+
166+
- name: Run multistream sample (Windows)
167+
if: runner.os == 'Windows' && matrix.sample.name == 'kvs_gstreamer_multistream_sample'
168+
shell: pwsh
169+
working-directory: D:\producer\build
170+
run: |
171+
# Equivalent to set -x
172+
Set-PSDebug -Trace 1
173+
174+
Invoke-WebRequest -Uri "https://github.com/bluenviron/mediamtx/releases/download/v1.11.2/mediamtx_v1.11.2_windows_amd64.zip" -OutFile "mediamtx.zip"
175+
Expand-Archive -Path mediamtx.zip -DestinationPath .
176+
177+
$env:Path += ';C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Strawberry\c\bin;C:\Program Files\NASM;D:\producer\open-source\local\lib;D:\producer\open-source\local\bin;D:\gstreamer\1.0\msvc_x86_64\bin'
178+
179+
echo "paths:
180+
all:
181+
source: publisher
182+
stream1:
183+
runOnInit: `"gst-launch-1.0 videotestsrc pattern=ball ! videoscale ! video/x-raw,width=640,height=480,framerate=10/1 ! x264enc tune=zerolatency bitrate=512 ! rtph264pay name=pay0 pt=96 ! udpsink host=127.0.0.1 port=5004`"
184+
runOnInitRestart: yes
185+
stream2:
186+
runOnInit: `"gst-launch-1.0 videotestsrc ! videoscale ! video/x-raw,width=640,height=480,framerate=10/1 ! x264enc tune=zerolatency bitrate=512 ! rtph264pay name=pay0 pt=96 ! udpsink host=127.0.0.1 port=5006`"
187+
runOnInitRestart: yes" | Out-File -FilePath mediamtx.yml -Encoding utf8
188+
189+
Start-Process -NoNewWindow -FilePath ".\mediamtx.exe" -ArgumentList "mediamtx.yml"
190+
191+
echo "rtsp://127.0.0.1:8554/stream1" | Out-File -FilePath rtsp-urls.txt -Encoding UTF8
192+
echo "rtsp://127.0.0.1:8554/stream2" | Out-File -FilePath rtsp-urls.txt -Append -Encoding UTF8
193+
194+
# Run the sample application
195+
Start-Sleep -Seconds 10 # Wait for server to be ready
196+
197+
mkdir D:\producer\debug_output
198+
199+
# Start the sample in a new console window
200+
$exePath = Join-Path $PWD ${{ matrix.sample.name }}.exe
201+
$process = Start-Process -FilePath $exePath -ArgumentList "demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}" -PassThru -NoNewWindow
202+
203+
# Wait for up to 30 seconds
204+
$timeout = 30
205+
$elapsed = 0
206+
while ($elapsed -lt $timeout) {
207+
Start-Sleep -Seconds 5
208+
$elapsed += 5
209+
if ($process.HasExited) {
210+
# In case there's a failure and it exits early
211+
break
212+
}
213+
}
214+
215+
# Check if the process is still running
216+
if (!$process.HasExited) {
217+
Write-Host "Process still running, sending Ctrl+C..."
218+
219+
# Send Ctrl+C by calling taskkill
220+
$processId = $process.Id
221+
Start-Process -NoNewWindow -FilePath "taskkill" -ArgumentList "/PID $processId /T /F"
222+
223+
# Wait 15 more seconds for it to exit gracefully
224+
$gracePeriod = 15
225+
$graceElapsed = 0
226+
while ($graceElapsed -lt $gracePeriod) {
227+
Start-Sleep -Seconds 5
228+
$graceElapsed += 5
229+
if ($process.HasExited) {
230+
# In case it doesn't need the full 15 seconds, speed up the job
231+
break
232+
}
233+
}
234+
}
235+
236+
# If it's STILL running, force kill it
237+
if (!$process.HasExited) {
238+
Write-Host "Process did not exit after Ctrl+C, force killing..."
239+
Start-Process -NoNewWindow -FilePath "taskkill" -ArgumentList "/PID $processId /T /F"
240+
Start-Sleep -Seconds 5 # Allow some time for cleanup
241+
}
242+
243+
# Get exit code
244+
$exitCode = if ($process.HasExited) { $process.ExitCode } else { 137 } # 137: Forced termination
245+
246+
Write-Host "Command exited with code: $exitCode"
247+
if ($exitCode -ne 0) {
248+
Write-Host "Command did not exit gracefully."
249+
exit 1
250+
}
251+
252+
env:
253+
GST_PLUGIN_PATH: D:\producer\build
254+
KVS_DEBUG_DUMP_DATA_FILE_DIR: D:\producer\debug_output
255+
115256
- name: Run ${{ matrix.sample.name }} (Linux & Mac)
116-
if: runner.os == 'Linux' || runner.os == 'macOS'
257+
if: (runner.os == 'Linux' || runner.os == 'macOS') && matrix.sample.name != 'kvs_gstreamer_multistream_sample'
117258
env:
118259
GST_PLUGIN_PATH: ${{ github.workspace }}/build
119260
KVS_DEBUG_DUMP_DATA_FILE_DIR: ${{ github.workspace }}/build/debug_output
@@ -123,17 +264,23 @@ jobs:
123264
./${{ matrix.sample.name }} demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
124265
125266
- name: Run ${{ matrix.sample.name }} (Windows)
126-
if: runner.os == 'Windows'
267+
if: runner.os == 'Windows' && matrix.sample.name != 'kvs_gstreamer_multistream_sample'
127268
env:
128-
GST_PLUGIN_PATH: ${{ github.workspace }}/build
129-
KVS_DEBUG_DUMP_DATA_FILE_DIR: ${{ github.workspace }}/build/debug_output
130-
working-directory: ./build
269+
GST_PLUGIN_PATH: D:\producer\build
270+
KVS_DEBUG_DUMP_DATA_FILE_DIR: D:\producer\debug_output
271+
working-directory: D:\producer\build
131272
run: |
273+
# Equivalent to set -x
274+
Set-PSDebug -Trace 1
275+
132276
$env:Path += ';C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Strawberry\c\bin;C:\Program Files\NASM;D:\producer\open-source\local\lib;D:\producer\open-source\local\bin;D:\gstreamer\1.0\msvc_x86_64\bin'
133277
278+
mkdir D:\producer\debug_output
279+
134280
Invoke-WebRequest -Uri https://awsj-iot-handson.s3-ap-northeast-1.amazonaws.com/kvs-workshop/sample.mp4 -OutFile sample.mp4
135-
$exePath = Join-Path $PWD ${{ matrix.sample.name }}
136-
& $exePath.exe demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
281+
dir
282+
$exePath = Join-Path $PWD ${{ matrix.sample.name }}.exe
283+
& $exePath demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
137284
138285
- name: Verify MKV dump (Mac & Linux)
139286
if: runner.os == 'Linux' || runner.os == 'macOS'
@@ -154,13 +301,13 @@ jobs:
154301
done
155302
shell: bash
156303

157-
- name: Verify MKV dump
304+
- name: Verify MKV dump (Windows)
158305
if: runner.os == 'Windows'
159306
working-directory: D:\producer\build
160307
run: |
161308
$env:Path += ";C:\Program Files\MKVToolNix"
162-
dir debug_output
163-
$mkvFiles = Get-ChildItem -Path "D:\producer\build\debug_output" -Filter *.mkv
309+
dir D:\producer\debug_output
310+
$mkvFiles = Get-ChildItem -Path "D:\producer\debug_output" -Filter *.mkv
164311
if ($mkvFiles.Count -eq 0) {
165312
Write-Error "No MKV files found in D:\producer\build\debug_output"
166313
exit 1

0 commit comments

Comments
 (0)