From 75b99e71ecbce70218e433efc4d4dcee02b7e919 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Tue, 11 Aug 2020 15:49:34 -0700 Subject: [PATCH] playing with gha --- .github/workflows/pr_build.yml | 51 ++++++++++++++++++++++++++++++---- android/build_android.sh | 10 +++---- android/containerized_build.sh | 8 +++--- android/docker/Dockerfile | 28 ++++++++----------- prebuild.py | 2 +- 5 files changed, 66 insertions(+), 33 deletions(-) diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml index f28cf1e66b..7bd061e7d2 100644 --- a/.github/workflows/pr_build.yml +++ b/.github/workflows/pr_build.yml @@ -27,14 +27,20 @@ env: jobs: build: + name: "build (${{matrix.os}}, ${{matrix.build_type}})" strategy: matrix: - os: [windows-latest, macOS-latest, ubuntu-18.04] - build_type: [full] 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' @@ -65,14 +71,25 @@ jobs: echo ::set-env name=INSTALLER_EXT::exe echo ::set-env name=CMAKE_EXTRA::"-A x64" fi + # Android + Quest build variables + if [[ "${{ matrix.build_type }}" == "android" ]]; then + HIFI_ANDROID_PRECOMPILED="${{runner.workspace}}/dependencies" + echo ::set-env name=HIFI_ANDROID_PRECOMPILED::"$HIFI_ANDROID_PRECOMPILED" + mkdir $HIFI_ANDROID_PRECOMPILED + echo ::set-env name=INSTALLER_EXT::apk + 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 ::set-env name=ARTIFACT_PATTERN::Vircadia-Alpha-PR${{ github.event.number }}-*.$INSTALLER_EXT - # Build type variables - echo ::set-env name=INSTALLER::Vircadia-Alpha-$RELEASE_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT + if [[ "${{ matrix.build_type }}" != "android" ]]; then + echo ::set-env name=ARTIFACT_PATTERN::Vircadia-Alpha-PR${{ github.event.number }}-*.$INSTALLER_EXT + # Build type variables + echo ::set-env name=INSTALLER::Vircadia-Alpha-$RELEASE_NUMBER-$GIT_COMMIT_SHORT.$INSTALLER_EXT + else + echo ::set-env name=ARTIFACT_PATTERN::*.$INSTALLER_EXT + fi - name: Clear Working Directory if: startsWith(matrix.os, 'windows') shell: bash @@ -98,26 +115,32 @@ jobs: shell: bash run: cmake -E make_directory "${{runner.workspace}}/build" - name: Configure CMake + if: matrix.build_type != 'android' 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: | @@ -144,6 +167,18 @@ jobs: 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}}/project-athena + 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 @@ -161,4 +196,8 @@ jobs: working-directory: ${{runner.workspace}}/build env: GITHUB_CONTEXT: ${{ toJson(github) }} - run: $PYTHON_EXEC "$GITHUB_WORKSPACE/tools/ci-scripts/upload_to_publish_server.py" + run: | + if [[ "${{ matrix.build_type }}" == "android" ]]; then + cd $GITHUB_WORKSPACE/android + fi + $PYTHON_EXEC "$GITHUB_WORKSPACE/tools/ci-scripts/upload_to_publish_server.py" \ No newline at end of file diff --git a/android/build_android.sh b/android/build_android.sh index e9c69b09de..9cf1b9e2ab 100755 --- a/android/build_android.sh +++ b/android/build_android.sh @@ -5,11 +5,11 @@ ANDROID_BUILD_TYPE=release ANDROID_BUILD_TARGET=assembleRelease if [[ "$RELEASE_TYPE" == "PR" ]]; then -ANDROID_APK_SUFFIX=PR${RELEASE_NUMBER}-${SHA7}.apk ; +ANDROID_APK_SUFFIX=PR${RELEASE_NUMBER}-${GIT_COMMIT_SHORT}.apk ; elif [[ "${STABLE_BUILD}" == "1" ]]; then ANDROID_APK_SUFFIX=${RELEASE_NUMBER}.apk ; else -ANDROID_APK_SUFFIX=${RELEASE_NUMBER}-${SHA7}.apk ; +ANDROID_APK_SUFFIX=${RELEASE_NUMBER}-${GIT_COMMIT_SHORT}.apk ; fi @@ -17,7 +17,7 @@ fi ANDROID_APP=interface ANDROID_OUTPUT_DIR=./apps/${ANDROID_APP}/build/outputs/apk/${ANDROID_BUILD_TYPE} ANDROID_OUTPUT_FILE=${ANDROID_APP}-${ANDROID_BUILD_TYPE}.apk -ANDROID_APK_NAME=HighFidelity-Beta-${ANDROID_APK_SUFFIX} +ANDROID_APK_NAME=Vircadia-Alpha-${ANDROID_APK_SUFFIX} ./gradlew -PHIFI_ANDROID_PRECOMPILED=${HIFI_ANDROID_PRECOMPILED} -PVERSION_CODE=${VERSION_CODE} -PRELEASE_NUMBER=${RELEASE_NUMBER} -PRELEASE_TYPE=${RELEASE_TYPE} ${ANDROID_APP}:${ANDROID_BUILD_TARGET} cp ${ANDROID_OUTPUT_DIR}/${ANDROID_OUTPUT_FILE} ./${ANDROID_APK_NAME} @@ -25,9 +25,9 @@ cp ${ANDROID_OUTPUT_DIR}/${ANDROID_OUTPUT_FILE} ./${ANDROID_APK_NAME} ANDROID_APP=questInterface ANDROID_OUTPUT_DIR=./apps/${ANDROID_APP}/build/outputs/apk/${ANDROID_BUILD_TYPE} ANDROID_OUTPUT_FILE=${ANDROID_APP}-${ANDROID_BUILD_TYPE}.apk -ANDROID_APK_NAME=HighFidelity-Quest-Beta-${ANDROID_APK_SUFFIX} +ANDROID_APK_NAME=Vircadia-Quest-Alpha-${ANDROID_APK_SUFFIX} ./gradlew -PHIFI_ANDROID_PRECOMPILED=${HIFI_ANDROID_PRECOMPILED} -PVERSION_CODE=${VERSION_CODE} -PRELEASE_NUMBER=${RELEASE_NUMBER} -PRELEASE_TYPE=${RELEASE_TYPE} ${ANDROID_APP}:${ANDROID_BUILD_TARGET} || true -cp ${ANDROID_OUTPUT_DIR}/${ANDROID_OUTPUT_FILE} ./${ANDROID_APK_NAME} || true +cp ${ANDROID_OUTPUT_DIR}/${ANDROID_OUTPUT_FILE} ./${ANDROID_APK_NAME} diff --git a/android/containerized_build.sh b/android/containerized_build.sh index 0c21d1df91..94b5b28831 100755 --- a/android/containerized_build.sh +++ b/android/containerized_build.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash set -xeuo pipefail -DOCKER_IMAGE_NAME="hifi_androidbuild" +DOCKER_IMAGE_NAME="vircadia_androidbuild" -docker build --build-arg BUILD_UID=`id -u` -t "${DOCKER_IMAGE_NAME}" -f docker/Dockerfile docker +docker build --build-arg BUILD_UID=`id -u` -t "${DOCKER_IMAGE_NAME}" -f ./android/docker/Dockerfile ./android/docker # The Jenkins PR builds use VERSION_CODE, but the release builds use VERSION # So make sure we use VERSION_CODE consistently @@ -17,7 +17,7 @@ test -z "$STABLE_BUILD" && export STABLE_BUILD=0 docker run \ --rm \ --security-opt seccomp:unconfined \ - -v "${WORKSPACE}":/home/jenkins/hifi \ + -v "${WORKSPACE}":/home/gha/project-athena \ -e RELEASE_NUMBER \ -e RELEASE_TYPE \ -e ANDROID_APP \ @@ -33,7 +33,7 @@ docker run \ -e OAUTH_CLIENT_SECRET \ -e OAUTH_CLIENT_ID \ -e OAUTH_REDIRECT_URI \ - -e SHA7 \ + -e GIT_COMMIT_SHORT \ -e STABLE_BUILD \ -e VERSION_CODE \ "${DOCKER_IMAGE_NAME}" \ diff --git a/android/docker/Dockerfile b/android/docker/Dockerfile index f6c0e7b2e5..144f6caffa 100644 --- a/android/docker/Dockerfile +++ b/android/docker/Dockerfile @@ -57,13 +57,13 @@ RUN apt-get -y install \ # --- Gradle ARG BUILD_UID=1001 -RUN useradd -ms /bin/bash -u $BUILD_UID jenkins -RUN echo "jenkins ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -USER jenkins -WORKDIR /home/jenkins +RUN useradd -ms /bin/bash -u $BUILD_UID gha +RUN echo "gha ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers +USER gha +WORKDIR /home/gha -# Hifi dependencies -ENV HIFI_BASE="/home/jenkins/hifi_android" +# Vircadia dependencies +ENV HIFI_BASE="/home/gha/vircadia_android" ENV HIFI_ANDROID_PRECOMPILED="$HIFI_BASE/dependencies" ENV HIFI_VCPKG_BASE="$HIFI_BASE/vcpkg" @@ -71,24 +71,18 @@ RUN mkdir "$HIFI_BASE" && \ mkdir "$HIFI_VCPKG_BASE" && \ mkdir "$HIFI_ANDROID_PRECOMPILED" -# Checkout a relatively recent commit from the main repository and use it to cache the -# gradle and vcpkg dependencies -# This commit ID should be updated whenever someone changes the dependency list -# in cmake/ports -RUN git clone https://github.com/highfidelity/hifi.git && \ - cd ~/hifi && \ - git checkout 796bfb5d6715ff14c2e60f3ee8fac1465b7578c6 +# Download the repo +RUN git clone https://github.com/kasenvr/project-athena.git -WORKDIR /home/jenkins/hifi +WORKDIR /home/gha/project-athena RUN mkdir build # Pre-cache the vcpkg managed dependencies -WORKDIR /home/jenkins/hifi/build +WORKDIR /home/gha/project-athena/build RUN python3 ../prebuild.py --build-root `pwd` --android interface # Pre-cache the gradle dependencies -WORKDIR /home/jenkins/hifi/android +WORKDIR /home/gha/project-athena/android RUN ./gradlew -m tasks -PHIFI_ANDROID_PRECOMPILED=$HIFI_ANDROID_PRECOMPILED #RUN ./gradlew extractDependencies -PHIFI_ANDROID_PRECOMPILED=$HIFI_ANDROID_PRECOMPILED - diff --git a/prebuild.py b/prebuild.py index cc315a49a4..21363bb9de 100644 --- a/prebuild.py +++ b/prebuild.py @@ -102,7 +102,7 @@ def parse_args(): if True: args = parser.parse_args() else: - args = parser.parse_args(['--android', 'questInterface', '--build-root', 'C:/git/hifi/android/apps/questInterface/.externalNativeBuild/cmake/debug/arm64-v8a']) + args = parser.parse_args(['--android', 'questInterface', '--build-root', 'C:/git/project-athena/android/apps/questInterface/.externalNativeBuild/cmake/debug/arm64-v8a']) return args def main():