# Copyright 2013-2019 High Fidelity, Inc. # Copyright 2020-2022 Vircadia contributors. # Copyright 2021-2024 Overte e.V. # SPDX-License-Identifier: Apache-2.0 name: Pull Request CI Build # Keep in mind that GitHub Actions does not allow reading secrets during PR builds. on: pull_request: types: [opened, synchronize, reopened] env: APP_NAME: interface BUILD_TYPE: Release CI_BUILD: Github GIT_COMMIT: ${{ github.event.pull_request.head.sha }} # VCPKG did not build well on OSX disabling HIFI_VCPKG_BOOTSTRAP, which invokes a download to a working version of vcpkg # HIFI_VCPKG_BOOTSTRAP: true RELEASE_TYPE: PR RELEASE_NUMBER: ${{ github.event.number }} VERSION_CODE: ${{ github.event.number }} # Sentry Crash Reporting # We can't use secrets or actions here, so the actual value has to be hardcoded. CMAKE_BACKTRACE_URL: "https://o4504831972343808.ingest.sentry.io/api/4504832427950080/minidump/?sentry_key=f511de295975461b8f92a36f4a4a4f32" CMAKE_BACKTRACE_TOKEN: PR_${{ github.event.number }}_${{ github.sha }} # Disable VCPKG caching to save time. VCPKG_FEATURE_FLAGS: -binarycaching UPLOAD_BUCKET: overte-public UPLOAD_REGION: fra1 UPLOAD_ENDPOINT: "https://fra1.digitaloceanspaces.com" # OSX specific variables DEVELOPER_DIR: /Applications/Xcode_11.2.app/Contents/Developer # We are using macOS SDK 10.12 to work around a lot of OpenGL issues in newer SDKs. # There are crashes on startup, crashes on window resize, etc. on newer macOS SDKs. MACOSX_DEPLOYMENT_TARGET: '10.12' # WIN32 specific variables PreferredToolArchitecture: X64 # Ensure XZ always runs with muticore support XZ_OPT: -T0 jobs: build_pr: name: "${{matrix.os}}, ${{matrix.arch}}" strategy: matrix: include: - os: Windows 2019 runner: windows-2019 arch: x86_64 build_type: full #- os: macOS-10.15 # build_type: full - os: Ubuntu 20.04 # https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Meta-Labels # self_hosted makes the Hetzner auto-scaler put up the job. # type-cx52 is a Hetzner VPS server type. In this case cs52 is a server with 16-cores and 32GB of RAM. # image-x86-app-docker-ce is a Hetzner image. # https://github.com/testflows/TestFlows-GitHub-Hetzner-Runners/wiki/Specifying-The-Runner-Image runner: [self_hosted, type-cx52, image-x86-app-docker-ce] arch: amd64 build_type: full apt-dependencies: pkg-config libxext-dev libdouble-conversion-dev libpcre2-16-0 libpulse0 libharfbuzz-dev libnss3 libnspr4 libxdamage1 libasound2 libxcb-glx0-dev # add missing dependencies to docker image when convenient image: docker.io/overte/overte-full-build:0.1.1-ubuntu-20.04-amd64 # Android builds are currently failing #- os: ubuntu-18.04 # build_type: android # apt-dependencies: mesa-common-dev libegl1 libglvnd-dev libdouble-conversion1 libpulse0 python3-github python3-distro # Do not change the names of self-hosted runners without knowing what you are doing, as they correspond to labels that have to be set on the runner. - os: Ubuntu 22.04 runner: [self_hosted, type-cax41, image-arm-app-docker-ce] arch: aarch64 build_type: full apt-dependencies: libxcb-glx0-dev # add missing dependencies to docker image when convenient image: docker.io/overte/overte-full-build:0.1.1-ubuntu-22.04-aarch64 fail-fast: false runs-on: ${{matrix.runner}} container: ${{matrix.image}} steps: - name: Configure Build Environment 1 shell: bash id: buildenv1 run: | # Setting short commit SHA for use as RELEASE_NAME in generated installers. echo "GIT_COMMIT_SHORT=`echo $GIT_COMMIT | cut -c1-7`" >> $GITHUB_ENV echo "JOB_NAME=${{matrix.os}}, ${{matrix.build_type}}" >> $GITHUB_ENV echo "APP_TARGET_NAME=$APP_NAME" >> $GITHUB_ENV # Linux build variables if [[ "${{ matrix.os }}" = "Ubuntu"* ]]; then echo "PYTHON_EXEC=python3" >> $GITHUB_ENV echo "INSTALLER_EXT=*" >> $GITHUB_ENV echo "CMAKE_BUILD_EXTRA=-- -j$(nproc)" >> $GITHUB_ENV # Don't optimize builds to save build time. echo "OVERTE_OPTIMIZE=false" >> $GITHUB_ENV # Starting with Ubuntu 22.04 we can use system Qt if [[ "${{ matrix.image }}" = *"ubuntu-22.04"* ]]; then echo "OVERTE_USE_SYSTEM_QT=true" >> $GITHUB_ENV fi if [[ "${{ matrix.arch }}" = "aarch64" ]]; then echo "VCPKG_FORCE_SYSTEM_BINARIES=true" >> $GITHUB_ENV if [ "${{ matrix.build_type }}" = "full" ]; then echo "CMAKE_EXTRA=-DOVERTE_CPU_ARCHITECTURE= -DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)" >> $GITHUB_ENV else echo "CMAKE_EXTRA=-DOVERTE_CPU_ARCHITECTURE= -DCLIENT_ONLY=1 -DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)" >> $GITHUB_ENV fi fi if [[ "${{ matrix.arch }}" = "amd64" ]]; then if [ "${{ matrix.build_type }}" = "full" ]; then echo "CMAKE_EXTRA=-DOVERTE_CPU_ARCHITECTURE=-msse3 -DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)" >> $GITHUB_ENV else echo "CMAKE_EXTRA=-DOVERTE_CPU_ARCHITECTURE=-msse3 -DCLIENT_ONLY=1 -DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)" >> $GITHUB_ENV fi fi fi # Mac build variables if [ "${{ matrix.os }}" = "macOS-10.15" ]; then echo "PYTHON_EXEC=python3" >> $GITHUB_ENV echo "INSTALLER_EXT=dmg" >> $GITHUB_ENV if [ "${{ matrix.build_type }}" = "full" ]; then echo "CMAKE_EXTRA=-DOVERTE_CPU_ARCHITECTURE= -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib -G Xcode" >> $GITHUB_ENV else echo "CMAKE_EXTRA=-DOVERTE_CPU_ARCHITECTURE= -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -DCLIENT_ONLY=1 -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib -G Xcode" >> $GITHUB_ENV fi echo "APP_TARGET_NAME=Overte" >> $GITHUB_ENV fi # Windows build variables if [ "${{ matrix.os }}" = "Windows 2019" ]; then echo "PYTHON_EXEC=python" >> $GITHUB_ENV echo "INSTALLER_EXT=exe" >> $GITHUB_ENV if [ "${{ matrix.build_type }}" = "full" ]; then echo "CMAKE_EXTRA=-A x64 -DJSDOC_ENABLED:BOOL=TRUE" >> $GITHUB_ENV else echo "CMAKE_EXTRA=-A x64 -DJSDOC_ENABLED:BOOL=TRUE -DCLIENT_ONLY=1" >> $GITHUB_ENV fi fi # Android + Quest build variables if [[ "${{ matrix.build_type }}" == "android" ]]; then HIFI_ANDROID_PRECOMPILED="${{runner.workspace}}/dependencies" echo "HIFI_ANDROID_PRECOMPILED=$HIFI_ANDROID_PRECOMPILED" >> $GITHUB_ENV mkdir $HIFI_ANDROID_PRECOMPILED echo "INSTALLER_EXT=apk" >> $GITHUB_ENV fi # Configuration is broken into two steps because you can't set an env var and also reference it in the same step - name: Configure Build Environment 2 shell: bash run: | echo "${{ steps.buildenv1.outputs.symbols_archive }}" if [ "${{ matrix.build_type }}" = "full" ]; then echo "ARTIFACT_PATTERN=Overte-PR${{ github.event.number }}-${GIT_COMMIT_SHORT}.$INSTALLER_EXT" >> $GITHUB_ENV echo "INSTALLER=Overte-$RELEASE_NUMBER-${GIT_COMMIT_SHORT}.$INSTALLER_EXT" >> $GITHUB_ENV else echo "ARTIFACT_PATTERN=Overte-Interface-PR${{ github.event.number }}-${GIT_COMMIT_SHORT}.$INSTALLER_EXT" >> $GITHUB_ENV echo "INSTALLER=Overte-Interface-$RELEASE_NUMBER-${GIT_COMMIT_SHORT}.$INSTALLER_EXT" >> $GITHUB_ENV fi - name: Clear Working Directories if: contains(matrix.runner, 'linux_aarch64') || contains(matrix.runner, 'linux_amd64') shell: bash run: | rm -rf ./* rm -rf ~/overte-files rm -rf ~/.cache - uses: actions/checkout@v4 with: submodules: false fetch-depth: 1 - name: Install dependencies shell: bash if: startsWith(matrix.os, 'Ubuntu') || contains(matrix.os, 'Debian') || startsWith(matrix.os, 'macOS') run: | if [[ "${{ matrix.os }}" =~ "Ubuntu" || "${{ matrix.os }}" =~ "Debian" ]]; then echo "Updating apt repository index" sudo apt update || exit 1 echo "Installing apt packages" sudo apt install -y ${{ matrix.apt-dependencies }} || exit 1 echo "Adding Toolchain test PPA" apt install -y software-properties-common add-apt-repository ppa:ubuntu-toolchain-r/test echo "Installing gcc-13" apt install -y gcc-13 g++-13 || exit 1 # Set GCC 13 as default update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 --slave /usr/bin/g++ g++ /usr/bin/g++-13 --slave /usr/bin/gcov gcov /usr/bin/gcov-13 else # macOS echo "Downloading MacOSX10.12 SDK.." curl --progress-bar -L -o macOS_SDK10.12.4.tar.xz "https://data.moto9000.moe/overte_packages/macOS_SDK10.12.4.tar.xz" || exit 1 echo " done\n" echo "Checking MacOSX10.12 SDK.." echo "c00e03cb64bed8d0d75d7a01c93de094b6ffaa3bc3318e7b29a9bdc354f0e29e363c454b7db89db8a3b78e9702668d1c661f1af279807de8db11accecb0ca498 macOS_SDK10.12.4.tar.xz" >> macOS_SDK10.12.4.tar.xz.checksum shasum -a 512 -w -c macOS_SDK10.12.4.tar.xz.checksum echo "Extracting MacOSX10.12 SDK.." tar -xf macOS_SDK10.12.4.tar.xz || exit 1 echo " done\n" echo "Installing MacOSX10.12 SDK.." # cp always sets an error code while copying the SDK so we return 0 when that happens. sudo cp -rp MacOSX10.12.sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ || exit 0 echo " done" fi if [[ "${{ matrix.os }}" =~ "Debian 11" ]]; then echo "Installing CMake from Debian Backports" echo deb http://deb.debian.org/debian bullseye-backports main > /etc/apt/sources.list.d/bullseye-backports.list sudo apt update sudo apt-get -t bullseye-backports install -y cmake fi - name: Override NSIS shell: pwsh if: startsWith(matrix.os, 'Windows') run: choco install nsis --allow-downgrade --version=3.06.1 - name: Install Python modules if: startsWith(matrix.os, 'Windows') || startsWith(matrix.os, 'macOS') shell: bash run: $PYTHON_EXEC -m pip install boto3 PyGithub - name: Create Build Environment shell: bash run: cmake -E make_directory ./build - name: Configure CMake working-directory: build shell: bash run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DVCPKG_BUILD_TYPE=release $CMAKE_EXTRA - name: Compress cmake logs if: always() shell: bash run: | if [ "${{ matrix.os }}" == "macOS-10.15" ]; then TAR=gtar else TAR=tar fi find "$HOME/overte-files/vcpkg" -name '*log' -type f -print0 | $TAR --null --force-local -T - -c --xz -v -f "./cmake-logs-${{ matrix.os }}-${{ github.event.number }}.tar.xz" - name: Archive cmake logs if: always() uses: actions/upload-artifact@v3 with: name: cmake-logs-${{ matrix.os }}-${{ github.event.number }}.tar.xz path: ./cmake-logs-${{ matrix.os }}-${{ github.event.number }}.tar.xz if-no-files-found: error - name: Build Application if: matrix.build_type == 'full' || matrix.build_type == 'client' working-directory: build shell: bash run: cmake --build . --config $BUILD_TYPE --target $APP_TARGET_NAME $CMAKE_BUILD_EXTRA - name: Build Domain Server if: matrix.build_type == 'full' working-directory: build shell: bash run: cmake --build . --config $BUILD_TYPE --target domain-server $CMAKE_BUILD_EXTRA - name: Build Assignment Client if: matrix.build_type == 'full' working-directory: build shell: bash run: cmake --build . --config $BUILD_TYPE --target assignment-client $CMAKE_BUILD_EXTRA - name: Build Console if: matrix.build_type == 'full' && matrix.arch != 'aarch64' || startsWith(matrix.os, 'windows') working-directory: build shell: bash run: | cmake --build . --config $BUILD_TYPE --target packaged-server-console $CMAKE_BUILD_EXTRA - name: Build Installer if: matrix.build_type != 'android' && matrix.arch != 'aarch64' working-directory: build shell: bash run: | echo "Retry code from https://unix.stackexchange.com/a/137639" function fail { echo $1 >&2 exit 1 } function retry { local n=1 local max=5 local delay=15 while true; do "$@" && break || { if [[ $n -lt $max ]]; then ((n++)) echo "Command failed. Attempt $n/$max:" sleep $delay; else fail "The command has failed after $n attempts." fi } done } retry cmake --build . --config $BUILD_TYPE --target package $CMAKE_BUILD_EXTRA # As of 05/17/21 GitHub Virtual Environments changed their "Ubuntu 18.04.5 LTS" image to include two versions of CMake for Android # https://github.com/actions/virtual-environments/blob/ubuntu18/20210517.1/images/linux/Ubuntu1804-README.md # Removing 3.18.1 version of CMake as its not compatible with our Android build. # It will fall back to 3.10.2 which is already installed - name: Nuke CMake 3.18.1-g262b901 if: matrix.build_type == 'android' shell: bash run: | /usr/local/lib/android/sdk/tools/bin/sdkmanager --uninstall 'cmake;3.18.1' - name: Build for Android + Quest if: matrix.build_type == 'android' shell: bash working-directory: ${{runner.workspace}}/overte run: | echo "Pre-cache the vcpkg managed dependencies" $PYTHON_EXEC prebuild.py --build-root ${{runner.workspace}}/build --android interface cd android # Pre-cache the gradle dependencies ./gradlew -m tasks -PHIFI_ANDROID_PRECOMPILED=$HIFI_ANDROID_PRECOMPILED # Build! ./build_android.sh - name: Output system stats if: ${{ always() }} working-directory: build shell: bash run: | echo "Disk usage:" df -h - name: Output Installer Logs if: failure() && startsWith(matrix.os, 'Windows') shell: bash working-directory: build run: cat ./_CPack_Packages/win64/NSIS/NSISOutput.log - name: Upload Artifact if: startsWith(matrix.os, 'Windows') || startsWith(matrix.os, 'macOS') uses: actions/upload-artifact@v4 with: name: ${{ env.ARTIFACT_PATTERN }} path: ./build/${{ env.ARTIFACT_PATTERN }} if-no-files-found: error - name: Clear Working Directories if: contains(matrix.runner, 'linux_aarch64') || contains(matrix.runner, 'linux_amd64') shell: bash run: | rm -rf ./* rm -rf ~/overte-files rm -rf ~/.cache