Skip to content

Improve stability

Improve stability #510

# Testing cpp and python libraries.
name: cpp-python-tests
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
inputs:
pytest_stdout:
description: "Show test STDOUT in log for Pytest tests"
required: false
type: boolean
default: false
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-22.04, macos-11, macos-12]
python-version: ["3.8", "3.9", "3.10"]
build-type: [Debug, Release]
enable-gstreamer: [ON, OFF]
enable-system-opencv: [OFF]
exclude:
- os: macos-11
enable-gstreamer: ON
- os: macos-12
enable-gstreamer: ON
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Add .local/bin to PATH (macOS, automatic on Linux)
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
if: runner.os == 'macOS'
- name: Use gcc-8 and g++-8 (ubuntu-18.04)
run: |
sudo apt-get install gcc-8 g++-8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 100
sudo update-alternatives --set gcc /usr/bin/gcc-8
sudo update-alternatives --set g++ /usr/bin/g++-8
if: matrix.os == 'ubuntu-18.04'
- name: Generate Version Output
id: generate_version_output
run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT
- name: Print Version Information
run: echo "Version ${{ steps.generate_version_output.outputs.version }}"
- name: Generate OS Release Output
id: generate_os_release_name_output
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
echo "os_release_name=${{runner.os}}-$(lsb_release -i -s)" >> $GITHUB_OUTPUT
else
echo "os_release_name=${{runner.os}}" >> $GITHUB_OUTPUT
fi
- name: Generate OS Release Version Output
id: generate_os_release_version_output
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
echo "os_release_version=$(lsb_release -r -s)" >> $GITHUB_OUTPUT
elif [[ "${{ runner.os }}" == "macOS" ]]; then
echo "os_release_version=$(cmake -P cmake/macos_get_version_script.cmake)" >> $GITHUB_OUTPUT
fi
- name: Generate OS Release Architecture Output
id: generate_os_release_architecture_output
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
echo "os_release_architecture=$(uname -i)" >> $GITHUB_OUTPUT
elif [[ "${{ runner.os }}" == "macOS" ]]; then
echo "os_release_architecture=$(uname -m)" >> $GITHUB_OUTPUT
fi
- name: Generate Release File Name
id: generate_release_file_name
run: |
echo "release_file_name=\
${{ steps.generate_os_release_name_output.outputs.os_release_name }}-\
${{ steps.generate_os_release_version_output.outputs.os_release_version }}-\
${{ steps.generate_os_release_architecture_output.outputs.os_release_architecture }}-\
${{ steps.generate_version_output.outputs.version }}" >> $GITHUB_OUTPUT
- name: Print Release File Name
run: echo "Release File Name ${{ steps.generate_release_file_name.outputs.release_file_name }}"
- name: Install system dependencies (Linux)
run: |
sudo apt-get update
sudo apt-get install ninja-build cmake build-essential libssl-dev libboost-all-dev
sudo apt-get install libglib2.0-dev libgtk-3-dev libpulse-dev libasound2-dev tree perl
sudo apt install libunwind-dev
sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev
sudo apt-get install gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad
sudo apt-get install gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools
sudo apt-get install gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5
sudo apt-get install gstreamer1.0-pulseaudio
if: runner.os == 'Linux'
- name: Install system dependencies (macOS)
run: |
brew update
brew install ninja tree ca-certificates perl
if: runner.os == 'macOS'
- name: Install python dependencies
run: |
python -m pip install --user --upgrade pip
python -m pip install --user --upgrade setuptools wheel
python -m pip install --user --upgrade twine
python -m pip install --user --upgrade pytest
python -m pip install --user --upgrade sphinx
python -m pip install --user --upgrade pybind11-stubgen
python -m pip install --user --upgrade numpy
python -m pip install --user -r signaling-server/requirements.txt
- name: Create build directory
run: |
mkdir build
- name: Run CMake and build opentera-webrtc
working-directory: build
run: |
cmake ../ -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DCMAKE_INSTALL_PREFIX=dist \
-DOPENTERA_WEBRTC_NATIVE_CLIENT_PYTHON_PIP_INSTALL_PREFIX='--user' \
-DOPENTERA_WEBRTC_NATIVE_CLIENT_PYTHON_VERSION="$(python --version | perl -pe 's/Python //')" \
-DPython_ROOT_DIR="${{ env.pythonLocation }}" \
-DOPENTERA_WEBRTC_ENABLE_GSTREAMER=${{ matrix.enable-gstreamer }} \
-DOPENTERA_WEBRTC_USE_SYSTEM_OPENCV=${{ matrix.enable-system-opencv }}
make
make install
- name: Python native_client build cleanup
working-directory: build/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/python/package/opentera_webrtc_native_client
run: |
rm -rfv build
rm -rfv '*.so'
rm -rfv opentera_webrtc_native_client.egg-info
rm -rfv _build
- name: Python signaling_server build cleanup
working-directory: build/signaling-server/opentera_webrtc_signaling_server
run: |
rm -rfv build
rm -rfv opentera_webrtc_signaling_server.egg-info
rm -rfv _build
- name: Run CPP Tests
working-directory: build/dist/bin
run: |
export LD_LIBRARY_PATH=$PWD
export GST_DEBUG=2
./OpenteraWebrtcNativeClientTests
# Without stdout
- name: Run Python signaling-server Tests
if: ${{ !github.event.inputs.pytest_stdout }}
working-directory: signaling-server
run: |
python -m pytest -v opentera_webrtc/tests
- name: Run Python webrtc-native-client Tests
if: ${{ !github.event.inputs.pytest_stdout }}
working-directory: opentera-webrtc-native-client/OpenteraWebrtcNativeClient/python/test
run: |
if [ -f requirements.txt ]; then python -m pip install --user -r requirements.txt; fi
python -m pytest -vv -s
# With stdout
- name: Run Python signaling-server Tests with STDOUT
if: ${{ github.event.inputs.pytest_stdout }}
working-directory: signaling-server
run: |
python -m pytest -v --capture=tee-sys opentera_webrtc/tests
- name: Run Python webrtc-native-client Tests with STDOUT
if: ${{ github.event.inputs.pytest_stdout }}
working-directory: opentera-webrtc-native-client/OpenteraWebrtcNativeClient/python/test
run: |
if [ -f requirements.txt ]; then python -m pip install --user -r requirements.txt; fi
python -m pytest -v --capture=tee-sys