123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- #
- # Copyright (c) Contributors to the Open 3D Engine Project.
- # For complete copyright and license terms please see the LICENSE at the root of this distribution.
- #
- # SPDX-License-Identifier: Apache-2.0 OR MIT
- #
- #
- name: Android Build
- # These jobs are to be triggered by ar.yml
- on:
- workflow_dispatch:
- workflow_call:
- inputs:
- compiler:
- required: true
- type: string
- config:
- required: true
- type: string
- image:
- required: true
- type: string
- platform:
- required: true
- type: string
- type:
- required: true
- type: string
- last_artifact:
- required: false
- type: boolean
- run-name: ${{ inputs.platform }} - ${{ inputs.type }}
- # Activate compiler cache
- env:
- O3DE_ENABLE_COMPILER_CACHE: true
- O3DE_COMPILER_CACHE_PATH: 'C:\ProgramData\Chocolatey\bin\ccache.exe'
- NDK_VERSION: 25.1.8937393
- # Note: All 3P Github Actions use the commit hash for security reasons
- # Avoid using the tag version, which is vulnerable to supply chain attacks
- jobs:
- Build:
- strategy:
- fail-fast: false
- runs-on: ${{ inputs.image }}
-
- steps:
- - name: Checkout repo
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- with:
- show-progress: false
- - name: Git LFS pull
- # Minimal pull for profile builds, otherwise pull all
- run: |
- git lfs install
- if ("${{ inputs.type }}" -eq "profile") { git lfs pull --include "*.ico,*.bmp" } else { git lfs pull }
- - name: Setup DevDrive
- uses: samypr100/setup-dev-drive@b9079d2711b01ed39de859c79c96484bfd80e078 # v3.4.1
- with:
- drive-size: 130GB
- drive-format: NTFS
- drive-path: "D:/dev_drive.vhdx"
- workspace-copy: true
- trusted-dev-drive: true
- - name: Setup 3p, user, and build folders
- # Symlink the .o3de folder to the github workspace to avoid permission issues
- run: |
- "3rdParty", "build", ".o3de" | % {New-Item "${{ env.DEV_DRIVE_WORKSPACE }}\$_" -ItemType 'Directory' -Force}
- "temp" | % {New-Item "${{ env.DEV_DRIVE }}\$_" -ItemType 'Directory' -Force}
- ".o3de" | % {New-Item -Path $env:USERPROFILE\$_ -ItemType SymbolicLink -Target ${{ env.DEV_DRIVE_WORKSPACE }}\$_ -Force}
- "AutomatedTesting\Cache", "AutomatedTesting\user" | % {New-Item "${{ env.DEV_DRIVE_WORKSPACE }}\$_" -ItemType 'Directory' -Force}
- - name: Move Page File to Workspace drive
- # Configure the page file to the workspace drive for the duration of the run
- run: |
- Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" `
- -Name "PagingFiles" -Value "${{ env.DEV_DRIVE }}\temp\pagefile.sys 8192 8192"
- echo "Page file moved to ${{ env.DEV_DRIVE }}\temp\pagefile.sys"
- - name: Get drive info
- run: |
- Get-PSDrive
- - name: Setup ccache
- uses: Chocobo1/setup-ccache-action@f84f86840109403e0fe0ded8b0766c9633affa16 # v1.4.7
- continue-on-error: true
- if: always()
- with:
- windows_compile_environment: msvc
- prepend_symlinks_to_path: false
- store_cache: false
- restore_cache: false
- ccache_options: |
- max_size=10G
- inode_cache=true
- hash_dir=false
- temporary_dir=${{ env.DEV_DRIVE }}\temp
- cache_dir=${{ env.DEV_DRIVE_WORKSPACE }}\.ccache
-
- - name: Check for rerun
- id: check-rerun
- run: |
- # GitHub sets GITHUB_RUN_ATTEMPT to track reruns
- if ($env:GITHUB_RUN_ATTEMPT -gt 1) {
- echo "is_rerun=true" >> $env:GITHUB_OUTPUT
- echo "This is rerun attempt #$env:GITHUB_RUN_ATTEMPT"
- } else {
- echo "is_rerun=false" >> $env:GITHUB_OUTPUT
- echo "This is the first run attempt"
- }
- - name: Get last run
- # Get the last runid of the target branch of a PR or the current branch
- # Skip if this is a rerun to either freshly build or get artifacts from existing run
- uses: dawidd6/action-download-artifact@07ab29fd4a977ae4d2b275087cf67563dfdf0295 # v9
- id: last-run-id
- if: ${{ inputs.last_artifact && steps.check-rerun.outputs.is_rerun != 'true' }}
- continue-on-error: true
- with:
- workflow_search: true
- workflow_conclusion: ""
- branch: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.ref_name }}
- search_artifacts: true
- check_artifacts: true
- name: O3DE-${{ inputs.platform }}-${{ inputs.config }}-build
- dry_run: true
- - name: Set artifact run ID
- # Set the run ID of the artifact to be used for the download step
- id: set-artifact-run-id
- if: steps.last-run-id.outcome == 'success' && inputs.last_artifact == true
- run: |
- $runId = ${{ fromJSON(steps.last-run-id.outputs.artifacts)[0].workflow_run.id }}
- echo "artifact_run_id=$runId" >> $env:GITHUB_OUTPUT
- echo "Using artifacts from previous run: $runId"
-
- - name: Restore artifact cache
- # Restore the artifact from the "Get last run" step or from the current run
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
- id: restore-artifact-cache
- continue-on-error: true
- with:
- name: O3DE-${{ inputs.platform }}-${{ inputs.config }}-build
- github-token: ${{ secrets.GITHUB_TOKEN }}
- path: ${{ env.DEV_DRIVE_WORKSPACE }}
- run-id: ${{ steps.set-artifact-run-id.outputs.artifact_run_id || github.run_id }}
- - name: Extract artifact
- # Extract the tar file from the artifact
- id: extract-artifact
- continue-on-error: true
- if: ${{ steps.restore-artifact-cache.outcome == 'success' }}
- working-directory: ${{ env.DEV_DRIVE_WORKSPACE }}
- run: |
- if (Test-Path ${{ env.DEV_DRIVE_WORKSPACE }}\cache.tar) {
- tar -xvpf ${{ env.DEV_DRIVE_WORKSPACE }}\cache.tar
- rm ${{ env.DEV_DRIVE_WORKSPACE }}\cache.tar
- ${{ env.O3DE_COMPILER_CACHE_PATH }} --zero-stats --cleanup
- }
-
- - name: Setup cmake
- # Pin the version of cmake
- uses: lukka/get-cmake@56d043d188c3612951d8755da8f4b709ec951ad6 # v3.31.6
- with:
- cmakeVersion: "~3.30.0"
- - name: Set MSBuild options
- # Configuire VS environment variables through the developer command prompt for MSVC
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
-
- - name: Configure environment
- # Install dependencies for gradle and clang builds from the NDK
- continue-on-error: true
- working-directory: ${{ env.DEV_DRIVE_WORKSPACE }}
- run: |
- echo "Installing dependencies"
- echo "Getting python..."
- python\get_python.bat
- echo "Installing NDK ${{ env.NDK_VERSION }}..."
- & "$env:ANDROID_HOME\cmdline-tools\latest\bin\sdkmanager.bat" --install 'ndk;${{ env.NDK_VERSION }}' --sdk_root=$env:ANDROID_HOME
- echo "Accepting Android SDK licenses..."
- "y`ny" | & "$env:ANDROID_HOME\cmdline-tools\latest\bin\sdkmanager.bat" --licenses --sdk_root=$env:ANDROID_HOME
- echo "LY_NDK_DIR=$env:ANDROID_HOME\ndk\${{ env.NDK_VERSION }}" >> $env:GITHUB_ENV
- echo "JDK_HOME=$env:JAVA_HOME_17_X64" >> $env:GITHUB_ENV
- echo "JAVA_HOME=$env:JAVA_HOME_17_X64" >> $env:GITHUB_ENV
- echo "GRADLE_BUILD_HOME=$env:GRADLE_HOME" >> $env:GITHUB_ENV
-
- - name: Build ${{ inputs.type }}
- # Builds with presets in ../scripts/build/Platform/Android/build_config.json
- # Set temp folders to the workspace drive as the boot drive is slow
- working-directory: ${{ env.DEV_DRIVE_WORKSPACE }}
- timeout-minutes: 330
- run: |
- $env:LY_3RDPARTY_PATH = "${{ env.DEV_DRIVE_WORKSPACE }}\3rdParty"
- $env:LY_PACKAGE_SERVER_URLS = "https://d1gg6ket0m44ly.cloudfront.net;https://d3t6xeg4fgfoum.cloudfront.net"
- $env:TEMP = "${{ env.DEV_DRIVE }}\temp"
- $env:TMP = "${{ env.DEV_DRIVE }}\temp"
- scripts\o3de.bat register --this-engine # Resolves registration issue with gradle build
- python\python.cmd -u scripts\build\ci_build.py --platform ${{ inputs.platform }} --type ${{ inputs.type }}
-
- - name: Compress artifacts
- # Compress with posix format to preserve permissions and timestamps at nanosecond precision
- # Skip compression and upload if the type is a test to reduce dirty build artifacts from previous runs
- id: compress-artifacts
- if: ${{ (steps.extract-artifact.outcome == 'success' || steps.extract-artifact.outcome == 'skipped') && !cancelled() && !contains(inputs.type, 'test') }}
- continue-on-error: true
- working-directory: ${{ env.DEV_DRIVE_WORKSPACE }}
- run: |
- try {
- tar --format=posix -cvpf ${{ env.DEV_DRIVE_WORKSPACE }}\cache.tar `
- .ccache `
- .o3de\python\downloaded_packages `
- 3rdParty\downloaded_packages `
- AutomatedTesting\Cache
- } catch {
- echo "Warning: Error during tar compression"
- }
-
- - name: Save artifacts
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
- if: ${{ steps.compress-artifacts.conclusion == 'success' && !cancelled() && !contains(inputs.type, 'test') }}
- continue-on-error: true
- with:
- name: O3DE-${{ inputs.platform }}-${{ inputs.config }}-build
- compression-level: 1
- overwrite: true
- path: |
- ${{ env.DEV_DRIVE_WORKSPACE }}\cache.tar
|