ci: Cache and install dependencies and libraries

Note: We define CMAKE_PREFIX_PATH for OBS Studio here, which should normally (https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PATH.html#variable:CMAKE_PREFIX_PATH) be filled by the project itself. This is technically non-standard behavior, and may be remedied in the future by OBS Studio.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2022-08-14 10:31:43 +02:00
parent 730987ba77
commit f8ecf61a7b

View file

@ -23,8 +23,9 @@ jobs:
strategy:
fail-fast: false
matrix:
runner: [ windows-2022, macos-12, ubuntu-22.04, ubuntu-20.04 ]
generator: [ MSVC, GCC, Clang ]
runner: [ "windows-2022", "macos-12", "ubuntu-22.04", "ubuntu-20.04" ]
qt: [ 5, 6 ]
generator: [ "MSVC", "GCC", "Clang" ]
exclude:
- runner: windows-2022
generator: GCC
@ -38,6 +39,8 @@ jobs:
generator: MSVC
- runner: ubuntu-20.04
generator: MSVC
- runner: ubuntu-20.04
qt: 6
include:
# Windows supports MSVC
- runner: windows-2022
@ -53,7 +56,7 @@ jobs:
package_name: "macos"
CMAKE_GENERATOR: "Xcode"
CMAKE_OSX_DEPLOYMENT_TARGET: "10.15"
CMAKE_OSX_ARCHITECTURES: "x86_64"
CMAKE_OSX_ARCHITECTURES: "x86_64;arm64"
# Ubuntu needs version-specific binaries
- runner: ubuntu-22.04
@ -65,8 +68,8 @@ jobs:
package_name: "ubuntu-20"
CMAKE_GENERATOR: "Ninja"
runs-on: ${{ matrix.runner }}
name: "${{ matrix.name }} (${{ matrix.generator }})"
runs-on: "${{ matrix.runner }}"
name: "${{ matrix.name }} (${{ matrix.generator }}, Qt${{ matrix.qt }})"
env:
CMAKE_GENERATOR: "${{ matrix.CMAKE_GENERATOR }}"
CMAKE_GENERATOR_PLATFORM: "${{ matrix.CMAKE_GENERATOR_PLATFORM }}"
@ -81,6 +84,22 @@ jobs:
submodules: recursive
fetch-depth: 0
- name: "Gather Information"
id: info
shell: bash
run: |
# Dependency Versioning
if [[ "${{ matrix.runner }}" = windows* ]]; then
[[ $(cat "${{ github.workspace }}/third-party/obs-studio/.github/workflows/main.yml") =~ DEPS_VERSION_WIN:\ \'([0-9a-zA-Z\-]+)\' ]]
echo "::set-output name=obs_deps_version::${BASH_REMATCH[1]}"
elif [[ "${{ matrix.runner }}" = macos* ]]; then
[[ $(cat "${{ github.workspace }}/third-party/obs-studio/.github/workflows/main.yml") =~ DEPS_VERSION_MAC:\ \'([0-9a-zA-Z\-]+)\' ]]
echo "::set-output name=obs_deps_version::${BASH_REMATCH[1]}"
else
echo "::set-output name=obs_deps_version::BADVALUE"
fi
echo "::set-output name=obs_version::$(cd "${{ github.workspace }}/third-party/obs-studio" && git describe --tags --long)"
- name: "Dependencies: Windows"
if: startsWith( matrix.runner, 'windows' )
run: |
@ -102,10 +121,7 @@ jobs:
pkg-config \
cmake \
ninja-build \
git \
qtbase5-dev qtbase5-private-dev libqt5svg5-dev \
libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev \
libcurl4-openssl-dev
git
# clang-format, clang-tidy
curl -jLo /tmp/llvm.sh "https://apt.llvm.org/llvm.sh"
@ -143,48 +159,158 @@ jobs:
sudo installer -pkg ./Install\ Packages.pkg -target /
echo "CLANG_PATH=$(brew --prefix llvm@14)/bin/" >> "${GITHUB_ENV}"
- name: "Dependency: Qt (Cache)"
id: qt-cache
if: ${{ ! startsWith( matrix.runner, 'ubuntu' ) }}
uses: actions/cache@v3
with:
path: "${{ github.workspace }}/build/qt"
key: "${{ matrix.runner }}-obsdeps${{ steps.info.outputs.obs_deps_version }}-qt${{ matrix.qt }}"
- name: "Dependency: Qt "
id: qt
if: ${{ startsWith( matrix.runner, 'ubuntu' ) || (steps.qt-cache.outputs.cache-hit != 'true') }}
shell: bash
run: |
if [[ "${{ matrix.runner }}" = windows* ]]; then
curl --retry 5 --retry-delay 30 -jLo /tmp/qt.zip "https://github.com/obsproject/obs-deps/releases/download/${{ steps.info.outputs.obs_deps_version }}/windows-deps-qt${{ matrix.qt }}-${{ steps.info.outputs.obs_deps_version }}-x64.zip"
if [[ ! -f "${{ github.workspace }}/build/qt" ]]; then mkdir -p "${{ github.workspace }}/build/qt"; fi
7z x -y -o"${{ github.workspace }}/build/qt" -- "/tmp/qt.zip"
elif [[ "${{ matrix.runner }}" = macos* ]]; then
curl --retry 5 --retry-delay 30 -jLo /tmp/qt.tar.xz "https://github.com/obsproject/obs-deps/releases/download/${{ steps.info.outputs.obs_deps_version }}/macos-deps-qt${{ matrix.qt }}-${{ steps.info.outputs.obs_deps_version }}-universal.tar.xz"
if [[ ! -f "${{ github.workspace }}/build/qt" ]]; then mkdir -p "${{ github.workspace }}/build/qt"; fi
tar -xvf "/tmp/qt.tar.xz" -C "${{ github.workspace }}/build/qt"
elif [[ "${{ matrix.runner }}" = ubuntu* ]]; then
if [[ ${{ matrix.qt }} -eq 5 ]]; then
sudo apt-get -y install -V \
qtbase5-dev qtbase5-private-dev libqt5svg5-dev
elif [[ ${{ matrix.qt }} -eq 6 ]]; then
sudo apt-get -y install -V \
qt6-base-dev qt6-base-private-dev libqt6svg6-dev
fi
fi
- name: "Dependency: OBS Dependencies (FFmpeg, CURL, ...) (Cache)"
id: obsdeps-cache
if: ${{ ! startsWith( matrix.runner, 'ubuntu' ) }}
uses: actions/cache@v3
with:
path: "${{ github.workspace }}/build/obsdeps"
key: "${{ matrix.runner }}-obsdeps${{ steps.info.outputs.obs_deps_version }}"
- name: "Dependency: OBS Dependencies (FFmpeg, CURL, ...)"
id: obsdeps
if: ${{ startsWith( matrix.runner, 'ubuntu' ) || (steps.obsdeps-cache.outputs.cache-hit != 'true') }}
shell: bash
run: |
if [[ "${{ matrix.runner }}" = windows* ]]; then
curl --retry 5 --retry-delay 30 -jLo /tmp/obsdeps.zip "https://github.com/obsproject/obs-deps/releases/download/${{ steps.info.outputs.obs_deps_version }}/windows-deps-${{ steps.info.outputs.obs_deps_version }}-x64.zip"
if [[ ! -f "${{ github.workspace }}/build/obsdeps" ]]; then mkdir -p "${{ github.workspace }}/build/obsdeps"; fi
7z x -y -o"${{ github.workspace }}/build/obsdeps" -- "/tmp/obsdeps.zip"
elif [[ "${{ matrix.runner }}" = macos* ]]; then
curl --retry 5 --retry-delay 30 -jLo /tmp/obsdeps.tar.xz "https://github.com/obsproject/obs-deps/releases/download/${{ steps.info.outputs.obs_deps_version }}/macos-deps-${{ steps.info.outputs.obs_deps_version }}-universal.tar.xz"
if [[ ! -f "${{ github.workspace }}/build/obsdeps" ]]; then mkdir -p "${{ github.workspace }}/build/obsdeps"; fi
tar -xvf "/tmp/obsdeps.tar.xz" -C "${{ github.workspace }}/build/obsdeps"
elif [[ "${{ matrix.runner }}" = ubuntu* ]]; then
sudo apt-get -y install -V \
libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev \
libcurl4-openssl-dev
fi
- name: "Dependency: OBS Libraries (Cache)"
id: obs-cache
uses: actions/cache@v3
with:
path: "${{ github.workspace }}/build/obs"
key: "${{ matrix.runner }}-${{ matrix.generator }}-obs${{ steps.info.outputs.obs_version }}-obsdeps${{ steps.info.outputs.obs_deps_version }}-qt${{ matrix.qt }}"
- name: "Dependency: OBS Libraries"
id: obs
if: ${{ steps.obs-cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
# Extra requirements by libobs on Linux.
if [[ "${{ matrix.runner }}" = ubuntu* ]]; then
sudo apt-get install \
libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev \
libx264-dev libcurl4-openssl-dev libmbedtls-dev libgl1-mesa-dev libjansson-dev libluajit-5.1-dev python3-dev \
libx11-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-xinerama0-dev libxcomposite-dev libxinerama-dev \
libxcb1-dev libx11-xcb-dev libxcb-xfixes0-dev swig libcmocka-dev libxss-dev libglvnd-dev libgles2-mesa \
libgles2-mesa-dev libwayland-dev \
libasound2-dev libfdk-aac-dev libfontconfig-dev libfreetype6-dev libjack-jackd2-dev libpulse-dev \
libsndio-dev libspeexdsp-dev libudev-dev libv4l-dev libva-dev libvlc-dev libdrm-dev
fi
cmake \
-S"${{ github.workspace }}/third-party/obs-studio" \
-B"${{ github.workspace }}/build/obs" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/build/obs/install" \
-DENABLE_PLUGINS=OFF \
-DENABLE_UI=OFF \
-DENABLE_SCRIPTING=OFF \
-DCMAKE_PREFIX_PATH="${{ github.workspace }}/build/obsdeps;${{ github.workspace }}/build/qt"
cmake \
--build "${{ github.workspace }}/build/obs" \
--config Release \
--target obs-frontend-api
cmake \
--install "${{ github.workspace }}/build/obs" \
--config Release \
--component obs_libraries
- name: "Configure & Build (Debug)"
continue-on-error: true
shell: bash
env:
CMAKE_BUILD_TYPE: "Debug"
run: |
cmake -H. -B"build/debug" \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX="build/debug/install" \
cmake \
-S"${{ github.workspace }}" \
-B"${{ github.workspace }}/build/debug" \
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/build/debug/install" \
-DPACKAGE_NAME="streamfx-${{ matrix.package_name }}-debug" \
-DPACKAGE_PREFIX="build/package" \
-DPACKAGE_PREFIX="${{ github.workspace }}/build/package" \
-DENABLE_CLANG=TRUE -DCLANG_PATH="${{ env.CLANG_PATH }}" \
-DENABLE_PROFILING=ON
-DENABLE_PROFILING=ON \
-Dlibobs_DIR="${{ github.workspace }}/build/obs/install" \
-DQt_DIR="${{ github.workspace }}/build/qt" \
-DFFmpeg_DIR="${{ github.workspace }}/build/obsdeps" \
-DCURL_DIR="${{ github.workspace }}/build/obsdeps"
if [[ "${{ matrix.runner }}" = windows* ]]; then
cmake --build "build/debug" --config Debug --target INSTALL
cmake --build "build/debug" --config ${{ env.CMAKE_BUILD_TYPE }} --target INSTALL
elif [[ "${{ matrix.runner }}" = ubuntu* ]]; then
cmake --build "build/debug" --config Debug --target install
cmake --build "build/debug" --config ${{ env.CMAKE_BUILD_TYPE }} --target install
elif [[ "${{ matrix.runner }}" = macos* ]]; then
cmake --build "build/debug" --config Debug --target install
cmake --build "build/debug" --config ${{ env.CMAKE_BUILD_TYPE }} --target install
fi
- name: "Configure & Build (Release)"
shell: bash
env:
CMAKE_BUILD_TYPE: "RelWithDebInfo"
run: |
cmake -H. -B"build/release" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX="build/release/install" \
cmake \
-S"${{ github.workspace }}" \
-B"${{ github.workspace }}/build/release" \
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/build/release/install" \
-DPACKAGE_NAME="streamfx-${{ matrix.package_name }}" \
-DPACKAGE_PREFIX="build/package" \
-DPACKAGE_PREFIX="${{ github.workspace }}/build/package" \
-DENABLE_CLANG=TRUE -DCLANG_PATH="${{ env.CLANG_PATH }}" \
-DENABLE_PROFILING=OFF
-DENABLE_PROFILING=OFF \
-Dlibobs_DIR="${{ github.workspace }}/build/obs/install" \
-DQt_DIR="${{ github.workspace}}/build/qt" \
-DFFmpeg_DIR="${{ github.workspace }}/build/obsdeps" \
-DCURL_DIR="${{ github.workspace }}/build/obsdeps"
if [[ "${{ matrix.runner }}" = windows* ]]; then
cmake --build "build/release" --config RelWithDebInfo --target INSTALL
cmake --build "build/release" --config ${{ env.CMAKE_BUILD_TYPE }} --target INSTALL
elif [[ "${{ matrix.runner }}" = ubuntu* ]]; then
cmake --build "build/release" --config RelWithDebInfo --target install/strip
cmake --build "build/release" --config ${{ env.CMAKE_BUILD_TYPE }} --target install/strip
elif [[ "${{ matrix.runner }}" = macos* ]]; then
cmake --build "build/release" --config RelWithDebInfo --target install
cmake --build "build/release" --config ${{ env.CMAKE_BUILD_TYPE }} --target install
fi
- name: "Validate Formatting"
shell: bash
run: |
cmake --build "build/debug" --config Debug --target StreamFX_clang-format
cmake --build "build/release" --config RelWithDebInfo --target StreamFX_clang-format
cmake --build "${{ github.workspace }}/build/debug" --config Debug --target StreamFX_clang-format
cmake --build "${{ github.workspace }}/build/release" --config RelWithDebInfo --target StreamFX_clang-format
git --no-pager diff --patch --minimal HEAD --
git update-index --refresh
git diff-index --quiet HEAD --
@ -192,9 +318,9 @@ jobs:
- name: "Package: Archives"
shell: bash
run: |
mkdir build/package
cmake --build "build/debug" --config RelWithDebInfo --target PACKAGE_7Z
cmake --build "build/release" --config RelWithDebInfo --target PACKAGE_7Z
mkdir "${{ github.workspace }}/build/package"
cmake --build "${{ github.workspace }}/build/debug" --config Debug --target PACKAGE_7Z
cmake --build "${{ github.workspace }}/build/release" --config RelWithDebInfo --target PACKAGE_7Z
- name: "Package: Installer (Windows)"
if: startsWith( matrix.runner, 'windows' )
@ -207,11 +333,11 @@ jobs:
if: startsWith( matrix.runner, 'macos' )
shell: bash
run: |
packagesbuild ./build/debug/installer.pkgproj
packagesbuild ./build/release/installer.pkgproj
packagesbuild "${{ github.workspace }}/build/debug/installer.pkgproj"
packagesbuild "${{ github.workspace }}/build/release/installer.pkgproj"
- name: "Artifacts"
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.runner }}-${{ matrix.generator }}-${{ matrix.CMAKE_BUILD_TYPE }}
path: build/package
name: "${{ matrix.runner }}-${{ matrix.generator }}-qt${{ matrix.qt }}"
path: "${{ github.workspace }}/build/package"