name: Pull Request CI Build on: pull_request: types: [opened, synchronize, reopened, labeled] env: APP_NAME: interface BUILD_TYPE: Release CI_BUILD: Github GIT_COMMIT: ${{ github.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 CMAKE_BACKTRACE_URL: ${{ secrets.MINIDUMP_TOKEN }} CMAKE_BACKTRACE_TOKEN: PR_${{ github.event.number }}_${{ github.sha }} # OSX specific variables DEVELOPER_DIR: /Applications/Xcode_11.2.app/Contents/Developer MACOSX_DEPLOYMENT_TARGET: '10.11' # WIN32 specific variables PreferredToolArchitecture: X64 jobs: build: name: "build (${{matrix.os}}, ${{matrix.build_type}})" strategy: matrix: include: - os: windows-latest build_type: full - os: macOS-latest build_type: full - os: ubuntu-18.04 build_type: full apt-dependencies: mesa-common-dev libegl1 libglvnd-dev libdouble-conversion1 libpulse0 - os: ubuntu-18.04 build_type: android apt-dependencies: mesa-common-dev libegl1 libglvnd-dev libdouble-conversion1 libpulse0 fail-fast: false runs-on: ${{matrix.os}} if: github.event.action != 'labeled' || github.event.label.name == 'rebuild' steps: - name: Configure Build Environment 1 shell: bash id: buildenv1 run: | echo ::set-output name=github_sha_short::`echo $GIT_COMMIT | cut -c1-7` echo "JOB_NAME=build (${{matrix.os}}, ${{matrix.build_type}})" >> $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=-- -j3" >> $GITHUB_ENV echo "CMAKE_EXTRA=-DBUILD_TOOLS:BOOLEAN=FALSE -DHIFI_PYTHON_EXEC:FILEPATH=$(which python3)" >> $GITHUB_ENV fi # Mac build variables if [ "${{ matrix.os }}" = "macOS-latest" ]; then echo "PYTHON_EXEC=python3" >> $GITHUB_ENV echo "INSTALLER_EXT=dmg" >> $GITHUB_ENV echo "CMAKE_EXTRA=-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -G Xcode" >> $GITHUB_ENV fi # Windows build variables if [ "${{ matrix.os }}" = "windows-latest" ]; then echo "PYTHON_EXEC=python" >> $GITHUB_ENV echo "INSTALLER_EXT=exe" >> $GITHUB_ENV echo "CMAKE_EXTRA=-A x64" >> $GITHUB_ENV 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 }}" echo "GIT_COMMIT_SHORT=${{ steps.buildenv1.outputs.github_sha_short }}" >> $GITHUB_ENV if [[ "${{ matrix.build_type }}" != "android" ]]; then echo "ARTIFACT_PATTERN=Vircadia-Alpha-PR${{ github.event.number }}-*.$INSTALLER_EXT" >> $GITHUB_ENV # Build type variables echo "INSTALLER=Vircadia-Alpha-$RELEASE_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT" >> $GITHUB_ENV else echo "ARTIFACT_PATTERN=*.$INSTALLER_EXT" >> $GITHUB_ENV fi - name: Clear Working Directory if: startsWith(matrix.os, 'windows') shell: bash working-directory: ${{runner.workspace}} run: rm -rf ./* - uses: actions/checkout@v1 with: submodules: true fetch-depth: 1 - name: Install dependencies shell: bash if: startsWith(matrix.os, 'ubuntu') run: | echo "Installing Python Modules:" pip3 install distro || exit 1 echo "Updating apt repository index" sudo apt update || exit 1 echo "Installing apt packages" sudo apt install -y ${{ matrix.apt-dependencies }} || exit 1 - name: Create Build Environment shell: bash run: cmake -E make_directory "${{runner.workspace}}/build" - name: Configure CMake working-directory: ${{runner.workspace}}/build shell: bash run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DVCPKG_BUILD_TYPE=release $CMAKE_EXTRA - name: Build Application if: matrix.build_type == 'full' || matrix.build_type == 'client' working-directory: ${{runner.workspace}}/build shell: bash run: cmake --build . --config $BUILD_TYPE --target $APP_NAME $CMAKE_BUILD_EXTRA - name: Build Domain Server if: matrix.build_type == 'full' working-directory: ${{runner.workspace}}/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: ${{runner.workspace}}/build shell: bash run: cmake --build . --config $BUILD_TYPE --target assignment-client $CMAKE_BUILD_EXTRA - name: Build Console if: matrix.build_type == 'full' working-directory: ${{runner.workspace}}/build shell: bash run: cmake --build . --config $BUILD_TYPE --target packaged-server-console $CMAKE_BUILD_EXTRA - name: Build Installer if: matrix.build_type != 'android' working-directory: ${{runner.workspace}}/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 - name: Build for Android + Quest if: matrix.build_type == 'android' shell: bash working-directory: ${{runner.workspace}}/vircadia 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: ${{runner.workspace}}/build shell: bash run: | echo "Disk usage:" df -h - name: Output Installer Logs if: failure() && matrix.os == 'windows-latest' shell: bash working-directory: ${{runner.workspace}}/build run: cat ./_CPack_Packages/win64/NSIS/NSISOutput.log - name: Upload Artifact shell: bash working-directory: ${{runner.workspace}}/build env: GITHUB_CONTEXT: ${{ toJson(github) }} run: | if [[ "${{ matrix.build_type }}" == "android" ]]; then cd $GITHUB_WORKSPACE/android fi $PYTHON_EXEC "$GITHUB_WORKSPACE/tools/ci-scripts/upload_to_publish_server.py"