|
| 1 | +on: |
| 2 | + workflow_call: |
| 3 | + inputs: |
| 4 | + unreal-version: |
| 5 | + required: true |
| 6 | + type: string |
| 7 | + |
| 8 | +env: |
| 9 | + REGISTRY: ghcr.io |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + name: Test |
| 14 | + runs-on: ubuntu-latest-4-cores |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Free disk space |
| 18 | + run: | |
| 19 | + # time df -h |
| 20 | + sudo time swapoff -a |
| 21 | + sudo time rm -f /swapfile |
| 22 | + sudo time rm -rf /usr/local/lib/android |
| 23 | + sudo time rm -rf /usr/share/dotnet |
| 24 | + sudo time rm -rf /usr/share/swift |
| 25 | + sudo time rm -rf /usr/local/share/powershell |
| 26 | + sudo time rm -rf /usr/local/.ghcup |
| 27 | + sudo time rm -rf /usr/local/lib/node_modules |
| 28 | + sudo time rm -rf /usr/local/share/boost |
| 29 | + sudo time rm -rf /usr/lib/google-cloud-sdk |
| 30 | + sudo time rm -rf /usr/lib/jvm |
| 31 | + sudo time rm -rf /opt/pipx |
| 32 | + sudo time rm -rf /opt/ghc |
| 33 | + sudo time rm -rf "$AGENT_TOOLSDIRECTORY" |
| 34 | + sudo time apt-get clean |
| 35 | + sudo time rm -rf /var/lib/apt/lists/* |
| 36 | + # time docker rmi $(docker image ls -aq) |
| 37 | + # time du --max-depth=3 --threshold=100M -h /usr /opt /var 2>/dev/null | sort -hr |
| 38 | + df -h |
| 39 | +
|
| 40 | + - name: Log in to GitHub package registry |
| 41 | + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a |
| 42 | + with: |
| 43 | + registry: ${{ env.REGISTRY }} |
| 44 | + username: ${{ github.actor }} |
| 45 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + |
| 47 | + - name: Start Docker container |
| 48 | + env: |
| 49 | + WORKSPACE_PATH: ${{ github.workspace }} |
| 50 | + UNREAL_VERSION: ${{ inputs.unreal-version }} |
| 51 | + DISALLOW_RAW_POINTERS: ${{ inputs.unreal-version == '4.27' && 'false' || 'true' }} |
| 52 | + run: | |
| 53 | + # We start the container with the user ID of the parent GH action user to avoid permission issues on volume. |
| 54 | + # For UE 5.4 we have to enable ipv6 to fix container startup issues. See https://github.com/adamrehn/ue4-docker/issues/357 |
| 55 | + uid=$(id -u) # the GH action user ID |
| 56 | + gid=1000 # the ue4 group in the docker container |
| 57 | + user='gh' |
| 58 | + set -x |
| 59 | + docker network create --ipv6 --subnet 2001:0DB8::/112 ip6net |
| 60 | + docker run -td \ |
| 61 | + --name unreal \ |
| 62 | + --volume "$WORKSPACE_PATH:/workspace" \ |
| 63 | + --workdir /workspace \ |
| 64 | + --user $uid:$gid \ |
| 65 | + --env HOME="/home/$user" \ |
| 66 | + --env PATH="/home/$user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ |
| 67 | + --env DISALLOW_RAW_POINTERS=$DISALLOW_RAW_POINTERS \ |
| 68 | + --network ip6net -p 80:80 \ |
| 69 | + ghcr.io/getsentry/unreal-docker:"$UNREAL_VERSION"-android |
| 70 | + docker logout ghcr.io |
| 71 | + # Add the user so it has a home directory (needed to run tests later on) |
| 72 | + docker exec --user root unreal useradd -u $uid -g $gid --create-home $user |
| 73 | + # Ensure the gh user owns their home directory (needed for clang++ to write temp files) |
| 74 | + docker exec --user root unreal chown -R $uid:$gid /home/$user |
| 75 | + # Ensure CA certs are in the right directory (needed for running tests) |
| 76 | + docker exec --user root unreal bash -c " |
| 77 | + mkdir -p /etc/pki/tls/certs ; |
| 78 | + cp /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt " |
| 79 | +
|
| 80 | + # Chown some paths to the GH user to make UE5 work properly. We can't just chown the whole UnrealEngine or |
| 81 | + # docker would implicitly have to copy it to the container and we would run out of space on the GH runner. |
| 82 | + - name: Chown Docker container paths |
| 83 | + env: |
| 84 | + ENGINE_PATH: ${{ inputs.unreal-version == '4.27' && 'Programs/UnrealPak/Saved' || 'Binaries/ThirdParty/DotNet' }} |
| 85 | + run: | |
| 86 | + uid=$(id -u) # the GH action user ID |
| 87 | + docker exec --user root unreal bash -c " |
| 88 | + chown -R $uid /home/ue4/UnrealEngine/Engine/Binaries/ThirdParty/Mono/Linux ; |
| 89 | + chown -R $uid /home/ue4/UnrealEngine/Engine/\"$ENGINE_PATH\" ; |
| 90 | + chown -R $uid /home/ue4/UnrealEngine/Engine/Binaries/ThirdParty/USD/UsdResources/Linux ; |
| 91 | + chown -R $uid /home/ue4/UnrealEngine/Engine/Programs/AutomationTool ; |
| 92 | + chown -R $uid /home/ue4/android-sdk ; |
| 93 | + mkdir -p /home/ue4/UnrealEngine/Epic/UnrealEngine && chown -R $uid /home/ue4/UnrealEngine/Epic ; |
| 94 | + mkdir -p /home/ue4/UnrealEngine/Engine/Source/Epic/UnrealEngine && chown -R $uid /home/ue4/UnrealEngine/Engine/Source/Epic ; |
| 95 | + mkdir -p /home/ue4/UnrealEngine/Engine/Intermediate/Build/BuildCookRun && chown -R $uid /home/ue4/UnrealEngine/Engine/Intermediate/Build/BuildCookRun ; |
| 96 | + mkdir -p /home/ue4/.config/Epic/UnrealEngine && chown -R $uid /home/ue4/.config ; |
| 97 | + mkdir -p /home/ue4/UnrealEngine/UnrealTrace && chown -R $uid /home/ue4/UnrealEngine/UnrealTrace ; |
| 98 | + mkdir -p /home/ue4/.gradle && chown -R $uid /home/ue4/.gradle ; |
| 99 | + mkdir -p /home/gh/.cache/tmp && chown -R $uid /home/gh/.cache ; |
| 100 | + mkdir -p /home/gh/Library/Logs && chown -R $uid /home/gh/Library " |
| 101 | +
|
| 102 | + - name: Download package |
| 103 | + uses: actions/download-artifact@v4 |
| 104 | + with: |
| 105 | + name: ${{ github.sha }} |
| 106 | + |
| 107 | + - uses: actions/checkout@v4 |
| 108 | + with: |
| 109 | + path: checkout |
| 110 | + submodules: recursive |
| 111 | + |
| 112 | + - name: Extract package to sample/Plugins |
| 113 | + env: |
| 114 | + UNREAL_VERSION: ${{ inputs.unreal-version }} |
| 115 | + run: unzip sentry-unreal-*-engine"$UNREAL_VERSION".zip -d checkout/sample/Plugins/sentry |
| 116 | + |
| 117 | + - name: Compute DDC cache key |
| 118 | + id: ddc-cache-key |
| 119 | + run: | |
| 120 | + HASH="${{ hashFiles('checkout/sample/Content/**', 'checkout/sample/Config/**/*.ini', 'checkout/sample/*.uproject') }}" |
| 121 | + KEY="ue-${{ inputs.unreal-version }}-android-ddc-${HASH}" |
| 122 | + echo "key=${KEY}" >> $GITHUB_OUTPUT |
| 123 | + echo "DDC cache key: ${KEY}" |
| 124 | +
|
| 125 | + - name: Configure project-local DDC |
| 126 | + shell: pwsh |
| 127 | + run: ./checkout/scripts/configure-local-ddc.ps1 -ProjectPath checkout/sample |
| 128 | + |
| 129 | + - name: Restore cached DDC |
| 130 | + id: cache-ddc |
| 131 | + uses: actions/cache/restore@v4 |
| 132 | + with: |
| 133 | + path: checkout/sample/DerivedDataCache |
| 134 | + key: ${{ steps.ddc-cache-key.outputs.key }} |
| 135 | + restore-keys: | |
| 136 | + ue-${{ inputs.unreal-version }}-android-ddc |
| 137 | +
|
| 138 | + - name: Set permissions for sample |
| 139 | + # sentry-native requires write access to sample project directory in order to initialize itself properly |
| 140 | + run: docker exec -w /workspace/checkout unreal chmod -R +x sample |
| 141 | + |
| 142 | + - name: Set execute permission for Python3 |
| 143 | + # Python3 is needed for post-build symbol upload script |
| 144 | + run: docker exec --user root unreal chmod +x /home/ue4/UnrealEngine/Engine/Binaries/ThirdParty/Python3/Linux/bin/python3 |
| 145 | + |
| 146 | + - name: Update engine's build configuration |
| 147 | + run: | |
| 148 | + docker exec unreal bash -c " |
| 149 | + mkdir -p ~/.config/Unreal\ Engine/UnrealBuildTool ; |
| 150 | + cp /workspace/checkout/.github/BuildConfiguration.xml ~/.config/Unreal\ Engine/UnrealBuildTool/ " |
| 151 | +
|
| 152 | + - name: Build Android package |
| 153 | + id: build-android |
| 154 | + env: |
| 155 | + SENTRY_UPLOAD_SYMBOLS_AUTOMATICALLY: true |
| 156 | + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} |
| 157 | + SENTRY_ORG: ${{ secrets.SENTRY_ORG }} |
| 158 | + SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} |
| 159 | + run: | |
| 160 | + docker exec -w /workspace/checkout/sample \ |
| 161 | + -e TMPDIR=/home/gh/.cache/tmp \ |
| 162 | + -e SENTRY_UPLOAD_SYMBOLS_AUTOMATICALLY="$SENTRY_UPLOAD_SYMBOLS_AUTOMATICALLY" \ |
| 163 | + -e SENTRY_AUTH_TOKEN="$SENTRY_AUTH_TOKEN" \ |
| 164 | + -e SENTRY_ORG="$SENTRY_ORG" \ |
| 165 | + -e SENTRY_PROJECT="$SENTRY_PROJECT" \ |
| 166 | + unreal /home/ue4/UnrealEngine/Engine/Build/BatchFiles/RunUAT.sh BuildCookRun \ |
| 167 | + -project=/workspace/checkout/sample/SentryPlayground.uproject \ |
| 168 | + -archivedirectory=/workspace/checkout/sample/Builds \ |
| 169 | + -platform=Android \ |
| 170 | + -clientconfig=Development \ |
| 171 | + -nop4 \ |
| 172 | + -cook \ |
| 173 | + -iterate \ |
| 174 | + -build \ |
| 175 | + -stage \ |
| 176 | + -prereqs \ |
| 177 | + -package \ |
| 178 | + -archive |
| 179 | +
|
| 180 | + - name: Save DDC to cache |
| 181 | + if: ${{ success() && steps.cache-ddc.outputs.cache-hit != 'true' }} |
| 182 | + uses: actions/cache/save@v4 |
| 183 | + with: |
| 184 | + path: checkout/sample/DerivedDataCache |
| 185 | + key: ${{ steps.ddc-cache-key.outputs.key }} |
| 186 | + |
| 187 | + - name: Collect build logs on failure |
| 188 | + if: ${{ always() && steps.build-android.outcome == 'failure' }} |
| 189 | + uses: actions/upload-artifact@v4 |
| 190 | + with: |
| 191 | + name: UE ${{ inputs.unreal-version }} Android build logs |
| 192 | + path: | |
| 193 | + checkout/sample/Saved/Logs |
| 194 | +
|
| 195 | + - name: Upload Android build |
| 196 | + if: ${{ success() && steps.build-android.outcome == 'success' }} |
| 197 | + uses: actions/upload-artifact@v4 |
| 198 | + with: |
| 199 | + name: UE ${{ inputs.unreal-version }} sample build (Android) |
| 200 | + path: checkout/sample/Builds/Android/ |
| 201 | + retention-days: 1 |
0 commit comments