Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 23 additions & 29 deletions .github/actions/prepare-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,28 @@ runs:
# https://github.com/actions/runner-images/issues/709
- name: ♻️ Free up disk space
run: |
echo "🚧 Starting cleanup operations..."
echo "🤖 Deleting Boost..."
sudo rm -rf "/usr/local/share/boost"

echo "🤖 Deleting Android SDKs... Beep boop, bye-bye!"
sudo rm -rf /usr/local/lib/android

echo "🗑️ Tossing .NET..."
sudo rm -rf /usr/share/dotnet

echo "🧙‍♂️ Vanishing Haskell..."
sudo rm -rf /opt/ghc

echo "🔍 Losing CodeQL..."
sudo rm -rf /opt/codeql

echo "🛠️ Emptying the Tool Cache... (We don't need no tools!)"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"

# Check space
echo "🚀 Space freed! Let's see how much room for activities we have:"
df -h
shell: bash

- name: 🔧 Install tools
Expand All @@ -37,18 +57,18 @@ runs:
run: echo "TZ=UTC" >> $GITHUB_ENV
shell: bash

# We want to cache the build for a week, so we include the date (year and week) in the version.
# We want to cache the build once per day, so we include the date in the version.
- name: 🧱 Generate Cache Version
run: |
CACHE_VERSION=${{ runner.os }}-$(date +%Y-%V)-webrtc
CACHE_VERSION=${{ runner.os }}-$(date +%Y-%V-%D)-webrtc
echo "CACHE_VERSION=$CACHE_VERSION" >> $GITHUB_ENV
shell: bash

# Caches are TTL'd to 7 days after last access.
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy
- name: 📦 Cache WebRTC build
id: cache-webrtc
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: webrtc-checkout
key: ${{ env.CACHE_VERSION }}
Expand All @@ -59,29 +79,3 @@ runs:
git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
echo "$(pwd)/depot_tools" >> $GITHUB_PATH
shell: bash

- name: 📡 Fetch and build WebRTC
if: ${{ steps.cache-webrtc.outputs.cache-hit != 'true' }}
run: |
mkdir webrtc-checkout
pushd webrtc-checkout
fetch --nohooks webrtc
pushd src
git checkout b00c469cad3f8c926fcf81ded90b90b6e1e62b9c
popd
sed -i -e "s|'src/resources'],|'src/resources'],'condition':'rtc_include_tests==true',|" src/DEPS
gclient sync
pushd src
gn gen out/Default --args='is_debug=false use_custom_libcxx=false rtc_include_tests=false rtc_build_examples=false dcheck_always_on=true rtc_use_x11=false use_rtti=true'
ninja -C out/Default
popd
mv src webrtc
pushd webrtc
# Delete all unnecessary files, maintaining directory structure. Required to conserve Github
# runner disk space.
find . -type f ! -name "libwebrtc.a" ! -name "*.h" ! -path "*/boringssl/src/*" -delete
# Housekeeping: delete empty directories.
find . -type d -empty -delete
popd
popd
shell: bash
18 changes: 12 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ jobs:
- name: 📦 Prepare dependencies
uses: ./.github/actions/prepare-deps

- name: 🚧 Build
- name: 🕸️ Build Web
run: |
sed -i -e 's|webrtc_path = ".*"|webrtc_path = "${{ github.workspace }}/webrtc-checkout/"|g' WORKSPACE
# Don't `build ...`, as includes irrelevant targets in `webrtc-checkout`.
bazel-7.4.1 build cpp/...
bazel-7.4.1 build web/...

- name: 🔍 Test
- name: 🔧 Make build script executable
run: chmod +x cpp/build.sh

- name: 🚧 Build C++ (No Cache Hit)
if: ${{ steps.cache-webrtc.outputs.cache-hit != 'true' }}
run: |
cd cpp && ./build.sh --cached_webrtc=false

- name: 🚧 Build C++ (Cache Hit)
if: ${{ steps.cache-webrtc.outputs.cache-hit == 'true' }}
run: |
bazel-7.4.1 test cpp/...
cd cpp && ./build.sh --cached_webrtc=true
48 changes: 45 additions & 3 deletions cpp/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,41 @@ WEBRTC_SRC="$WEBRTC_DIR/src"
CURRENT_DIR=$(pwd)
# ---------------------

# --- Argument Parsing ---
CACHED_WEBRTC=0
NINJA_ARGS=()

while [[ $# -gt 0 ]]; do
case $1 in
--cached_webrtc=*)
# Handle explicit value (e.g., --cached_webrtc=true)
VAL="${1#*=}"
if [[ "$VAL" == "true" ]]; then
CACHED_WEBRTC=1
else
CACHED_WEBRTC=0
fi
shift
;;
--cached_webrtc)
# Handle standalone flag (treat as true)
CACHED_WEBRTC=1
shift
;;
*)
# Collect unknown args to pass to Ninja
NINJA_ARGS+=("$1")
shift
;;
esac
done
# ---------------------

echo -e "\033[1;36m🔍 [1/5] Scanning for WebRTC Universe...\033[0m"

if [ ! -d "$WEBRTC_SRC" ]; then
if [ "$CACHED_WEBRTC" -eq 1 ]; then
echo -e "\033[1;33m ⏩ Skipping WebRTC checkout: --cached_webrtc specified.\033[0m"
elif [ ! -d "$WEBRTC_SRC" ]; then
echo -e "\033[1;33m ⚠️ WebRTC checkout not found. Initializing auto-fetch sequence...\033[0m"

# Check for depot_tools first
Expand All @@ -44,14 +76,24 @@ if [ ! -d "$WEBRTC_SRC" ]; then
fetch --nohooks webrtc

echo -e "\033[1;34m 🔄 Syncing dependencies...\033[0m"
gclient sync
gclient sync --nohooks --with_branch_heads --no-history --shallow

popd > /dev/null
echo -e "\033[1;32m ✅ WebRTC Universe created successfully.\033[0m"
else
echo -e "\033[1;32m ✅ Found existing WebRTC checkout.\033[0m"
fi

echo -e "\033[1;36m🏗️ [1.5/5] Hydrating Dependencies (Sysroot & Clang)...\033[0m"
pushd "$WEBRTC_SRC" > /dev/null
echo -e "\033[1;34m 🐧 Installing Debian Sysroot...\033[0m"
python3 build/linux/sysroot_scripts/install-sysroot.py --arch=amd64

echo -e "\033[1;34m 🔨 Installing Clang Compiler...\033[0m"
python3 tools/clang/scripts/update.py
popd > /dev/null
echo -e "\033[1;32m ✅ Build environment hydrated.\033[0m"

echo -e "\033[1;36m💉 [2/5] Injecting your code into the matrix...\033[0m"
# Clean replace of the destination folder
rm -rf "$WEBRTC_SRC/$MODULE_NAME"
Expand Down Expand Up @@ -107,7 +149,7 @@ if [ ! -f "$WEBRTC_SRC/out/Default/build.ninja" ]; then
fi

echo -e "\033[1;36m🔨 [5/5] Compiling... (Grab a coffee ☕)\033[0m"
ninja -C "$WEBRTC_SRC/out/Default" "$MODULE_NAME:$TARGET_NAME" "$@"
ninja -C "$WEBRTC_SRC/out/Default" "$MODULE_NAME:$TARGET_NAME" "${NINJA_ARGS[@]}"

echo -e "\033[1;35m==================================================\033[0m"
echo -e "\033[1;32m🎉 BUILD SUCCESS! You are ready to rock. 🎸\033[0m"
Expand Down
Loading