Skip to content

Commit

Permalink
Add the commit SHA tag during building of precompiled image
Browse files Browse the repository at this point in the history
Signed-off-by: shiva kumar <shivaku@nvidia.com>
  • Loading branch information
shivakunv committed Feb 4, 2025
1 parent da308fd commit aaefa63
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 22 deletions.
39 changes: 27 additions & 12 deletions .github/workflows/precompiled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@
# Run this workflow on a schedule
name: Precompiled images

# on:
# schedule:
# - cron: '00 09 * * *'

on:
schedule:
- cron: '00 09 * * *'
pull_request:
types:
- opened
- synchronize
branches:
- tagcommittshaimage
push:
branches:
- tagcommittshaimage


jobs:
set-driver-version-matrix:
Expand All @@ -37,17 +49,19 @@ jobs:
id: extract_driver_branch
run: |
# get driver_branch
DRIVER_BRANCH=("535" "550")
DRIVER_BRANCH=("535")
driver_branch_json=$(printf '%s\n' "${DRIVER_BRANCH[@]}" | jq -R . | jq -cs .)
echo "driver_branch=$driver_branch_json" >> $GITHUB_OUTPUT
# get kernel flavors
KERNEL_FLAVORS=("aws" "azure" "generic" "nvidia" "oracle")
# KERNEL_FLAVORS=("aws" "azure" "generic" "nvidia" "oracle")
KERNEL_FLAVORS=("generic")
kernel_flavors_json=$(printf '%s\n' "${KERNEL_FLAVORS[@]}" | jq -R . | jq -cs .)
echo "kernel_flavors=$kernel_flavors_json" >> $GITHUB_OUTPUT
# get ubuntu distributions
DIST=("ubuntu22.04" "ubuntu24.04")
# DIST=("ubuntu22.04" "ubuntu24.04")
DIST=("ubuntu22.04")
dist_json=$(printf '%s\n' "${DIST[@]}" | jq -R . | jq -cs .)
echo "dist=$dist_json" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -133,17 +147,17 @@ jobs:
run: |
source kernel_version.txt
tar -cvf kernel-version-${{ matrix.driver_branch }}-${KERNEL_VERSION}-${DIST}.tar kernel_version.txt
docker save "${PRIVATE_REGISTRY}/nvidia/driver:${{ matrix.driver_branch }}-${KERNEL_VERSION}-${DIST}" \
-o ./driver-images-${{ matrix.driver_branch }}-${KERNEL_VERSION}-${DIST}.tar
docker save "${PRIVATE_REGISTRY}/nvidia/driver:${COMMIT_SHORT_SHA:+$COMMIT_SHORT_SHA-}${{ matrix.driver_branch }}-${KERNEL_VERSION}-${COMMIT_SHORT_SHA:+signed_}$DIST" \
-o ./driver-images-${COMMIT_SHORT_SHA:+$COMMIT_SHORT_SHA-}${{ matrix.driver_branch }}-${KERNEL_VERSION}-${COMMIT_SHORT_SHA:+signed_}$DIST.tar
# set env for artifacts upload
echo "KERNEL_VERSION=$KERNEL_VERSION" >> $GITHUB_ENV
echo "DIST=$DIST" >> $GITHUB_ENV
- name: Upload build image as an artifact
uses: actions/upload-artifact@v4
with:
name: driver-images-${{ matrix.driver_branch }}-${{ env.KERNEL_VERSION }}-${{ env.DIST }}
path: ./driver-images-${{ matrix.driver_branch }}-${{ env.KERNEL_VERSION }}-${{ env.DIST }}.tar
name: driver-images-${{ env.COMMIT_SHORT_SHA && format('{0}-', env.COMMIT_SHORT_SHA) }}${{ matrix.driver_branch }}-${{ env.KERNEL_VERSION }}-${{ env.COMMIT_SHORT_SHA && format('signed_{0}', env.DIST) || env.DIST }}
path: ./driver-images-${{ env.COMMIT_SHORT_SHA && format('{0}-', env.COMMIT_SHORT_SHA) }}${{ matrix.driver_branch }}-${{ env.KERNEL_VERSION }}-${{ env.COMMIT_SHORT_SHA && format('signed_{0}', env.DIST) || env.DIST }}.tar
retention-days: 1

