Skip to content

Commit 5d93056

Browse files
JackLau1222github-actions[bot]
authored andcommitted
workflows/test: build FFmpeg once per TLS backend and reuse via artifacts
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
1 parent 096a089 commit 5d93056

File tree

1 file changed

+119
-186
lines changed

1 file changed

+119
-186
lines changed

.github/workflows/test.yml

Lines changed: 119 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,92 @@ jobs:
6262
make fate -j$(nproc) SAMPLES=$(pwd)/fate-suite
6363
runs-on: ubuntu-22.04
6464

65-
srs:
66-
name: "FFmpeg with SRS"
65+
build:
66+
name: "Build FFmpeg (${{ matrix.tls }})"
67+
strategy:
68+
fail-fast: false
69+
matrix:
70+
tls: [openssl, gnutls, mbedtls]
6771
steps:
6872
- name: Checkout repository
6973
uses: actions/checkout@v4
74+
- name: Install dependencies
75+
run: |
76+
set -euxo pipefail
77+
sudo apt-get update
78+
sudo apt-get install -y nasm pkg-config jq libopus-dev libx264-dev
79+
if [[ "${{ matrix.tls }}" == "openssl" ]]; then
80+
sudo apt-get install -y libssl-dev
81+
elif [[ "${{ matrix.tls }}" == "gnutls" ]]; then
82+
sudo apt-get install -y gnutls-bin libgnutls28-dev
83+
elif [[ "${{ matrix.tls }}" == "mbedtls" ]]; then
84+
sudo apt-get install -y cmake
85+
fi
86+
- name: Build mbedTLS
87+
if: matrix.tls == 'mbedtls'
88+
run: |
89+
set -euxo pipefail
90+
curl -s -L https://github.com/Mbed-TLS/mbedtls/releases/download/mbedtls-3.6.2/mbedtls-3.6.2.tar.bz2 | tar xj
91+
cd mbedtls-3.6.2
92+
scripts/config.py set MBEDTLS_SSL_DTLS_SRTP
93+
mkdir build && cd build
94+
cmake -DCMAKE_INSTALL_PREFIX=$HOME/.release/mbedtls \
95+
-DUSE_SHARED_MBEDTLS_LIBRARY=Off -DENABLE_SHARED=Off -DENABLE_STATIC=On ..
96+
make -j$(nproc) && make install
7097
- name: Build FFmpeg
7198
run: |
7299
set -euxo pipefail
100+
if [[ "${{ matrix.tls }}" == "openssl" ]]; then
101+
./configure --enable-muxer=whip --enable-openssl --enable-version3 \
102+
--enable-libx264 --enable-gpl --enable-libopus
103+
elif [[ "${{ matrix.tls }}" == "gnutls" ]]; then
104+
./configure --enable-muxer=whip --enable-gnutls \
105+
--enable-libx264 --enable-gpl --enable-libopus
106+
elif [[ "${{ matrix.tls }}" == "mbedtls" ]]; then
107+
PKG_CONFIG_PATH="$HOME/.release/mbedtls/lib/pkgconfig" \
108+
./configure --enable-muxer=whip --enable-mbedtls --enable-version3 \
109+
--extra-cflags="-I$HOME/.release/mbedtls/include" \
110+
--extra-ldflags="-L$HOME/.release/mbedtls/lib" \
111+
--pkg-config-flags="--static" \
112+
--enable-libx264 --enable-gpl --enable-libopus
113+
fi
114+
make -j$(nproc)
115+
./ffmpeg -version && ./ffmpeg -muxers 2>/dev/null |grep whip
116+
- name: Upload FFmpeg binary
117+
uses: actions/upload-artifact@v4
118+
with:
119+
name: ffmpeg-${{ matrix.tls }}
120+
path: ./ffmpeg
121+
retention-days: 1
122+
runs-on: ubuntu-22.04
73123

