windows-build.yml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. #
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. #
  8. name: Windows Build
  9. # These jobs are to be triggered by ar.yml
  10. on:
  11. workflow_dispatch:
  12. workflow_call:
  13. inputs:
  14. compiler:
  15. required: true
  16. type: string
  17. config:
  18. required: true
  19. type: string
  20. image:
  21. required: true
  22. type: string
  23. platform:
  24. required: true
  25. type: string
  26. type:
  27. required: true
  28. type: string
  29. last_artifact:
  30. required: false
  31. type: boolean
  32. run-name: ${{ inputs.platform }} - ${{ inputs.type }}
  33. # Activate compiler cache
  34. env:
  35. O3DE_ENABLE_COMPILER_CACHE: true
  36. O3DE_COMPILER_CACHE_PATH: 'C:\ProgramData\Chocolatey\bin\ccache.exe'
  37. # Note: All 3P Github Actions use the commit hash for security reasons
  38. # Avoid using the tag version, which is vulnerable to supply chain attacks
  39. jobs:
  40. Build:
  41. strategy:
  42. fail-fast: false
  43. runs-on: ${{ inputs.image }}
  44. steps:
  45. - name: Checkout repo
  46. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  47. with:
  48. show-progress: false
  49. - name: Git LFS pull
  50. # Minimal pull for profile builds, otherwise pull all
  51. run: |
  52. git lfs install
  53. if ("${{ inputs.type }}" -eq "profile") { git lfs pull --include "*.ico,*.bmp" } else { git lfs pull }
  54. - name: Setup DevDrive
  55. uses: samypr100/setup-dev-drive@b9079d2711b01ed39de859c79c96484bfd80e078 # v3.4.1
  56. with:
  57. drive-size: 130GB
  58. drive-format: NTFS
  59. drive-path: "D:/dev_drive.vhdx"
  60. workspace-copy: true
  61. trusted-dev-drive: true
  62. - name: Setup 3p, user, and build folders
  63. # Symlink the .o3de folder to the github workspace to avoid permission issues
  64. run: |
  65. "3rdParty", "build", ".o3de" | % {New-Item "${{ env.DEV_DRIVE_WORKSPACE }}\$_" -ItemType 'Directory' -Force}
  66. "temp" | % {New-Item "${{ env.DEV_DRIVE }}\$_" -ItemType 'Directory' -Force}
  67. ".o3de" | % {New-Item -Path $env:USERPROFILE\$_ -ItemType SymbolicLink -Target ${{ env.DEV_DRIVE_WORKSPACE }}\$_ -Force}
  68. "AutomatedTesting\Cache", "AutomatedTesting\user" | % {New-Item "${{ env.DEV_DRIVE_WORKSPACE }}\$_" -ItemType 'Directory' -Force}
  69. - name: Move Page File to Workspace drive
  70. # Configure the page file to the workspace drive for the duration of the run
  71. run: |
  72. Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" `
  73. -Name "PagingFiles" -Value "${{ env.DEV_DRIVE }}\temp\pagefile.sys 8192 8192"
  74. echo "Page file moved to ${{ env.DEV_DRIVE }}\temp\pagefile.sys"
  75. - name: Get drive info
  76. run: |
  77. Get-PSDrive
  78. - name: Setup ccache
  79. uses: Chocobo1/setup-ccache-action@f84f86840109403e0fe0ded8b0766c9633affa16 # v1.4.7
  80. continue-on-error: true
  81. if: always()
  82. with:
  83. windows_compile_environment: msvc
  84. prepend_symlinks_to_path: false
  85. store_cache: false
  86. restore_cache: false
  87. ccache_options: |
  88. max_size=10G
  89. inode_cache=true
  90. hash_dir=false
  91. temporary_dir=${{ env.DEV_DRIVE }}\temp
  92. cache_dir=${{ env.DEV_DRIVE_WORKSPACE }}\.ccache
  93. - name: Get last run
  94. # Get the last runid of the target branch of a PR or the current branch
  95. uses: dawidd6/action-download-artifact@07ab29fd4a977ae4d2b275087cf67563dfdf0295 # v9
  96. id: last-run-id
  97. if: ${{ inputs.last_artifact }}
  98. continue-on-error: true
  99. with:
  100. workflow_search: true
  101. workflow_conclusion: ""
  102. branch: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.ref_name }}
  103. search_artifacts: true
  104. name: O3DE-${{ inputs.platform }}-${{ inputs.config }}-build
  105. dry_run: true
  106. - name: Set artifact run ID
  107. # Set the run ID of the artifact to be used for the download step
  108. id: set-artifact-run-id
  109. if: steps.last-run-id.outcome == 'success' && inputs.last_artifact == true
  110. run: |
  111. $runId = ${{ fromJSON(steps.last-run-id.outputs.artifacts)[0].workflow_run.id }}
  112. echo "artifact_run_id=$runId" >> $env:GITHUB_OUTPUT
  113. echo "Using artifacts from previous run: $runId"
  114. - name: Restore artifact cache
  115. # Restore the artifact from the "Get last run" step or from the current run
  116. uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
  117. id: restore-artifact-cache
  118. continue-on-error: true
  119. with:
  120. name: O3DE-${{ inputs.platform }}-${{ inputs.config }}-build
  121. github-token: ${{ secrets.GITHUB_TOKEN }}
  122. path: ${{ env.DEV_DRIVE_WORKSPACE }}
  123. run-id: ${{ steps.set-artifact-run-id.outputs.artifact_run_id || github.run_id }}
  124. - name: Extract artifact
  125. # Extract the tar file from the artifact
  126. id: extract-artifact
  127. continue-on-error: true
  128. if: ${{ steps.restore-artifact-cache.outcome == 'success' }}
  129. working-directory: ${{ env.DEV_DRIVE_WORKSPACE }}
  130. run: |
  131. if (Test-Path ${{ env.DEV_DRIVE_WORKSPACE }}\cache.tar) {
  132. tar -xvpf ${{ env.DEV_DRIVE_WORKSPACE }}\cache.tar
  133. rm ${{ env.DEV_DRIVE_WORKSPACE }}\cache.tar
  134. ${{ env.O3DE_COMPILER_CACHE_PATH }} --zero-stats --cleanup
  135. }
  136. - name: Setup cmake
  137. # Pin the version of cmake
  138. uses: lukka/get-cmake@56d043d188c3612951d8755da8f4b709ec951ad6 # v3.31.6
  139. with:
  140. cmakeVersion: "~3.30.0"
  141. - name: Set MSBuild options
  142. # Configuire VS environment variables through the developer command prompt for MSVC
  143. uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
  144. - name: Configure environment
  145. working-directory: ${{ env.DEV_DRIVE_WORKSPACE }}
  146. run: |
  147. echo "Installing dependencies"
  148. echo "Getting python..."
  149. python\get_python.bat
  150. echo "Installing additional python dependencies..."
  151. python\pip.sh install tempfile2 PyGithub
  152. - name: Build ${{ inputs.type }}
  153. # Builds with presets in ../scripts/build/Platform/Windows/build_config.json
  154. # Set temp folders to the workspace drive as the boot drive is slow
  155. working-directory: "${{ env.DEV_DRIVE_WORKSPACE }}"
  156. timeout-minutes: 310
  157. run: |
  158. $env:LY_3RDPARTY_PATH = "${{ env.DEV_DRIVE_WORKSPACE }}\3rdParty"
  159. $env:TEMP = "${{ env.DEV_DRIVE }}\temp"
  160. $env:TMP = "${{ env.DEV_DRIVE }}\temp"
  161. python\python.cmd -u scripts\build\ci_build.py --platform ${{ inputs.platform }} --type ${{ inputs.type }}
  162. - name: Compress artifacts
  163. # Compress with posix format to preserve permissions and timestamps at nanosecond precision
  164. # Skip compression and upload if the type is a test to reduce dirty build artifacts from previous runs
  165. id: compress-artifacts
  166. if: ${{ (steps.extract-artifact.outcome == 'success' || steps.extract-artifact.outcome == 'skipped') && !cancelled() && !contains(inputs.type, 'test') }}
  167. continue-on-error: true
  168. working-directory: ${{ env.DEV_DRIVE_WORKSPACE }}
  169. run: |
  170. try {
  171. tar --format=posix -cvpf ${{ env.DEV_DRIVE_WORKSPACE }}\cache.tar `
  172. .ccache `
  173. .o3de\python `
  174. 3rdParty\packages `
  175. AutomatedTesting\Cache
  176. } catch {
  177. echo "Warning: Error during tar compression"
  178. }
  179. - name: Save artifacts
  180. uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
  181. if: ${{ steps.compress-artifacts.conclusion == 'success' && !cancelled() && !contains(inputs.type, 'test') }}
  182. continue-on-error: true
  183. with:
  184. name: O3DE-${{ inputs.platform }}-${{ inputs.config }}-build
  185. compression-level: 1
  186. overwrite: true
  187. path: |
  188. ${{ env.DEV_DRIVE_WORKSPACE }}\cache.tar