- name: Upload kernel version as an artifact
Expand Down Expand Up @@ -362,14 +376,14 @@ jobs:
fi
for DRIVER_VERSION in "${DRIVER_BRANCHES[@]}"; do
echo "Running e2e for DRIVER_VERSION=$DRIVER_VERSION"
image="driver-images-${DRIVER_VERSION}-${KERNEL_VERSION}-${DIST}"
image="driver-images-${{ env.COMMIT_SHORT_SHA && format('{0}-', env.COMMIT_SHORT_SHA) }}${DRIVER_VERSION}-${KERNEL_VERSION}-${{ env.COMMIT_SHORT_SHA && format('signed_{0}', env.DIST) || env.DIST }}"
echo "Downloading $image in tests directory"
gh run download --name $image --dir ./tests/
status=0
TEST_CASE_ARGS="${GPU_OPERATOR_OPTIONS} --set driver.version=${DRIVER_VERSION}"
TEST_CASE_ARGS="${GPU_OPERATOR_OPTIONS} --set driver.version=${{ env.COMMIT_SHORT_SHA && format('{0}-', env.COMMIT_SHORT_SHA) }}${DRIVER_VERSION}"
# add escape character for space
TEST_CASE_ARGS=$(printf '%q ' "$TEST_CASE_ARGS")
IMAGE_PATH="./tests/driver-images-${DRIVER_VERSION}-${KERNEL_VERSION}-${DIST}.tar"
IMAGE_PATH="./tests/driver-images-${{ env.COMMIT_SHORT_SHA && format('{0}-', env.COMMIT_SHORT_SHA) }}${DRIVER_VERSION}-${KERNEL_VERSION}-${{ env.COMMIT_SHORT_SHA && format('signed_{0}', env.DIST) || env.DIST }}.tar"
./tests/ci-run-e2e.sh "${TEST_CASE}" "${TEST_CASE_ARGS}" ${IMAGE_PATH} || status=$?
if [ $status -eq 1 ]; then
echo "e2e validation failed for driver version $DRIVER_VERSION with status $status"
Expand All @@ -389,6 +403,7 @@ jobs:
retention-days: 15

publish-precompiled-image:
if: "!github.event.COMMIT_SHORT_SHA"
runs-on: linux-amd64-cpu4
needs:
- set-driver-version-matrix
Expand Down
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ pull-signed_ubuntu20.04%: DRIVER_TAG = $(DRIVER_BRANCH)

pull-signed_ubuntu22.04%: DIST = ubuntu22.04
pull-signed_ubuntu22.04%: DRIVER_TAG = $(DRIVER_BRANCH)
pull-signed_ubuntu22.04%: IMAGE_TAG = $(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)
pull-signed_ubuntu22.04%: IMAGE_TAG := $(if $(VERSION),$(VERSION)-)$(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)

pull-signed_ubuntu24.04%: DIST = ubuntu24.04
pull-signed_ubuntu24.04%: DRIVER_TAG = $(DRIVER_BRANCH)
pull-signed_ubuntu24.04%: IMAGE_TAG = $(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)
pull-signed_ubuntu24.04%: IMAGE_TAG := $(if $(VERSION),$(VERSION)-)$(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)

PLATFORM ?= linux/amd64
$(DRIVER_PULL_TARGETS): pull-%:
Expand All @@ -111,11 +111,11 @@ archive-signed_ubuntu20.04%: DRIVER_TAG = $(DRIVER_BRANCH)

archive-signed_ubuntu22.04%: DIST = ubuntu22.04
archive-signed_ubuntu22.04%: DRIVER_TAG = $(DRIVER_BRANCH)
archive-signed_ubuntu22.04%: IMAGE_TAG = $(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)
archive-signed_ubuntu22.04%: IMAGE_TAG := $(if $(VERSION),$(VERSION)-)$(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)