74-
# Install dependencies
124+
srs:
125+
name: "SRS with FFmpeg (${{ matrix.tls }})"
126+
needs: build
127+
strategy:
128+
fail-fast: false
129+
matrix:
130+
tls: [openssl, gnutls, mbedtls]
131+
steps:
132+
- name: Checkout repository
133+
uses: actions/checkout@v4
134+
- name: Install runtime dependencies
135+
run: |
136+
set -euxo pipefail
75137
sudo apt-get update
76-
sudo apt-get install -y nasm pkg-config jq libssl-dev libopus-dev libx264-dev
77-
78-
# Build FFmpeg with WebRTC support
79-
./configure --enable-muxer=whip --enable-openssl --enable-version3 \
80-
--enable-libx264 --enable-gpl --enable-libopus
81-
make -j$(nproc)
138+
sudo apt-get install -y jq libopus-dev libx264-dev
139+
if [[ "${{ matrix.tls }}" == "openssl" ]]; then
140+
sudo apt-get install -y libssl-dev
141+
elif [[ "${{ matrix.tls }}" == "gnutls" ]]; then
142+
sudo apt-get install -y libgnutls28-dev
143+
fi
144+
- name: Download FFmpeg binary
145+
uses: actions/download-artifact@v4
146+
with:
147+
name: ffmpeg-${{ matrix.tls }}
148+
- name: Verify FFmpeg
149+
run: |
150+
chmod +x ./ffmpeg
82151
./ffmpeg -version && ./ffmpeg -muxers 2>/dev/null |grep whip
83152
- name: Start SRS Docker container
84153
run: |
@@ -133,22 +202,32 @@ jobs:
133202
runs-on: ubuntu-22.04
134203

135204
pion:
136-
name: "FFmpeg with Pion"
205+
name: "Pion with FFmpeg (${{ matrix.tls }})"
206+
needs: build
207+
strategy:
208+
fail-fast: false
209+
matrix:
210+
tls: [openssl, gnutls, mbedtls]
137211
steps:
138212
- name: Checkout repository
139213
uses: actions/checkout@v4
140-
- name: Build FFmpeg
214+
- name: Install runtime dependencies
141215
run: |
142216
set -euxo pipefail
143-
144-
# Install dependencies
145217
sudo apt-get update
146-
sudo apt-get install -y nasm pkg-config jq libssl-dev libopus-dev libx264-dev
147-
148-
# Build FFmpeg with WebRTC support
149-
./configure --enable-muxer=whip --enable-openssl --enable-version3 \
150-
--enable-libx264 --enable-gpl --enable-libopus
151-
make -j$(nproc)
218+
sudo apt-get install -y jq libopus-dev libx264-dev
219+
if [[ "${{ matrix.tls }}" == "openssl" ]]; then
220+
sudo apt-get install -y libssl-dev
221+
elif [[ "${{ matrix.tls }}" == "gnutls" ]]; then
222+
sudo apt-get install -y libgnutls28-dev
223+
fi
224+
- name: Download FFmpeg binary
225+
uses: actions/download-artifact@v4
226+
with:
227+
name: ffmpeg-${{ matrix.tls }}
228+
- name: Verify FFmpeg
229+
run: |
230+
chmod +x ./ffmpeg
152231
./ffmpeg -version && ./ffmpeg -muxers 2>/dev/null |grep whip
153232
- name: Set up Go
154233
uses: actions/setup-go@v4
@@ -198,22 +277,32 @@ jobs:
198277
runs-on: ubuntu-22.04
199278

200279
janus:
201-
name: "FFmpeg with Janus"
280+
name: "Janus with FFmpeg (${{ matrix.tls }})"
281+
needs: build
282+
strategy:
283+
fail-fast: false
284+
matrix:
285+
tls: [openssl, gnutls, mbedtls]
202286
steps:
203287
- name: Checkout repository
204288
uses: actions/checkout@v4
205-
- name: Build FFmpeg
289+
- name: Install runtime dependencies
206290
run: |
207291
set -euxo pipefail
208-
209-
# Install dependencies
210292
sudo apt-get update
211-
sudo apt-get install -y nasm pkg-config jq libssl-dev libopus-dev libx264-dev
212-
213-
# Build FFmpeg with WebRTC support
214-
./configure --enable-muxer=whip --enable-openssl --enable-version3 \
215-
--enable-libx264 --enable-gpl --enable-libopus
216-
make -j$(nproc)
293+
sudo apt-get install -y jq libopus-dev libx264-dev
294+
if [[ "${{ matrix.tls }}" == "openssl" ]]; then
295+
sudo apt-get install -y libssl-dev
296+
elif [[ "${{ matrix.tls }}" == "gnutls" ]]; then
297+
sudo apt-get install -y libgnutls28-dev
298+
fi
299+
- name: Download FFmpeg binary
300+
uses: actions/download-artifact@v4
301+
with:
302+
name: ffmpeg-${{ matrix.tls }}
303+
- name: Verify FFmpeg
304+
run: |
305+
chmod +x ./ffmpeg
217306
./ffmpeg -version && ./ffmpeg -muxers 2>/dev/null |grep whip
218307
- name: Start Janus
219308
run: |
@@ -591,173 +680,17 @@ jobs:
591680
run: exit 1
592681
runs-on: ubuntu-22.04
593682

