Skip to content

Commit 062c0ea

Browse files
committed
workflows/test: add macOS and Windows to build and pion matrix
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
1 parent 224098a commit 062c0ea

File tree

1 file changed

+106
-17
lines changed

1 file changed

+106
-17
lines changed

.github/workflows/test.yml

Lines changed: 106 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,44 @@ jobs:
6363
runs-on: ubuntu-22.04
6464

6565
build:
66-
name: "Build FFmpeg (${{ matrix.tls }})"
66+
name: "Build FFmpeg (${{ matrix.os }}, ${{ matrix.tls }})"
6767
strategy:
6868
fail-fast: false
6969
matrix:
70+
os: [ubuntu-22.04, macos-14, windows-latest]
7071
tls: [openssl, gnutls, mbedtls]
7172
steps:
7273
- name: Checkout repository
7374
uses: actions/checkout@v4
74-
- name: Install dependencies
75+
- name: Setup MSYS2
76+
if: runner.os == 'Windows'
77+
uses: msys2/setup-msys2@v2
78+
with:
79+
msystem: MINGW64
80+
update: false
81+
install: >-
82+
mingw-w64-x86_64-nasm
83+
mingw-w64-x86_64-pkg-config
84+
mingw-w64-x86_64-jq
85+
mingw-w64-x86_64-opus
86+
mingw-w64-x86_64-x264
87+
mingw-w64-x86_64-toolchain
88+
make
89+
diffutils
90+
- name: Install TLS dependencies (Windows)
91+
if: runner.os == 'Windows'
92+
shell: msys2 {0}
93+
run: |
94+
set -euxo pipefail
95+
if [[ "${{ matrix.tls }}" == "openssl" ]]; then
96+
pacman -S --noconfirm mingw-w64-x86_64-openssl
97+
elif [[ "${{ matrix.tls }}" == "gnutls" ]]; then
98+
pacman -S --noconfirm mingw-w64-x86_64-gnutls
99+
elif [[ "${{ matrix.tls }}" == "mbedtls" ]]; then
100+
pacman -S --noconfirm mingw-w64-x86_64-cmake
101+
fi
102+
- name: Install dependencies (Linux)
103+
if: runner.os == 'Linux'
75104
run: |
76105
set -euxo pipefail
77106
sudo apt-get update
@@ -83,20 +112,39 @@ jobs:
83112
elif [[ "${{ matrix.tls }}" == "mbedtls" ]]; then
84113
sudo apt-get install -y cmake
85114
fi
115+
- name: Install dependencies (macOS)
116+
if: runner.os == 'macOS'
117+
run: |
118+
set -euxo pipefail
119+
brew install nasm pkg-config jq opus x264
120+
if [[ "${{ matrix.tls }}" == "openssl" ]]; then
121+
brew install openssl@3
122+
elif [[ "${{ matrix.tls }}" == "gnutls" ]]; then
123+
brew install gnutls
124+
elif [[ "${{ matrix.tls }}" == "mbedtls" ]]; then
125+
brew install cmake
126+
fi
86127
- name: Build mbedTLS
87128
if: matrix.tls == 'mbedtls'
129+
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
88130
run: |
89131
set -euxo pipefail
132+
NPROC=$(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || echo 4)
90133
curl -s -L https://github.com/Mbed-TLS/mbedtls/releases/download/mbedtls-3.6.2/mbedtls-3.6.2.tar.bz2 | tar xj
91134
cd mbedtls-3.6.2
92135
scripts/config.py set MBEDTLS_SSL_DTLS_SRTP
93136
mkdir build && cd build
94137
cmake -DCMAKE_INSTALL_PREFIX=$HOME/.release/mbedtls \
95138
-DUSE_SHARED_MBEDTLS_LIBRARY=Off -DENABLE_SHARED=Off -DENABLE_STATIC=On ..
96-
make -j$(nproc) && make install
139+
make -j$NPROC && make install
97140
- name: Build FFmpeg
141+
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
98142
run: |
99143
set -euxo pipefail
144+
NPROC=$(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || echo 4)
145+
if [[ "${{ runner.os }}" == "macOS" && "${{ matrix.tls }}" == "openssl" ]]; then
146+
export PKG_CONFIG_PATH="$(brew --prefix openssl@3)/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
147+
fi
100148
if [[ "${{ matrix.tls }}" == "openssl" ]]; then
101149
./configure --enable-muxer=whip --enable-openssl --enable-version3 \
102150
--enable-libx264 --enable-gpl --enable-libopus
@@ -111,15 +159,15 @@ jobs:
111159
--pkg-config-flags="--static" \
112160
--enable-libx264 --enable-gpl --enable-libopus
113161
fi
114-
make -j$(nproc)
162+
make -j$NPROC
115163
./ffmpeg -version && ./ffmpeg -muxers 2>/dev/null |grep whip
116164
- name: Upload FFmpeg binary
117165
uses: actions/upload-artifact@v4
118166
with:
119-
name: ffmpeg-${{ matrix.tls }}
120-
path: ./ffmpeg
167+
name: ffmpeg-${{ matrix.os }}-${{ matrix.tls }}
168+
path: ./ffmpeg*
121169
retention-days: 1
122-
runs-on: ubuntu-22.04
170+
runs-on: ${{ matrix.os }}
123171

