Skip to content

Commit

Permalink
ci: added template
Browse files Browse the repository at this point in the history
Signed-off-by: Iaroslav Sydoruk <[email protected]>
  • Loading branch information
isdrk committed Dec 20, 2024
1 parent c3222ec commit 06c2a05
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 49 deletions.
25 changes: 25 additions & 0 deletions .ci/ci_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Important: all variables must start with CI_ENV_
# otherwise it will not be replaced!

export CI_ENV_MOFED_VER="24.07-0.6.1.0"
export CI_ENV_REGISTRY_AUTH_FILE="/mnt/secret_podman/config_podman.json"
export CI_ENV_GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no"
export CI_ENV_STORAGE_DRIVER="overlay"

export CI_ENV_NVCR_REGISTRY_HOST="nvcr.io"
export CI_ENV_NVCR_REGISTRY_PATH="nvstaging/doca"

export CI_ENV_HARBOR_REGISTRY_HOST="nbu-harbor.gtm.nvidia.com"
export CI_ENV_HARBOR_REGISTRY_PATH="swx-storage/doca_nvmf_target_offload"

export CI_ENV_ARTIFACT_PROPERTIES="/mnt/pvc/doca-sta-artifact.properties"

export CI_ENV_DOCA_BUILDER_IMAGE="nvcr.io/nvstaging/doca/doca"
export CI_ENV_DOCA_RUNTIME_TAG="2.10.0045-full-rt-ubuntu22.04-arm64"
export CI_ENV_DOCA_BUILDER_TAG="2.10.0045-devel-ubuntu22.04-arm64"

# Change this revision number always when you make any
# changes that affect components in CI builder images.
# CI builder images use it as docker tag.
# Format=<YYMMDD>-<ID>
export CI_ENV_CI_REV="241220-1"
57 changes: 57 additions & 0 deletions .ci/cidemo-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash -eE

SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")

info() {
echo "[$0] [INFO]: $1"
}

error() {
echo "[$0] [ERROR]: $1"
}

# conf_file checks
if [ -z "${conf_file}" ]; then
error "ENV variable 'conf_file' is not defined!"
exit 1
fi

if [ ! -e "${conf_file}.in" ]; then
error "Template ${conf_file}.in isn't found!"
exit 1
fi

# CI env path checks
if [ -z "${CI_ENV_PATH}" ]; then
info "CI_ENV_PATH isn't defined. Using default: ${SCRIPTPATH}/ci_env.sh"
CI_ENV_PATH="$SCRIPTPATH/ci_env.sh"
fi

if [ ! -e "$CI_ENV_PATH" ]; then
error "CI env file ${CI_ENV_PATH} doesn't exist!"
exit 1
fi

info "CI env file: $CI_ENV_PATH"
cat $CI_ENV_PATH

CI_ENV_VARS=$(grep '^export CI_ENV_' $CI_ENV_PATH | sed 's/^export \(CI_ENV_[^=]*\)=.*$/\$\1/' | tr '\n' ' ')

if [ -z "$CI_ENV_VARS" ]; then
error "CI Variables not found in the $CI_ENV_PATH!"
exit 1
fi

source $CI_ENV_PATH

if ! type -p envsubst; then
info "envsubst isn't found. Trying to install it..."
apt update
apt install -y gettext-base
fi

envsubst "$CI_ENV_VARS" < ${conf_file}.in > ${conf_file}

info "Created ${conf_file}:"
cat "${conf_file}"
6 changes: 3 additions & 3 deletions .ci/job_matrix.yaml → .ci/job_matrix.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ kubernetes:
privileged: true

env:
MOFED_VER: 24.07-0.6.1.0
REGISTRY_AUTH_FILE: '/mnt/secret_podman/config_podman.json'
GIT_SSH_COMMAND: 'ssh -o StrictHostKeyChecking=no'
MOFED_VER: '${CI_ENV_MOFED_VER}'
REGISTRY_AUTH_FILE: '${CI_ENV_REGISTRY_AUTH_FILE}'
GIT_SSH_COMMAND: '${CI_ENV_GIT_SSH_COMMAND}'