594-
gnutls:
595-
name: "With GnuTLS"
596-
steps:
597-
- name: Checkout repository
598-
uses: actions/checkout@v4
599-
- name: Install GnuTLS and Download Test File
600-
run: |
601-
set -euxo pipefail
602-
sudo apt-get update
603-
sudo apt-get install -y nasm pkg-config jq gnutls-bin libgnutls28-dev
604-
curl -s -L -O https://github.com/ossrs/ffmpeg-webrtc/releases/download/pre-release/bbb-4mbps-baseline-opus.mp4
605-
- name: Build FFmpeg
606-
run: |
607-
set -euxo pipefail
608-
609-
# Build FFmpeg with WebRTC support using GnuTLS
610-
./configure --enable-muxer=whip --enable-gnutls
611-
make -j$(nproc)
612-
./ffmpeg -version && ./ffmpeg -muxers 2>/dev/null |grep whip
613-
- name: Start SRS Docker container
614-
run: |
615-
set -euxo pipefail
616-
ip=$(ifconfig eth0 | grep 'inet ' | awk '{print $2}')
617-
docker run --rm -d -p 1935:1935 -p 1985:1985 -p 8080:8080 \
618-
--env CANDIDATE=$ip -p 8000:8000/udp \
619-
ossrs/srs:5 ./objs/srs -c conf/rtc2rtmp.conf
620-
- name: Streaming with FFmpeg
621-
run: |
622-
set -euxo pipefail
623-
nohup ./ffmpeg -t 30 -re -i bbb-4mbps-baseline-opus.mp4 -c copy \
624-
-f whip "http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream" \
625-
1>ffstdout.log 2>ffstderr.log &
626-
- name: Check SRS Streaming
627-
id: streaming
628-
run: |
629-
set -euxo pipefail
630-
631-
# Check streams in SRS.
632-
for ((i=0; i<10; i++)); do
633-
STREAM=$(curl -s http://localhost:1985/api/v1/streams/ | jq -r '.streams[].name')
634-
if [[ "$STREAM" == "livestream" ]]; then
635-
echo 'Test OK';
636-
echo "has_stream=true" >> $GITHUB_OUTPUT
637-
break;
638-
fi
639-
sleep 3
640-
done
641-
642-
if [[ "$STREAM" != "livestream" ]]; then
643-
echo "Stream not found: $STREAM"
644-
echo "has_stream=false" >> $GITHUB_OUTPUT
645-
fi
646-
- name: Stop FFmpeg normally
647-
run: |
648-
pkill -SIGINT ffmpeg && sleep 3 ||
649-
echo "FFmpeg process not found or already stopped."
650-
- name: Show FFmpeg Stdout Log
651-
run: cat ffstdout.log
652-
- name: Show FFmpeg Stderr Log
653-
run: cat ffstderr.log
654-
- name: Check FFmpeg Exit Log
655-
run: |
656-
set -euxo pipefail
657-
cat ffstderr.log |grep 'Exiting normally' && exit 0
658-
echo "Exiting normally not found in ffstderr.log" && exit 1
659-
- name: Check Stream Existence
660-
if: ${{ steps.streaming.outputs.has_stream == 'false' }}
661-
run: exit 1
662-
runs-on: ubuntu-22.04
663-
664-
mbedtls:
665-
name: "With mbedTLS 3.6.2"
666-
steps:
667-
- name: Checkout repository
668-
uses: actions/checkout@v4
669-
- name: Build mbedTLS
670-
run: |
671-
set -euxo pipefail
672-
sudo apt-get update
673-
sudo apt-get install -y nasm pkg-config jq cmake
674-
curl -s -L https://github.com/Mbed-TLS/mbedtls/releases/download/mbedtls-3.6.2/mbedtls-3.6.2.tar.bz2 | tar xj
675-
cd mbedtls-3.6.2
676-
scripts/config.py set MBEDTLS_SSL_DTLS_SRTP
677-
mkdir build && cd build
678-
cmake -DCMAKE_INSTALL_PREFIX=$HOME/.release/mbedtls \
679-
-DUSE_SHARED_MBEDTLS_LIBRARY=Off -DENABLE_SHARED=Off -DENABLE_STATIC=On ..
680-
make -j$(nproc) && make install
681-
- name: Download Test File
682-
run: |
683-
set -euxo pipefail
684-
curl -s -L -O https://github.com/ossrs/ffmpeg-webrtc/releases/download/pre-release/bbb-4mbps-baseline-opus.mp4
685-
- name: Build FFmpeg
686-
run: |
687-
set -euxo pipefail
688-
689-
# Build FFmpeg with WebRTC support using mbedTLS
690-
PKG_CONFIG_PATH="$HOME/.release/mbedtls/lib/pkgconfig" \
691-
./configure --enable-muxer=whip --enable-mbedtls --enable-version3 \
692-
--extra-cflags="-I$HOME/.release/mbedtls/include" \
693-
--extra-ldflags="-L$HOME/.release/mbedtls/lib" \
694-
--pkg-config-flags="--static"
695-
make -j$(nproc)
696-
./ffmpeg -version && ./ffmpeg -muxers 2>/dev/null |grep whip
697-
698-
- name: Start SRS Docker container
699-
run: |
700-
set -euxo pipefail
701-
ip=$(ifconfig eth0 | grep 'inet ' | awk '{print $2}')
702-
docker run --rm -d -p 1935:1935 -p 1985:1985 -p 8080:8080 \
703-
--env CANDIDATE=$ip -p 8000:8000/udp \
704-
ossrs/srs:5 ./objs/srs -c conf/rtc2rtmp.conf
705-
- name: Streaming with FFmpeg
706-
run: |
707-
set -euxo pipefail
708-
nohup ./ffmpeg -t 30 -re -i bbb-4mbps-baseline-opus.mp4 -c copy \
709-
-f whip "http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream" \
710-
1>ffstdout.log 2>ffstderr.log &
711-
- name: Check SRS Streaming
712-
id: streaming
713-
run: |
714-
set -euxo pipefail
715-
716-
# Check streams in SRS.
717-
for ((i=0; i<10; i++)); do
718-
STREAM=$(curl -s http://localhost:1985/api/v1/streams/ | jq -r '.streams[].name')
719-
if [[ "$STREAM" == "livestream" ]]; then
720-
echo 'Test OK';
721-
echo "has_stream=true" >> $GITHUB_OUTPUT
722-
break;
723-
fi
724-
sleep 3
725-
done
726-
727-
if [[ "$STREAM" != "livestream" ]]; then
728-
echo "Stream not found: $STREAM"
729-
echo "has_stream=false" >> $GITHUB_OUTPUT
730-
fi
731-
- name: Stop FFmpeg normally
732-
run: |
733-
pkill -SIGINT ffmpeg && sleep 3 ||
734-
echo "FFmpeg process not found or already stopped."
735-
- name: Show FFmpeg Stdout Log
736-
run: cat ffstdout.log
737-
- name: Show FFmpeg Stderr Log
738-
run: cat ffstderr.log
739-
- name: Check FFmpeg Exit Log
740-
run: |
741-
set -euxo pipefail
742-
cat ffstderr.log |grep 'Exiting normally' && exit 0
743-
echo "Exiting normally not found in ffstderr.log" && exit 1
744-
- name: Check Stream Existence
745-
if: ${{ steps.streaming.outputs.has_stream == 'false' }}
746-
run: exit 1
747-
runs-on: ubuntu-22.04
748-
749683
test-done:
750684
needs:
751685
- fate
686+
- build
752687
- srs
753688
- pion
754689
- janus
755690
- asan
756691
- openssl-1-1-1
757692
- openssl-3-0
758693
- openssl-latest
759-
- gnutls
760-
- mbedtls
761694
steps:
762695
- run: echo 'All done'
763696
runs-on: ubuntu-22.04

0 commit comments

Comments
 (0)