-
Notifications
You must be signed in to change notification settings - Fork 6
332 lines (332 loc) · 14.5 KB
/
build-ais.yml
File metadata and controls
332 lines (332 loc) · 14.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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
name: build_and_test
run-name: Build, Test, and Analyze AIS
env:
AIS_GHA_CMD_FILES_DOCKER_DIR: /root/github
AIS_INPUT_BUILD_ID: ${{ inputs.build_id }}
AIS_INPUT_CI_IMAGE: ${{ inputs.ci_image }}
AIS_INPUT_CXX_COMPILER: ${{ inputs.cxx_compiler }}
AIS_INPUT_JOB_DESIGNATOR: ${{ inputs.job_designator }}
AIS_INPUT_PLATFORM: ${{ inputs.platform }}
AIS_INPUT_UPLOAD_ARTIFACTS: ${{ inputs.upload_artifacts }}
AIS_MOUNT_PATH: /mnt/ais/ext4
AIS_PKG_MGR: >-
${{
inputs.platform == 'rocky' && 'dnf' ||
inputs.platform == 'suse' && 'zypper' ||
inputs.platform == 'ubuntu' && 'apt'
}}
AIS_PKG_TYPE: ${{ inputs.platform == 'ubuntu' && 'DEB' || 'RPM' }}
AIS_INPUT_ROCM_VERSION: ${{ inputs.rocm_version }}
# Code coverage report only vetted to work for amdclang++ on Ubuntu
AIS_USE_CODE_COVERAGE: ${{ inputs.cxx_compiler == 'amdclang++' && inputs.platform == 'ubuntu' }}
AIS_HIP_ARCHITECTURES: gfx950;gfx1201;gfx1200;gfx1101;gfx1100;gfx1030;gfx942;gfx90a;gfx908
on:
workflow_call:
inputs:
build_id:
default: 9999
description: "Number assigned by the build orchestrator."
required: false
type: number
ci_image:
required: true
type: string
cxx_compiler:
required: true
type: string
job_designator:
description: "Qualifies the type of job building hipFile."
required: false
type: string
platform:
required: true
type: string
rocm_version:
description: "Target ROCm MAJOR.MINOR.PATCH Version."
required: true
type: string
upload_artifacts:
default: false
description: "Upload binaries and the build tree as artifacts to GitHub."
type: boolean
outputs:
ais_hipfile_pkg_dev_filename:
description: "Filename for the hipFile development DEB/RPM package."
value: ${{ jobs.compile_on_AMD.outputs.ais_hipfile_pkg_dev_filename }}
ais_hipfile_pkg_filename:
description: "Filename for the hipFile runtime DEB/RPM package."
value: ${{ jobs.compile_on_AMD.outputs.ais_hipfile_pkg_filename }}
ais_hipfile_pkg_version:
description: "Version for the hipFile DEB/RPM packages."
value: ${{ jobs.compile_on_AMD.outputs.ais_hipfile_pkg_version }}
ci_image:
description: "Echo ci_image for downstream jobs to consume."
value: ${{ inputs.ci_image }}
permissions:
contents: read
packages: read
jobs:
compile_on_AMD:
name: compile_on_AMD (${{ inputs.cxx_compiler }})
outputs:
ais_hipfile_pkg_dev_filename: ${{ steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_DEV_FILENAME }}
ais_hipfile_pkg_filename: ${{ steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_FILENAME }}
ais_hipfile_pkg_version: ${{ steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_VERSION }}
runs-on: [ubuntu-24.04]
steps:
- name: Set early AIS CI environment variables
# ROCm Build Environment Args
# - JOB_DESIGNATOR
# - BUILD_ID
# - SLES_BUILD_ID_PREFIX (will be instead be set in SUSE based DOCKERFILE's)
# - CPACK_<TYPE>_PACKAGE_RELEASE (made up of the above)
# - ROCM_VERSION (set in DOCKERFILE)
# See: https://github.com/ROCm/ROCm/blob/8aa43d132f0d541eb5303dc532f5931cb80ad87a/tools/rocm-build/envsetup.sh#L25-L42
run: |
echo "AIS_PR_NUMBER=$(echo "${GITHUB_REF}" | sed 's|[^0-9]||g')" >> "${GITHUB_ENV}"
echo "AIS_GHA_CMD_FILES_DIR=${GITHUB_ENV%/*}" >> "${GITHUB_ENV}"
echo "AIS_SAFE_COMPILER_NAME=$(echo ${AIS_INPUT_CXX_COMPILER} | sed 's|[\+]|plus|g')" >> "${GITHUB_ENV}"
- name: Set AIS CI container name
# We should expect that there are multiple instances of this job with different cxx_compilers.
# On non-pull_request triggering workflows, AIS_PR_NUMBER may be empty.
run: |
echo "AIS_CONTAINER_NAME=${AIS_PR_NUMBER:=${GITHUB_RUN_ID}}_${GITHUB_JOB}_${AIS_INPUT_PLATFORM}_${AIS_INPUT_ROCM_VERSION}_${AIS_SAFE_COMPILER_NAME}" >> "${GITHUB_ENV}"
- name: Fetching code repository...
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
with:
path: hipFile
- name: Authenticating to GitHub Container Registry
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 #v4.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Detach the container and run separate commands to it.
# Thus we can make separate explicit steps in the Github CI
# as if we were able to parameterize the container image in the first place.
- name: Starting Docker Container
run: |
docker run \
-dt \
--rm \
--pull always \
-v ${GITHUB_WORKSPACE}:/mnt/ais:ro \
-v "${AIS_GHA_CMD_FILES_DIR}:${AIS_GHA_CMD_FILES_DOCKER_DIR}" \
-v "${AIS_MOUNT_PATH}:/mnt/ais-fs" \
--name "${AIS_CONTAINER_NAME}" \
"${AIS_INPUT_CI_IMAGE}"
- name: Make copy of the code repository and create build directories
# Single quotes necessary to ensure string/command substitutions happen
# in the container and not on the host.
run: |
docker exec \
-t \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
cp -R /mnt/ais /ais
mkdir /ais/hipFile/build
'
- name: Generate build files for hipFile targeting the AMD platform (${{ inputs.cxx_compiler }})
# ${SLES_BUILD_ID} is mentioned for all platforms to match current ROCm build implementation.
run: |
docker exec \
-e "_AIS_INPUT_CXX_COMPILER=${AIS_INPUT_CXX_COMPILER}" \
-e "BUILD_ID=${AIS_INPUT_BUILD_ID}" \
-e "JOB_DESIGNATOR=${AIS_INPUT_JOB_DESIGNATOR}" \
-t \
-w /ais/hipFile/build \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
export CPACK_DEBIAN_PACKAGE_RELEASE="${JOB_DESIGNATOR}${SLES_BUILD_ID_PREFIX}${BUILD_ID}~$(source /etc/os-release && echo ${VERSION_ID})"
export CPACK_RPM_PACKAGE_RELEASE="${JOB_DESIGNATOR}${SLES_BUILD_ID_PREFIX}${BUILD_ID}"
cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_COMPILER="${_AIS_INPUT_CXX_COMPILER}" \
-DCMAKE_CXX_FLAGS="-Werror" \
-DCMAKE_HIP_ARCHITECTURES="${{ env.AIS_HIP_ARCHITECTURES }}" \
-DCMAKE_HIP_PLATFORM=amd \
-DAIS_BUILD_DOCS=ON \
-DAIS_USE_CODE_COVERAGE=${{ env.AIS_USE_CODE_COVERAGE == 'true' && 'ON' || 'OFF' }} \
-DROCM_VERSION="${ROCM_VERSION}" \
-DAIS_CAPABLE_DIR=/mnt/ais-fs \
..
'
- name: Build hipFile for the AMD platform (${{ inputs.cxx_compiler }})
run: |
docker exec \
-t \
-w /ais/hipFile/build \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
cmake --build . --parallel
'
- name: Test hipFile for the AMD platform (${{ inputs.cxx_compiler }})
run: |
docker exec \
-t \
-w /ais/hipFile/build \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
ctest -V -L "unit" --parallel
'
- name: Generate coverage summary (${{ inputs.cxx_compiler }})
if: ${{ env.AIS_USE_CODE_COVERAGE == 'true' }}
run: |
docker exec \
-t \
-w /ais/hipFile/build \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
export PATH="/opt/rocm/llvm/bin:${PATH}"
../util/llvm-coverage.sh
printf "# Code Coverage\n"
printf "\`\`\`\n"
cat coverage-report.txt
printf "\`\`\`\n"
' >> ${GITHUB_STEP_SUMMARY}
- name: Create hipFile package
run: |
docker exec \
-e "_AIS_PKG_TYPE=${AIS_PKG_TYPE}" \
-t \
-w /ais/hipFile/build \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
cpack -G "${_AIS_PKG_TYPE}"
'
# CI is unable to peer into CMake to capture this data ahead of time.
# We should only produce a single package so we can use a glob pattern
# to complete the relative path to select the package.
# For now, hardcode the glob pattern to the default DEV release package name.
# (We will also hardcode arch as well.)
- name: Capture package metadata
id: pkg-metadata
run: |
docker exec \
-e "AIS_GITHUB_OUTPUT=${{ env.AIS_GHA_CMD_FILES_DOCKER_DIR }}/${GITHUB_OUTPUT##*/}" \
-t \
-w /ais/hipFile/build \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
shopt -s nullglob
AIS_HIPFILE_PKG_DEV_FILENAME="$(echo hipfile-de{v,vel}{-,_}[0-9]*.{deb,rpm})"
AIS_HIPFILE_PKG_FILENAME="$(echo hipfile{-,_}[0-9]*.{deb,rpm})"
echo "AIS_HIPFILE_PKG_DEV_FILENAME=${AIS_HIPFILE_PKG_DEV_FILENAME}" >> "${AIS_GITHUB_OUTPUT}"
echo "AIS_HIPFILE_PKG_FILENAME=${AIS_HIPFILE_PKG_FILENAME}" >> "${AIS_GITHUB_OUTPUT}"
echo "AIS_HIPFILE_PKG_VERSION=$(
${{
env.AIS_PKG_TYPE == 'DEB' &&
'dpkg-deb -f "${AIS_HIPFILE_PKG_FILENAME}" "Version"' ||
'rpm -qp --qf "%{VERSION}" "${AIS_HIPFILE_PKG_FILENAME}"'
}}
)" >> "${AIS_GITHUB_OUTPUT}"
'
# This information will be nice to have for debugging CPack configuration.
- name: Print package metadata for debugging.
run: |
docker exec \
-t \
-w /ais/hipFile/build \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
echo "Runtime Package:"
${{
format(
env.AIS_PKG_TYPE == 'DEB' &&
'dpkg-deb -I "{0}" && dpkg-deb -c "{0}"' ||
'rpm -qpil --requires "{0}"',
steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_FILENAME
)
}}
echo -e "\n\nDevelopment Package:"
${{
format(
env.AIS_PKG_TYPE == 'DEB' &&
'dpkg-deb -I "{0}" && dpkg-deb -c "{0}"' ||
'rpm -qpil --requires "{0}"',
steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_DEV_FILENAME
)
}}
'
- name: Validate Metadata stored correctly
run: |
echo "hipFile package dev filename: ${{ steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_DEV_FILENAME }}"
echo "hipFile package filename: ${{ steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_FILENAME }}"
echo "hipFile package version: ${{ steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_VERSION }}"
if [[ -z "${{ steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_VERSION }}" ]]; then exit 1; fi
- name: Test installing the hipFile package.
run: |
docker exec \
-t \
-w /ais/hipFile/build \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
${{
format(
env.AIS_PKG_MGR == 'apt' && 'apt install -y "./{0}" "./{1}"' ||
env.AIS_PKG_MGR == 'dnf' && 'dnf install -y --cacheonly "./{0}" "./{1}"' ||
env.AIS_PKG_MGR == 'zypper' && 'zypper --no-refresh install -y --allow-unsigned-rpm "./{0}" "./{1}"' ||
'echo "Unknown platform."; exit 1',
steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_DEV_FILENAME,
steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_FILENAME
)
}}
'
- name: Copy hipFile packages out of the container
if: ${{ inputs.upload_artifacts }}
run: |
docker cp \
"${AIS_CONTAINER_NAME}:/ais/hipFile/build/${{ steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_DEV_FILENAME }}" \
${GITHUB_WORKSPACE}
docker cp \
"${AIS_CONTAINER_NAME}:/ais/hipFile/build/${{ steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_FILENAME }}" \
${GITHUB_WORKSPACE}
- name: Upload development hipFile Package as an Artifact
if: ${{ inputs.upload_artifacts }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7.0.0
with:
name: ${{ steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_DEV_FILENAME }}
path: ${{ format('{0}/{1}', github.workspace, steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_DEV_FILENAME) }}
if-no-files-found: error
retention-days: 1
compression-level: 0
- name: Upload runtime hipFile Package as an Artifact
if: ${{ inputs.upload_artifacts }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7.0.0
with:
name: ${{ steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_FILENAME }}
path: ${{ format('{0}/{1}', github.workspace, steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_FILENAME) }}
if-no-files-found: error
retention-days: 1
compression-level: 0
# CTestTestfiles.cmake hardcodes the absolute path of the GTest executables
# in the build directory. CTest relies on this metadata for execution. It is not
# trivial to modify this metadata, otherwise an installable test package could be
# used. For now, reuse the build directory.
- name: Copy hipFile build directory out of the container
if: ${{ inputs.upload_artifacts }}
run: |
docker cp \
"${AIS_CONTAINER_NAME}:/ais/hipFile/build" \
${GITHUB_WORKSPACE}/hipfile-build-dir
- name: Upload runtime hipFile Package as an Artifact
if: ${{ inputs.upload_artifacts }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7.0.0
with:
name: hipfile-build-dir-${{ inputs.platform }}
path: ${{ github.workspace }}/hipfile-build-dir
if-no-files-found: error
retention-days: 1
- name: Clean CMake build directories
run: |
docker exec \
-t \
-w /ais/hipFile \
"${AIS_CONTAINER_NAME}" \
/bin/bash -c '
rm -rf build/*
'
- name: Cleanup & Stop the Docker container
if: ${{ always() }}
run: |
docker stop "${AIS_CONTAINER_NAME}"