124172
srs:
125173
name: "SRS with FFmpeg (${{ matrix.tls }})"
@@ -144,7 +192,7 @@ jobs:
144192
- name: Download FFmpeg binary
145193
uses: actions/download-artifact@v4
146194
with:
147-
name: ffmpeg-${{ matrix.tls }}
195+
name: ffmpeg-ubuntu-22.04-${{ matrix.tls }}
148196
- name: Verify FFmpeg
149197
run: |
150198
chmod +x ./ffmpeg
@@ -202,16 +250,39 @@ jobs:
202250
runs-on: ubuntu-22.04
203251

204252
pion:
205-
name: "Pion with FFmpeg (${{ matrix.tls }})"
253+
name: "Pion with FFmpeg (${{ matrix.os }}, ${{ matrix.tls }})"
206254
needs: build
207255
strategy:
208256
fail-fast: false
209257
matrix:
258+
os: [ubuntu-22.04, macos-14, windows-latest]
210259
tls: [openssl, gnutls, mbedtls]
211260
steps:
212261
- name: Checkout repository
213262
uses: actions/checkout@v4
214-
- name: Install runtime dependencies
263+
- name: Setup MSYS2
264+
if: runner.os == 'Windows'
265+
uses: msys2/setup-msys2@v2
266+
with:
267+
msystem: MINGW64
268+
update: false
269+
install: >-
270+
mingw-w64-x86_64-jq
271+
mingw-w64-x86_64-opus
272+
mingw-w64-x86_64-x264
273+
curl
274+
- name: Install TLS runtime dependencies (Windows)
275+
if: runner.os == 'Windows'
276+
shell: msys2 {0}
277+
run: |
278+
set -euxo pipefail
279+
if [[ "${{ matrix.tls }}" == "openssl" ]]; then
280+
pacman -S --noconfirm mingw-w64-x86_64-openssl
281+
elif [[ "${{ matrix.tls }}" == "gnutls" ]]; then
282+
pacman -S --noconfirm mingw-w64-x86_64-gnutls
283+
fi
284+
- name: Install runtime dependencies (Linux)
285+
if: runner.os == 'Linux'
215286
run: |
216287
set -euxo pipefail
217288
sudo apt-get update
@@ -221,26 +292,39 @@ jobs:
221292
elif [[ "${{ matrix.tls }}" == "gnutls" ]]; then
222293
sudo apt-get install -y libgnutls28-dev
223294
fi
295+
- name: Install runtime dependencies (macOS)
296+
if: runner.os == 'macOS'
297+
run: |
298+
set -euxo pipefail
299+
brew install jq opus x264
300+
if [[ "${{ matrix.tls }}" == "openssl" ]]; then
301+
brew install openssl@3
302+
elif [[ "${{ matrix.tls }}" == "gnutls" ]]; then
303+
brew install gnutls
304+
fi
224305
- name: Download FFmpeg binary
225306
uses: actions/download-artifact@v4
226307
with:
227-
name: ffmpeg-${{ matrix.tls }}
308+
name: ffmpeg-${{ matrix.os }}-${{ matrix.tls }}
228309
- name: Verify FFmpeg
310+
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
229311
run: |
230-
chmod +x ./ffmpeg
312+
chmod +x ./ffmpeg || true
231313
./ffmpeg -version && ./ffmpeg -muxers 2>/dev/null |grep whip
232314
- name: Set up Go
233315
uses: actions/setup-go@v4
234316
with:
235317
go-version: '1.22'
236318
- name: Verify Go version
319+
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
237320
run: go version
238321
- name: Start Pion and Stream with FFmpeg
322+
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
239323
run: |
240324
set -euxo pipefail
241325
git clone https://github.com/pion/webrtc.git
242326
cd webrtc/examples/whip-whep
243-
go run *.go &
327+
go run . &
244328
245329
# Wait for Pion to be ready
246330
for ((i=0; i<30; i++)); do
@@ -253,28 +337,33 @@ jobs:
253337
done
254338
255339
cd $GITHUB_WORKSPACE
256-
nohup ./ffmpeg -t 30 -re -f lavfi -i testsrc=size=1280x720 -f lavfi -i sine=frequency=440 -pix_fmt yuv420p \
340+
./ffmpeg -t 30 -re -f lavfi -i testsrc=size=1280x720 -f lavfi -i sine=frequency=440 -pix_fmt yuv420p \
257341
-vcodec libx264 -profile:v baseline -r 25 -g 50 -acodec libopus -ar 48000 -ac 2 \
258342
-f whip -authorization "seanTest" "http://localhost:8080/whip" \
259343
1>ffstdout.log 2>ffstderr.log &
344+
FFMPEG_PID=$!
260345
sleep 10
261-
pkill -SIGINT ffmpeg && sleep 3 ||
346+
kill -INT $FFMPEG_PID && sleep 3 ||
262347
echo "FFmpeg process not found or already stopped."
263348
- name: Show FFmpeg Stdout Log
349+
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
264350
run: cat ffstdout.log
265351
- name: Show FFmpeg Stderr Log
352+
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
266353
run: cat ffstderr.log
267354
- name: Check FFmpeg Exit Log
355+
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
268356
run: |
269357
set -euxo pipefail
270358
cat ffstderr.log |grep 'Exiting normally' && exit 0
271359
echo "Exiting normally not found in ffstderr.log" && exit 1
272360
- name: Check FFmpeg Streamed Successfully
361+
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
273362
run: |
274363
set -euxo pipefail
275364
cat ffstderr.log |grep -v 'Connection refused' |grep 'frame=' |grep -v 'frame= 0' && exit 0
276365
echo "FFmpeg did not stream any frames" && exit 1
277-
runs-on: ubuntu-22.04
366+
runs-on: ${{ matrix.os }}
278367

279368
janus:
280369
name: "Janus with FFmpeg (${{ matrix.tls }})"
@@ -299,7 +388,7 @@ jobs:
299388
- name: Download FFmpeg binary
300389
uses: actions/download-artifact@v4
301390
with:
302-
name: ffmpeg-${{ matrix.tls }}
391+
name: ffmpeg-ubuntu-22.04-${{ matrix.tls }}
303392
- name: Verify FFmpeg
304393
run: |
305394
chmod +x ./ffmpeg

0 commit comments

Comments
 (0)