Skip to content

Commit dce7be6

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

File tree

1 file changed

+168
-31
lines changed

1 file changed

+168
-31
lines changed

.github/workflows/samples.yml

Lines changed: 168 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,142 @@ 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
119+
else
120+
brew install --cask docker
121+
open -a /Applications/Docker.app --args --unattended --accept-license
122+
echo "We are waiting for Docker to be up and running. It can take over 2 minutes..."
123+
while ! /Applications/Docker.app/Contents/Resources/bin/docker info &>/dev/null; do sleep 1; done
124+
125+
sudo ln -s ~/.docker/run/docker.sock /var/run/docker.sock
126+
fi
127+
128+
docker run -d --rm -e RTSP_PORT=8558 -p 8558:8558 -e GST_PIPELINE="videotestsrc pattern=ball ! videoscale ! video/x-raw,width=640,height=480,framerate=10/1 ! x264enc tune=zerolatency bitrate=512 ! rtph264pay name=pay0 pt=96" -e STREAM_NAME=stream1 bluenviron/mediamtx
129+
docker run -d --rm -e RTSP_PORT=8559 -p 8559:8559 -e GST_PIPELINE="videotestsrc ! videoscale ! video/x-raw,width=640,height=480,framerate=10/1 ! x264enc tune=zerolatency bitrate=512 ! rtph264pay name=pay0 pt=96" -e STREAM_NAME=stream2 bluenviron/mediamtx
130+
131+
echo "rtsp://0.0.0.0:8558/stream1" > rtsp-urls.txt
132+
echo "rtsp://0.0.0.0:8559/stream2" >> rtsp-urls.txt
133+
134+
sleep 5
135+
136+
set +e # Disable exit on error for the timeout command
137+
timeout --preserve-status --signal=SIGINT --kill-after=15s 30s \
138+
./${{ matrix.sample.name }} demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
139+
EXIT_CODE=$?
140+
set -e # Re-enable exit on error
141+
142+
# 0: Process exited after interrupt with code 0
143+
# 1: Process exited with error code 1
144+
# 137: Process killed by SIGKILL (if the --kill-after timeout is reached)
145+
echo "Command exited with code: $EXIT_CODE"
146+
if [ $EXIT_CODE -ne 0 ]; then
147+
echo "Command did not exit gracefully after interrupt."
148+
exit 1
149+
fi
150+
151+
shell: bash
152+
env:
153+
GST_PLUGIN_PATH: ${{ github.workspace }}/build
154+
KVS_DEBUG_DUMP_DATA_FILE_DIR: ${{ github.workspace }}/build/debug_output
155+
156+
- name: Run multistream sample (Windows)
157+
if: runner.os == 'Windows' && matrix.sample.name == 'kvs_gstreamer_multistream_sample'
158+
shell: pwsh
159+
working-directory: D:\producer\build
160+
run: |
161+
# Equivalent to set -x
162+
Set-PSDebug -Trace 1
163+
164+
Invoke-WebRequest -Uri "https://github.com/bluenviron/mediamtx/releases/download/v1.11.2/mediamtx_v1.11.2_windows_amd64.zip" -OutFile "mediamtx.zip"
165+
Expand-Archive -Path mediamtx.zip -DestinationPath .
166+
167+
$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'
168+
169+
echo "paths:
170+
all:
171+
source: publisher
172+
stream1:
173+
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`"
174+
runOnInitRestart: yes
175+
stream2:
176+
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`"
177+
runOnInitRestart: yes" | Out-File -FilePath mediamtx.yml -Encoding utf8
178+
179+
Start-Process -NoNewWindow -FilePath ".\mediamtx.exe" -ArgumentList "mediamtx.yml"
180+
181+
echo "rtsp://127.0.0.1:8554/stream1" | Out-File -FilePath rtsp-urls.txt -Encoding UTF8
182+
echo "rtsp://127.0.0.1:8554/stream2" | Out-File -FilePath rtsp-urls.txt -Append -Encoding UTF8
183+
184+
# Run the sample application
185+
Start-Sleep -Seconds 10 # Wait for server to be ready
186+
187+
mkdir D:\producer\debug_output
188+
189+
# Start the sample in a new console window
190+
$exePath = Join-Path $PWD ${{ matrix.sample.name }}.exe
191+
$process = Start-Process -FilePath $exePath -ArgumentList "demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}" -PassThru -NoNewWindow
192+
193+
# Wait for up to 30 seconds
194+
$timeout = 30
195+
$elapsed = 0
196+
while ($elapsed -lt $timeout) {
197+
Start-Sleep -Seconds 5
198+
$elapsed += 5
199+
if ($process.HasExited) {
200+
# In case there's a failure and it exits early
201+
break
202+
}
203+
}
204+
205+
# Check if the process is still running
206+
if (!$process.HasExited) {
207+
Write-Host "Process still running, sending Ctrl+C..."
208+
209+
# Send Ctrl+C by calling taskkill
210+
$processId = $process.Id
211+
Start-Process -NoNewWindow -FilePath "taskkill" -ArgumentList "/PID $processId /T /F"
212+
213+
# Wait 15 more seconds for it to exit gracefully
214+
$gracePeriod = 15
215+
$graceElapsed = 0
216+
while ($graceElapsed -lt $gracePeriod) {
217+
Start-Sleep -Seconds 5
218+
$graceElapsed += 5
219+
if ($process.HasExited) {
220+
# In case it doesn't need the full 15 seconds, speed up the job
221+
break
222+
}
223+
}
224+
}
225+
226+
# If it's STILL running, force kill it
227+
if (!$process.HasExited) {
228+
Write-Host "Process did not exit after Ctrl+C, force killing..."
229+
Start-Process -NoNewWindow -FilePath "taskkill" -ArgumentList "/PID $processId /T /F"
230+
Start-Sleep -Seconds 5 # Allow some time for cleanup
231+
}
232+
233+
# Get exit code
234+
$exitCode = if ($process.HasExited) { $process.ExitCode } else { 137 } # 137: Forced termination
235+
236+
Write-Host "Command exited with code: $exitCode"
237+
if ($exitCode -ne 0) {
238+
Write-Host "Command did not exit gracefully."
239+
exit 1
240+
}
241+
242+
env:
243+
GST_PLUGIN_PATH: D:\producer\build
244+
KVS_DEBUG_DUMP_DATA_FILE_DIR: D:\producer\debug_output
245+
115246
- name: Run ${{ matrix.sample.name }} (Linux & Mac)
116-
if: runner.os == 'Linux' || runner.os == 'macOS'
247+
if: (runner.os == 'Linux' || runner.os == 'macOS') && matrix.sample.name != 'kvs_gstreamer_multistream_sample'
117248
env:
118249
GST_PLUGIN_PATH: ${{ github.workspace }}/build
119250
KVS_DEBUG_DUMP_DATA_FILE_DIR: ${{ github.workspace }}/build/debug_output
@@ -123,17 +254,23 @@ jobs:
123254
./${{ matrix.sample.name }} demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
124255
125256
- name: Run ${{ matrix.sample.name }} (Windows)
126-
if: runner.os == 'Windows'
257+
if: runner.os == 'Windows' && matrix.sample.name != 'kvs_gstreamer_multistream_sample'
127258
env:
128-
GST_PLUGIN_PATH: ${{ github.workspace }}/build
129-
KVS_DEBUG_DUMP_DATA_FILE_DIR: ${{ github.workspace }}/build/debug_output
130-
working-directory: ./build
259+
GST_PLUGIN_PATH: D:\producer\build
260+
KVS_DEBUG_DUMP_DATA_FILE_DIR: D:\producer\debug_output
261+
working-directory: D:\producer\build
131262
run: |
263+
# Equivalent to set -x
264+
Set-PSDebug -Trace 1
265+
132266
$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'
133267
268+
mkdir D:\producer\debug_output
269+
134270
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 }}
271+
dir
272+
$exePath = Join-Path $PWD ${{ matrix.sample.name }}.exe
273+
& $exePath demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
137274
138275
- name: Verify MKV dump (Mac & Linux)
139276
if: runner.os == 'Linux' || runner.os == 'macOS'
@@ -154,13 +291,13 @@ jobs:
154291
done
155292
shell: bash
156293

157-
- name: Verify MKV dump
294+
- name: Verify MKV dump (Windows)
158295
if: runner.os == 'Windows'
159296
working-directory: D:\producer\build
160297
run: |
161298
$env:Path += ";C:\Program Files\MKVToolNix"
162-
dir debug_output
163-
$mkvFiles = Get-ChildItem -Path "D:\producer\build\debug_output" -Filter *.mkv
299+
dir D:\producer\debug_output
300+
$mkvFiles = Get-ChildItem -Path "D:\producer\debug_output" -Filter *.mkv
164301
if ($mkvFiles.Count -eq 0) {
165302
Write-Error "No MKV files found in D:\producer\build\debug_output"
166303
exit 1

0 commit comments

Comments
 (0)