Skip to content

Commit

Permalink
Adding sample checks
Browse files Browse the repository at this point in the history
  • Loading branch information
sirknightj committed Feb 7, 2025
1 parent 9e057c2 commit 078e697
Showing 1 changed file with 177 additions and 31 deletions.
208 changes: 177 additions & 31 deletions .github/workflows/samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ jobs:
strategy:
matrix:
sample:
- name: kvs_gstreamer_audio_video_sample
args: -f sample.mp4
- name: kvs_gstreamer_file_uploader_sample
args: sample.mp4 0 audio-video
# - name: kvs_gstreamer_multistream_sample
# args: ""
- name: kvs_gstreamer_sample
args: sample.mp4
- name: kvssink_gstreamer_sample
args: sample.mp4
# - name: kvs_gstreamer_audio_video_sample
# args: -f sample.mp4
# - name: kvs_gstreamer_file_uploader_sample
# args: sample.mp4 0 audio-video
- name: kvs_gstreamer_multistream_sample
args: rtsp-urls.txt
# - name: kvs_gstreamer_sample
# args: sample.mp4
# - name: kvssink_gstreamer_sample
# args: sample.mp4
runner:
- id: macos-latest
image: macos-latest
- id: macos-13
image: macos-13

- id: ubuntu-22.04
image: ubuntu-latest
Expand Down Expand Up @@ -92,17 +92,14 @@ jobs:
- name: Build samples (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
@echo on
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
$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'
mkdir D:\producer
Move-Item -Path "D:\a\amazon-kinesis-video-streams-producer-sdk-cpp\amazon-kinesis-video-streams-producer-sdk-cpp\*" -Destination "D:\producer"
cd D:\producer
git config --system core.longpaths true
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
mkdir build
cd build
cmake -G "NMake Makefiles" -DBUILD_GSTREAMER_PLUGIN=ON -DPKG_CONFIG_EXECUTABLE="D:\\gstreamer\\1.0\\msvc_x86_64\\bin\\pkg-config.exe" ..
nmake
mkdir "%KVS_DEBUG_DUMP_DATA_FILE_DIR%"
dir
.github\build_windows.bat
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -112,8 +109,151 @@ jobs:
aws-region: ${{ secrets.AWS_REGION }}
role-duration-seconds: 10800

- name: Run multistream sample (Linux & Mac)
if: (runner.os == 'Linux' || runner.os == 'macOS') && matrix.sample.name == 'kvs_gstreamer_multistream_sample'
working-directory: ./build
run: |
set -x
if [[ "$RUNNER_OS" == "Linux" ]]; then
apt-get install -y docker.io
else
brew install --cask docker
open -a /Applications/Docker.app --args --unattended --accept-license
echo "We are waiting for Docker to be up and running. It can take over 2 minutes..."
while ! /Applications/Docker.app/Contents/Resources/bin/docker info &>/dev/null; do sleep 1; done
sudo ln -s ~/.docker/run/docker.sock /var/run/docker.sock
fi
docker run -d --rm -it -e RTSP_PROTOCOLS=tcp -p 8554:8554 bluenviron/mediamtx:latest
docker run -d --rm -it -e RTSP_PROTOCOLS=tcp -p 8555:8554 bluenviron/mediamtx:latest
(
ffmpeg -re -f lavfi -i "testsrc=size=640x480:rate=10" -vcodec libx264 -x264-params keyint=25:scenecut=0 -f rtsp rtsp://localhost:8554/mystream
) &
(
ffmpeg -re -f lavfi -i "testsrc=size=640x480:rate=10" -vcodec libx264 -x264-params keyint=25:scenecut=0 -f rtsp rtsp://localhost:8555/mystream
) &
echo "rtsp://0.0.0.0:8554/mystream" > rtsp-urls.txt
echo "rtsp://0.0.0.0:8555/mystream" >> rtsp-urls.txt
sleep 5
gst-discoverer-1.0 rtsp://0.0.0.0:8554/mystream
gst-discoverer-1.0 rtsp://0.0.0.0:8555/mystream
set +e # Disable exit on error for the timeout command
timeout --preserve-status --signal=SIGINT --kill-after=15s 30s \
./${{ matrix.sample.name }} demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
EXIT_CODE=$?
set -e # Re-enable exit on error
# 0: Process exited after interrupt with code 0
# 1: Process exited with error code 1
# 137: Process killed by SIGKILL (if the --kill-after timeout is reached)
echo "Command exited with code: $EXIT_CODE"
if [ $EXIT_CODE -ne 0 ]; then
echo "Command did not exit gracefully after interrupt."
exit 1
fi
shell: bash
env:
GST_PLUGIN_PATH: ${{ github.workspace }}/build
KVS_DEBUG_DUMP_DATA_FILE_DIR: ${{ github.workspace }}/build/debug_output

- name: Run multistream sample (Windows)
if: runner.os == 'Windows' && matrix.sample.name == 'kvs_gstreamer_multistream_sample'
shell: pwsh
working-directory: D:\producer\build
run: |
# Equivalent to set -x
Set-PSDebug -Trace 1
Invoke-WebRequest -Uri "https://github.com/bluenviron/mediamtx/releases/download/v1.11.2/mediamtx_v1.11.2_windows_amd64.zip" -OutFile "mediamtx.zip"
Expand-Archive -Path mediamtx.zip -DestinationPath .
$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'
echo "paths:
all:
source: publisher
stream1:
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`"
runOnInitRestart: yes
stream2:
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`"
runOnInitRestart: yes" | Out-File -FilePath mediamtx.yml -Encoding utf8
Start-Process -NoNewWindow -FilePath ".\mediamtx.exe" -ArgumentList "mediamtx.yml"
echo "rtsp://127.0.0.1:8554/stream1" | Out-File -FilePath rtsp-urls.txt -Encoding UTF8
echo "rtsp://127.0.0.1:8554/stream2" | Out-File -FilePath rtsp-urls.txt -Append -Encoding UTF8
# Run the sample application
Start-Sleep -Seconds 10 # Wait for server to be ready
mkdir D:\producer\debug_output
# Start the sample in a new console window
$exePath = Join-Path $PWD ${{ matrix.sample.name }}.exe
$process = Start-Process -FilePath $exePath -ArgumentList "demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}" -PassThru -NoNewWindow
# Wait for up to 30 seconds
$timeout = 30
$elapsed = 0
while ($elapsed -lt $timeout) {
Start-Sleep -Seconds 5
$elapsed += 5
if ($process.HasExited) {
# In case there's a failure and it exits early
break
}
}
# Check if the process is still running
if (!$process.HasExited) {
Write-Host "Process still running, sending Ctrl+C..."
# Send Ctrl+C by calling taskkill
$processId = $process.Id
Start-Process -NoNewWindow -FilePath "taskkill" -ArgumentList "/PID $processId /T /F"
# Wait 15 more seconds for it to exit gracefully
$gracePeriod = 15
$graceElapsed = 0
while ($graceElapsed -lt $gracePeriod) {
Start-Sleep -Seconds 5
$graceElapsed += 5
if ($process.HasExited) {
# In case it doesn't need the full 15 seconds, speed up the job
break
}
}
}
# If it's STILL running, force kill it
if (!$process.HasExited) {
Write-Host "Process did not exit after Ctrl+C, force killing..."
Start-Process -NoNewWindow -FilePath "taskkill" -ArgumentList "/PID $processId /T /F"
Start-Sleep -Seconds 5 # Allow some time for cleanup
}
# Get exit code
$exitCode = if ($process.HasExited) { $process.ExitCode } else { 137 } # 137: Forced termination
Write-Host "Command exited with code: $exitCode"
if ($exitCode -ne 0) {
Write-Host "Command did not exit gracefully."
exit 1
}
env:
GST_PLUGIN_PATH: D:\producer\build
KVS_DEBUG_DUMP_DATA_FILE_DIR: D:\producer\debug_output

- name: Run ${{ matrix.sample.name }} (Linux & Mac)
if: runner.os == 'Linux' || runner.os == 'macOS'
if: (runner.os == 'Linux' || runner.os == 'macOS') && matrix.sample.name != 'kvs_gstreamer_multistream_sample'
env:
GST_PLUGIN_PATH: ${{ github.workspace }}/build
KVS_DEBUG_DUMP_DATA_FILE_DIR: ${{ github.workspace }}/build/debug_output
Expand All @@ -123,17 +263,23 @@ jobs:
./${{ matrix.sample.name }} demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
- name: Run ${{ matrix.sample.name }} (Windows)
if: runner.os == 'Windows'
if: runner.os == 'Windows' && matrix.sample.name != 'kvs_gstreamer_multistream_sample'
env:
GST_PLUGIN_PATH: ${{ github.workspace }}/build
KVS_DEBUG_DUMP_DATA_FILE_DIR: ${{ github.workspace }}/build/debug_output
working-directory: ./build
GST_PLUGIN_PATH: D:\producer\build
KVS_DEBUG_DUMP_DATA_FILE_DIR: D:\producer\debug_output
working-directory: D:\producer\build
run: |
# Equivalent to set -x
Set-PSDebug -Trace 1
$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'
mkdir D:\producer\debug_output
Invoke-WebRequest -Uri https://awsj-iot-handson.s3-ap-northeast-1.amazonaws.com/kvs-workshop/sample.mp4 -OutFile sample.mp4
$exePath = Join-Path $PWD ${{ matrix.sample.name }}
& $exePath.exe demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
dir
$exePath = Join-Path $PWD ${{ matrix.sample.name }}.exe
& $exePath demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
- name: Verify MKV dump (Mac & Linux)
if: runner.os == 'Linux' || runner.os == 'macOS'
Expand All @@ -154,13 +300,13 @@ jobs:
done
shell: bash

- name: Verify MKV dump
- name: Verify MKV dump (Windows)
if: runner.os == 'Windows'
working-directory: D:\producer\build
run: |
$env:Path += ";C:\Program Files\MKVToolNix"
dir debug_output
$mkvFiles = Get-ChildItem -Path "D:\producer\build\debug_output" -Filter *.mkv
dir D:\producer\debug_output
$mkvFiles = Get-ChildItem -Path "D:\producer\debug_output" -Filter *.mkv
if ($mkvFiles.Count -eq 0) {
Write-Error "No MKV files found in D:\producer\build\debug_output"
exit 1
Expand Down

0 comments on commit 078e697

Please sign in to comment.