Skip to content

Commit dbdc813

Browse files
committed
test(e2e): fingerprint workload image tags without git
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 386d638 commit dbdc813

2 files changed

Lines changed: 21 additions & 22 deletions

File tree

e2e/gpu/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ The build task uses `tasks/scripts/container-engine.sh`. Set
6161
`CONTAINER_ENGINE=docker` or `CONTAINER_ENGINE=podman` to choose an engine
6262
explicitly. When unset, the helper uses its existing auto-detection behavior.
6363

64-
Local tags use the current commit short SHA plus a short fingerprint of the
65-
external build inputs. Dirty local trees append `-dirty`. Set
66-
`OPENSHELL_GPU_WORKLOAD_IMAGE_TAG=<tag>` to override the tag.
64+
Local tags use a short SHA-256 fingerprint of the selected workload contexts
65+
and external build inputs. Set `OPENSHELL_GPU_WORKLOAD_IMAGE_TAG=<tag>` to
66+
override the tag.
6767

6868
The task writes the latest build refs to:
6969

tasks/scripts/e2e-gpu-build-images.sh

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,29 @@ image_expectation() {
8383

8484
workload_input_fingerprint() {
8585
local -a names=("$@")
86+
local digest
87+
local file
88+
local name
89+
local rel
8690

8791
{
92+
printf 'schema=openshell-gpu-workload-input-v1\n'
8893
printf 'OPENSHELL_SANDBOX_BASE_IMAGE=%s\n' "${BASE_IMAGE}"
8994
if contains_image cuda-basic "${names[@]}"; then
9095
printf 'CUDA_BUILD_IMAGE=%s\n' "${CUDA_BUILD_IMAGE}"
9196
printf 'CUDA_SAMPLES_REPO=%s\n' "${CUDA_SAMPLES_REPO}"
9297
printf 'CUDA_SAMPLES_REF=%s\n' "${CUDA_SAMPLES_REF}"
9398
fi
94-
} | git -C "${ROOT}" hash-object --stdin | cut -c1-8
99+
for name in "${names[@]}"; do
100+
printf 'WORKLOAD=%s\n' "${name}"
101+
while IFS= read -r -d '' file; do
102+
rel="${file#"${ROOT}/"}"
103+
digest="$(sha256sum "${file}" | cut -d ' ' -f 1)"
104+
printf 'FILE=%s\n' "${rel}"
105+
printf 'SHA256=%s\n' "${digest}"
106+
done < <(find "${IMAGES_ROOT}/${name}" -type f -print0 | sort -z)
107+
done
108+
} | sha256sum | cut -c1-12
95109
}
96110

97111
mapfile -t available < <(available_image_dirs)
@@ -122,28 +136,18 @@ if [[ ${#selected[@]} -eq 0 ]]; then
122136
exit 1
123137
fi
124138

125-
source_sha="$(git -C "${ROOT}" rev-parse HEAD)"
126-
source_short_sha="$(git -C "${ROOT}" rev-parse --short HEAD)"
127-
source_dirty=false
128-
if [[ -n "$(git -C "${ROOT}" status --short)" ]]; then
129-
source_dirty=true
130-
fi
139+
input_fingerprint="$(workload_input_fingerprint "${selected[@]}")"
131140

132141
if [[ -n "${OPENSHELL_GPU_WORKLOAD_IMAGE_TAG:-}" ]]; then
133142
image_tag="${OPENSHELL_GPU_WORKLOAD_IMAGE_TAG}"
134143
else
135-
input_fingerprint="$(workload_input_fingerprint "${selected[@]}")"
136-
image_tag="${source_short_sha}-${input_fingerprint}"
137-
if [[ "${source_dirty}" == "true" ]]; then
138-
image_tag="${image_tag}-dirty"
139-
fi
144+
image_tag="${input_fingerprint}"
140145
fi
141-
input_fingerprint="$(workload_input_fingerprint "${selected[@]}")"
142146

143147
declare -A image_refs=()
144148

145149
echo "Building GPU workload images with ${CONTAINER_ENGINE}"
146-
echo "Source: ${source_short_sha} (dirty: ${source_dirty})"
150+
echo "Fingerprint: ${input_fingerprint}"
147151
echo "Tag: ${image_tag}"
148152

149153
for name in "${selected[@]}"; do
@@ -158,7 +162,6 @@ for name in "${selected[@]}"; do
158162
--label "com.nvidia.openshell.gpu-workload.source=${name}"
159163
--label "com.nvidia.openshell.gpu-workload.base-image=${BASE_IMAGE}"
160164
--label "com.nvidia.openshell.gpu-workload.input-fingerprint=${input_fingerprint}"
161-
--label "org.opencontainers.image.revision=${source_sha}"
162165
)
163166
if [[ "${name}" == "cuda-basic" ]]; then
164167
build_args+=(
@@ -194,8 +197,6 @@ manifest_path="${BUILD_DIR}/workloads.yaml"
194197
echo "# Source this file to use the most recently built GPU workload images."
195198
write_env_var OPENSHELL_GPU_WORKLOAD_IMAGE_TAG "${image_tag}"
196199
write_env_var OPENSHELL_GPU_WORKLOAD_IMAGE_SOURCE_PATH "${IMAGES_ROOT}"
197-
write_env_var OPENSHELL_GPU_WORKLOAD_IMAGE_SOURCE_SHA "${source_sha}"
198-
write_env_var OPENSHELL_GPU_WORKLOAD_IMAGE_SOURCE_DIRTY "${source_dirty}"
199200
write_env_var OPENSHELL_GPU_WORKLOAD_IMAGE_INPUT_FINGERPRINT "${input_fingerprint}"
200201
write_env_var OPENSHELL_SANDBOX_BASE_IMAGE "${BASE_IMAGE}"
201202
write_env_var CUDA_BUILD_IMAGE "${CUDA_BUILD_IMAGE}"
@@ -213,8 +214,6 @@ manifest_path="${BUILD_DIR}/workloads.yaml"
213214
echo "generated_by: $(yaml_quote "mise run e2e:workloads:build")"
214215
echo "source:"
215216
echo " path: $(yaml_quote "${IMAGES_ROOT}")"
216-
echo " revision: $(yaml_quote "${source_sha}")"
217-
echo " dirty: ${source_dirty}"
218217
echo " input_fingerprint: $(yaml_quote "${input_fingerprint}")"
219218
echo " container_engine: $(yaml_quote "${CONTAINER_ENGINE}")"
220219
echo " inputs:"

0 commit comments

Comments
 (0)