forked from o3de/o3de
-
Notifications
You must be signed in to change notification settings - Fork 0
246 lines (222 loc) · 9.5 KB
/
Copy pathlinux-build.yml
File metadata and controls
246 lines (222 loc) · 9.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#
# 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: Linux 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
desktop:
required: false
type: boolean
clang_version:
required: false
type: string
cmake_version:
required: false
type: string
run-name: ${{ inputs.platform }} - ${{ inputs.type }}
# 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:
runs-on: ${{ inputs.image }}
steps:
- name: Check disk space
# Check if the workspace has enough free space, otherwise flag the disk for resizing
env:
MIN_FREE_DISK: 70 # in GB
id: check-disk
run: |
AVAIL_GB=$(df ${{ github.workspace }} --output=avail --block-size=1G | tail -1 | tr -d ' ')
echo "Workspace has ${AVAIL_GB}GB available"
if [ "$AVAIL_GB" -lt ${{ env.MIN_FREE_DISK }} ]; then
echo "needs_resize=true" >> $GITHUB_OUTPUT
echo "Workspace has less than ${{ env.MIN_FREE_DISK }}GB available, resizing disk"
else
echo "needs_resize=false" >> $GITHUB_OUTPUT
echo "Workspace has enough free space, skipping disk resize"
fi
- name: Maximize build space
# Resize and combine disks as LVM to maximize space for builds, if below the minimum free space
if: steps.check-disk.outputs.needs_resize == 'true'
uses: easimon/maximize-build-space@fc881a613ad2a34aca9c9624518214ebc21dfc0c # v10
with:
root-reserve-mb: 8000
swap-size-mb: 200
remove-dotnet: true
remove-haskell: true
remove-codeql: true
remove-docker-images: true
- 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
[[ "${{ inputs.type }}" == "profile" ]] && git lfs pull --include "*.ico,*.bmp" || git lfs pull
- name: Setup 3p, user, and build folders
run: |
mkdir -p .o3de build 3rdParty && ln -sf "$(pwd)/.o3de" ~/.o3de
- name: Setup ccache
uses: chocobo1/setup-ccache-action@37c3347f8a7738e82aab7a06f276f7a12e3008fb # v1.5.3
continue-on-error: true
if: always()
with:
prepend_symlinks_to_path: false
store_cache: false
restore_cache: false
ccache_options: |
cache_dir=${{ github.workspace }}/.ccache
hash_dir=false
max_size=10G
- name: Check for rerun
id: check-rerun
run: |
# GitHub sets GITHUB_RUN_ATTEMPT to track reruns
if [ "$GITHUB_RUN_ATTEMPT" -gt 1 ]; then
echo "is_rerun=true" >> $GITHUB_OUTPUT
echo "This is rerun attempt #$GITHUB_RUN_ATTEMPT"
else
echo "is_rerun=false" >> $GITHUB_OUTPUT
echo "This is the first run attempt"
fi
- 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" >> $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
id: restore-artifact-cache
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
continue-on-error: true
with:
name: O3DE-${{ inputs.platform }}-${{ inputs.config }}-build
github-token: ${{ secrets.GITHUB_TOKEN }}
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' }}
run: |
if [ -f ${{ github.workspace }}/cache.tar ]; then
tar -xvpf ${{ github.workspace }}/cache.tar --ignore-failed-read
rm ${{ github.workspace }}/cache.tar
ccache --zero-stats --cleanup
fi
- name: Setup cmake
# Pin the version of cmake
if: ${{ inputs.cmake_version }}
uses: lukka/get-cmake@f176ccd3f28bda569c43aae4894f06b2435a3375 # v4.2.3
with:
cmakeVersion: "${{ inputs.cmake_version }}"
- name: Install specific clang version
if: ${{ inputs.compiler == 'clang' && inputs.clang_version }}
run: |
sudo apt-get update -qq
sudo apt-get install -y clang-${{ inputs.clang_version }} lld-${{ inputs.clang_version }}
echo "CC=$(which clang-${{ inputs.clang_version }})" >> $GITHUB_ENV
echo "CXX=$(which clang++-${{ inputs.clang_version }})" >> $GITHUB_ENV
- name: Configure environment
# Install dependencies. The desktop packages are for tests and assetprocessor
continue-on-error: true
run: |
echo "Installing dependencies"
pushd ./scripts/build/build_node/Platform/Linux
sudo ./install-ubuntu.sh
popd
echo "Getting python..."
./python/get_python.sh
echo "Installing additional python dependencies..."
./python/pip.sh install tempfile2 PyGithub
# If desktop is true, install desktop and x11 packages, otherwise install base packages
[[ "${{ inputs.desktop }}" == "true" ]] && \
sudo apt-get install -qq ubuntu-desktop libreoffice- thunderbird- xorg mesa-utils vulkan-tools libevdev-dev libevdev2 -y || \
sudo apt-get install -qq libevdev-dev libevdev2 -y
sudo apt -y autoremove --purge
sudo apt -y autoclean
sudo apt clean
df -h
- name: Build ${{ inputs.type }}
# Builds with presets in ../scripts/build/Platform/Linux/build_config.json
timeout-minutes: 330
env:
CMAKE_C_COMPILER_LAUNCHER: ccache
CMAKE_CXX_COMPILER_LAUNCHER: ccache
LY_3RDPARTY_PATH: ${{ github.workspace }}/3rdParty
LY_PACKAGE_SERVER_URLS: "https://d1gg6ket0m44ly.cloudfront.net;https://d3t6xeg4fgfoum.cloudfront.net"
run: |
export EXTRA_CMAKE_OPTIONS="-DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX"
export DISPLAY=:0
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
if [ "${{ inputs.desktop }}" == "true" ]; then
Xvfb :0 -screen 0 1400x1050x16 & # Start X virtual framebuffer for tests
fi
python/python.sh -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
run: |
tar --format=posix -cvpf ${{ github.workspace }}/cache.tar --ignore-failed-read \
.ccache \
.o3de/python/downloaded_packages \
3rdParty/downloaded_packages \
AutomatedTesting/Cache
- 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: |
${{ github.workspace }}/cache.tar