archive-signed_ubuntu24.04%: DIST = ubuntu24.04
archive-signed_ubuntu24.04%: DRIVER_TAG = $(DRIVER_BRANCH)
archive-signed_ubuntu24.04%: IMAGE_TAG = $(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)
archive-signed_ubuntu24.04%: IMAGE_TAG := $(if $(VERSION),$(VERSION)-)$(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)

$(DRIVER_ARCHIVE_TARGETS): archive-%:
$(DOCKER) save "$(IMAGE)" -o "archive.tar"
Expand All @@ -135,13 +135,13 @@ push-signed_ubuntu20.04%: DRIVER_TAG = $(DRIVER_BRANCH)

push-signed_ubuntu22.04%: DIST = ubuntu22.04
push-signed_ubuntu22.04%: DRIVER_TAG = $(DRIVER_BRANCH)
push-signed_ubuntu22.04%: IMAGE_TAG = $(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)
push-signed_ubuntu22.04%: OUT_IMAGE_TAG = $(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)
push-signed_ubuntu22.04%: IMAGE_TAG := $(if $(VERSION),$(VERSION)-)$(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)
push-signed_ubuntu22.04%: OUT_IMAGE_TAG := $(if $(VERSION),$(VERSION)-)$(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)

push-signed_ubuntu24.04%: DIST = ubuntu24.04
push-signed_ubuntu24.04%: DRIVER_TAG = $(DRIVER_BRANCH)
push-signed_ubuntu24.04%: IMAGE_TAG = $(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)
push-signed_ubuntu24.04%: OUT_IMAGE_TAG = $(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)
push-signed_ubuntu24.04%: IMAGE_TAG := $(if $(VERSION),$(VERSION)-)$(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)
push-signed_ubuntu24.04%: OUT_IMAGE_TAG := $(if $(VERSION),$(VERSION)-)$(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)

# $(DRIVER_BUILD_TARGETS) is in the form of build-$(DIST)-$(DRIVER_VERSION)
# Parse the target to set the required variables.
Expand Down Expand Up @@ -186,14 +186,14 @@ build-signed_ubuntu20.04%: DRIVER_TAG = $(DRIVER_BRANCH)
build-signed_ubuntu22.04%: DIST = ubuntu22.04
build-signed_ubuntu22.04%: SUBDIR = ubuntu22.04/precompiled
build-signed_ubuntu22.04%: DRIVER_TAG = $(DRIVER_BRANCH)
build-signed_ubuntu22.04%: IMAGE_TAG = $(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)
build-signed_ubuntu22.04%: IMAGE_TAG := $(if $(VERSION),$(VERSION)-)$(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)
build-signed_ubuntu22.04%: DOCKER_BUILD_ARGS = --build-arg KERNEL_VERSION="$(KERNEL_VERSION)"

# ubuntu24.04 Precompiled Driver
build-signed_ubuntu24.04%: DIST = ubuntu24.04
build-signed_ubuntu24.04%: SUBDIR = ubuntu24.04/precompiled
build-signed_ubuntu24.04%: DRIVER_TAG = $(DRIVER_BRANCH)
build-signed_ubuntu24.04%: IMAGE_TAG = $(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)
build-signed_ubuntu24.04%: IMAGE_TAG := $(if $(VERSION),$(VERSION)-)$(DRIVER_BRANCH)-$(KERNEL_VERSION)-$(DIST)
build-signed_ubuntu24.04%: DOCKER_BUILD_ARGS = --build-arg KERNEL_VERSION="$(KERNEL_VERSION)"

# base is an image used to poll Canonical for the latest kernel version
Expand Down
6 changes: 6 additions & 0 deletions tests/scripts/findkernelversion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ if [[ $status -eq 0 ]]; then
else
export should_continue=true
fi

# always support e2e for dev env
if [[ -n "$COMMIT_SHORT_SHA" ]]; then
export should_continue=true
fi

0 comments on commit aaefa63

Please sign in to comment.