secret_volumes:
- {secretName: 'mellanox-debs-keyring', mountPath: '/mnt/secret'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ credentials:
timeout_minutes: 120

env:
#DOCKER_REGISTRY_HOST: "nbu-harbor.gtm.nvidia.com"
#DOCKER_REGISTRY_PATH: "swx-storage/doca_nvmf_target_offload"
DOCKER_REGISTRY_HOST: "nvcr.io"
DOCKER_REGISTRY_PATH: "nvstaging/doca"
DOCA_IMAGE: "nvcr.io/nvstaging/doca/doca"
DOCA_BUILDER_TAG: "2.9.1006-devel-ubuntu22.04-arm64"
DOCA_RUNTIME_TAG: "2.9.1006-full-rt-ubuntu22.04-arm64"
artifact_properties: '/mnt/pvc/doca-sta-artifact.properties'
REGISTRY_AUTH_FILE: '/mnt/secret_podman/config_podman.json'
GIT_SSH_COMMAND: 'ssh -o StrictHostKeyChecking=no'
STORAGE_DRIVER: 'overlay'
DOCKER_REGISTRY_HOST: '${CI_ENV_NVCR_REGISTRY_HOST}'
DOCKER_REGISTRY_PATH: '${CI_ENV_NVCR_REGISTRY_PATH}'
DOCA_IMAGE: '${CI_ENV_DOCA_BUILDER_IMAGE}'
DOCA_BUILDER_TAG: '${CI_ENV_DOCA_BUILDER_TAG}'
DOCA_RUNTIME_TAG: '${CI_ENV_DOCA_RUNTIME_TAG}'
artifact_properties: '${CI_ENV_ARTIFACT_PROPERTIES}'
REGISTRY_AUTH_FILE: '${CI_ENV_REGISTRY_AUTH_FILE}'
GIT_SSH_COMMAND: '${CI_ENV_GIT_SSH_COMMAND}'
STORAGE_DRIVER: '${CI_ENV_STORAGE_DRIVER}'

failFast: false
kubernetes:
Expand Down Expand Up @@ -64,7 +62,7 @@ secret_volumes:

runs_on_dockers:
- {
file: '.ci/Dockerfile.doca', name: 'doca_ci', arch: 'aarch64', tag: "241126-1",
file: '.ci/Dockerfile.doca', name: 'doca_ci', arch: 'aarch64', tag: "${CI_ENV_CI_REV}",
build_args: '--build-arg DOCA_IMAGE_TAG=$DOCA_BUILDER_TAG --pull --no-cache'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ credentials:
timeout_minutes: 120

env:
DOCKER_REGISTRY_HOST: "nbu-harbor.gtm.nvidia.com"
DOCKER_REGISTRY_PATH: "swx-storage/doca_nvmf_target_offload"
DOCA_IMAGE: "nvcr.io/nvstaging/doca/doca"
DOCA_BUILDER_TAG: "2.9.1006-devel-ubuntu22.04-arm64"
DOCA_RUNTIME_TAG: "2.9.1006-full-rt-ubuntu22.04-arm64"
artifact_properties: '/mnt/pvc/doca-sta-artifact.properties'
REGISTRY_AUTH_FILE: '/mnt/secret_podman/config_podman.json'
GIT_SSH_COMMAND: 'ssh -o StrictHostKeyChecking=no'
STORAGE_DRIVER: 'overlay'
DOCKER_REGISTRY_HOST: '${CI_ENV_HARBOR_REGISTRY_HOST}'
DOCKER_REGISTRY_PATH: '${CI_ENV_HARBOR_REGISTRY_PATH}'
DOCA_IMAGE: '${CI_ENV_DOCA_BUILDER_IMAGE}'
DOCA_BUILDER_TAG: '${CI_ENV_DOCA_BUILDER_TAG}'
DOCA_RUNTIME_TAG: '${CI_ENV_DOCA_RUNTIME_TAG}'
artifact_properties: '${CI_ENV_ARTIFACT_PROPERTIES}'
REGISTRY_AUTH_FILE: '${CI_ENV_REGISTRY_AUTH_FILE}'
GIT_SSH_COMMAND: '${CI_ENV_GIT_SSH_COMMAND}'
STORAGE_DRIVER: '${CI_ENV_STORAGE_DRIVER}'

failFast: false
kubernetes:
Expand Down Expand Up @@ -62,7 +62,7 @@ secret_volumes:

runs_on_dockers:
- {
file: '.ci/Dockerfile.doca', name: 'doca_ci', arch: 'aarch64', tag: "241126-1",
file: '.ci/Dockerfile.doca', name: 'doca_ci', arch: 'aarch64', tag: "${CI_ENV_CI_REV}",
build_args: '--build-arg DOCA_IMAGE_TAG=$DOCA_BUILDER_TAG --pull --no-cache'
}

Expand All @@ -79,7 +79,7 @@ steps:
run: |
if [[ "$do_container" == "true" ]]; then
./container/build_image.sh \
--build-type=debugoptimized \
--build-type=debug \
--doca-image=$DOCA_IMAGE \
--doca-builder-tag=$DOCA_BUILDER_TAG \
--doca-runtime-tag=$DOCA_RUNTIME_TAG \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ credentials:
timeout_minutes: 120

env:
DOCKER_REGISTRY_HOST: "nbu-harbor.gtm.nvidia.com"
DOCKER_REGISTRY_PATH: "swx-storage/doca_nvmf_target_offload"
DOCA_IMAGE: "nvcr.io/nvstaging/doca/doca"
DOCA_BUILDER_TAG: "2.9.1006-devel-ubuntu22.04-arm64"
DOCA_RUNTIME_TAG: "2.9.1006-full-rt-ubuntu22.04-arm64"
artifact_properties: '/mnt/pvc/doca-sta-artifact.properties'
REGISTRY_AUTH_FILE: '/mnt/secret_podman/config_podman.json'
GIT_SSH_COMMAND: 'ssh -o StrictHostKeyChecking=no'
STORAGE_DRIVER: 'overlay'
DOCKER_REGISTRY_HOST: '${CI_ENV_HARBOR_REGISTRY_HOST}'
DOCKER_REGISTRY_PATH: '${CI_ENV_HARBOR_REGISTRY_PATH}'
DOCA_IMAGE: '${CI_ENV_DOCA_BUILDER_IMAGE}'
DOCA_BUILDER_TAG: '${CI_ENV_DOCA_BUILDER_TAG}'
DOCA_RUNTIME_TAG: '${CI_ENV_DOCA_RUNTIME_TAG}'
artifact_properties: '${CI_ENV_ARTIFACT_PROPERTIES}'
REGISTRY_AUTH_FILE: '${CI_ENV_REGISTRY_AUTH_FILE}'
GIT_SSH_COMMAND: '${CI_ENV_GIT_SSH_COMMAND}'
STORAGE_DRIVER: '${CI_ENV_STORAGE_DRIVER}'

failFast: false
kubernetes:
Expand Down Expand Up @@ -62,7 +62,7 @@ secret_volumes:

runs_on_dockers:
- {
file: '.ci/Dockerfile.doca', name: 'doca_ci', arch: 'aarch64', tag: "241126-1",
file: '.ci/Dockerfile.doca', name: 'doca_ci', arch: 'aarch64', tag: "${CI_ENV_CI_REV}",
build_args: '--build-arg DOCA_IMAGE_TAG=$DOCA_BUILDER_TAG --pull --no-cache'
}

Expand All @@ -77,12 +77,12 @@ steps:
credentialsId: '3s-bf3-dpa-prod-role'
archiveArtifacts: 'artifact.properties'
run: |
./container/build_image.sh \
--build-type=debugoptimized \
--doca-image=$DOCA_IMAGE \
--doca-builder-tag=$DOCA_BUILDER_TAG \
--doca-runtime-tag=$DOCA_RUNTIME_TAG \
--docker-registry-host=$DOCKER_REGISTRY_HOST \
--docker-registry-path=$DOCKER_REGISTRY_PATH \
--docker-image-name=doca_nvmf_target_offload \
--sign --push
./container/build_image.sh \
--build-type=debug \
--doca-image=$DOCA_IMAGE \
--doca-builder-tag=$DOCA_BUILDER_TAG \
--doca-runtime-tag=$DOCA_RUNTIME_TAG \
--docker-registry-host=$DOCKER_REGISTRY_HOST \
--docker-registry-path=$DOCKER_REGISTRY_PATH \
--docker-image-name=doca_nvmf_target_offload \
--sign --push
4 changes: 2 additions & 2 deletions container/Dockerfile.nvmf_target_offload
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ RUN apt update && \

# Build and install DOCA STA
RUN set -x; \
DOCA_VERSION=$(echo $DOCA_BUILDER_TAG | grep -o "[0-9]\.[0-9]\.[0-9]*") && \
wget https://urm.nvidia.com/artifactory/sw-nbu-doca-local/doca-sdk/$(echo $DOCA_VERSION | grep -o "[0-9]\.[0-9]\.[0-9]")/DOCA_${DOCA_VERSION//./-}-1/doca-sdk-sta-${DOCA_VERSION}.tar.gz && \
DOCA_VERSION=$(echo $DOCA_BUILDER_TAG | grep -o "[0-9]\+\.[0-9]\+\.[0-9]*") && \
wget https://urm.nvidia.com/artifactory/sw-nbu-doca-local/doca-sdk/$(echo $DOCA_VERSION | grep -o "[0-9]\+\.[0-9]\+\.[0-9]")/DOCA_${DOCA_VERSION//./-}-1/doca-sdk-sta-${DOCA_VERSION}.tar.gz && \
tar xzvf doca-sdk-sta-${DOCA_VERSION}.tar.gz --no-same-owner && \
cd doca-sdk-sta-${DOCA_VERSION} && \
. ./devtools/public/set_env_variables.sh --deb && \
Expand Down
4 changes: 2 additions & 2 deletions container/build_image.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -eE
#!/bin/bash -eEx

# SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LicenseRef-NvidiaProprietary
Expand Down Expand Up @@ -132,7 +132,7 @@ fi

DOCKER_BUILD_ARGS+=("--build-arg NVMF_TARGET_OFFLOAD_BUILD_ARGS='${NVMF_TARGET_OFFLOAD_BUILD_ARGS[@]}'")

DOCA_VERSION=$(echo $DOCA_RUNTIME_TAG | grep -o "[0-9]\.[0-9]\.[0-9]")
DOCA_VERSION=$(echo $DOCA_RUNTIME_TAG | grep -o "[0-9]\+\.[0-9]\+\.[0-9]")
NVMF_TARGET_OFFLOAD_VER_MID=$(echo $NVMF_TARGET_OFFLOAD_VERSION | grep -o "[0-9]\.[0-9]\.[0-9]")

case "$DOCKER_REGISTRY_HOST" in
Expand Down

0 comments on commit 06c2a05

Please sign in to comment.