Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 22 additions & 179 deletions .common-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,202 +13,45 @@
# limitations under the License.

default:
image: docker:stable
image: docker
services:
- name: docker:stable-dind
- name: docker:dind
command: ["--experimental"]

variables:
GIT_SUBMODULE_STRATEGY: recursive
BUILD_MULTI_ARCH_IMAGES: "true"

stages:
- image
- lint
- go-checks
- go-build
- unit-tests
- package-build
- image-build
- test
- pull
- scan
- aws_kube_setup
- integration_tests
- e2e_tests
- aws_kube_clean
- release
- sign

# Define the distribution targets
.dist-ubuntu22.04:
variables:
DIST: ubuntu22.04

.dist-ubi9:
variables:
DIST: ubi9

# Define the platform targets
.platform-amd64:
variables:
PLATFORM: linux/amd64

.platform-arm64:
variables:
PLATFORM: linux/arm64

# Define the sample targets
.sample-vectoradd:
variables:
SAMPLE: vectorAdd
LOWER_CASE_SAMPLE: vectoradd
PUSH_SAMPLE_ONLY_TAG: "false"

.sample-nbody:
variables:
SAMPLE: nbody
LOWER_CASE_SAMPLE: nbody
PUSH_SAMPLE_ONLY_TAG: "true"

.sample-device-query:
variables:
SAMPLE: deviceQuery
LOWER_CASE_SAMPLE: devicequery
PUSH_SAMPLE_ONLY_TAG: "true"

.sample-simple-multi-gpu:
variables:
SAMPLE: simpleMultiGPU
LOWER_CASE_SAMPLE: simplemultigpu
PUSH_SAMPLE_ONLY_TAG: "true"

# Define the sample targets
.sample-vulkan:
variables:
SAMPLE: vulkan
LOWER_CASE_SAMPLE: vulkan
PUSH_SAMPLE_ONLY_TAG: "true"

.sample-nvbandwidth:
variables:
SAMPLE: nvbandwidth
LOWER_CASE_SAMPLE: nvbandwidth
PUSH_SAMPLE_ONLY_TAG: "true"

# Make buildx available as a docker CLI plugin
.buildx-setup:
before_script:
- export BUILDX_VERSION=v0.6.3
- apk add --no-cache curl
- mkdir -p ~/.docker/cli-plugins
- curl -sSLo ~/.docker/cli-plugins/docker-buildx "https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-amd64"
- chmod a+x ~/.docker/cli-plugins/docker-buildx

- docker buildx create --use --platform=linux/amd64,linux/arm64

- '[[ -n "${SKIP_QEMU_SETUP}" ]] || docker run --rm --privileged multiarch/qemu-user-static --reset -p yes'
.pipeline-trigger-rules:
rules:
# We trigger the pipeline if started manually
- if: $CI_PIPELINE_SOURCE == "web"
# We trigger the pipeline on the main branch
- if: $CI_COMMIT_BRANCH == "main"
# We trigger the pipeline on the release- branches
- if: $CI_COMMIT_BRANCH =~ /^release-.*$/
# We trigger the pipeline on tags
- if: $CI_COMMIT_TAG && $CI_COMMIT_TAG != ""

workflow:
rules:
# We trigger the pipeline on a merge request
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# We then add all the regular triggers
- !reference [.pipeline-trigger-rules, rules]

# Download the regctl binary for use in the release steps
.regctl-setup:
before_script:
- export REGCTL_VERSION=v0.3.10
- export REGCTL_VERSION=v0.4.5
- apk add --no-cache curl
- mkdir -p bin
- curl -sSLo bin/regctl https://github.com/regclient/regclient/releases/download/${REGCTL_VERSION}/regctl-linux-amd64
- chmod a+x bin/regctl
- export PATH=$(pwd)/bin:${PATH}

# .release forms the base of the deployment jobs which push images to the CI registry.
# This is extended with the version to be deployed (e.g. the SHA or TAG) and the
# target os.
.release:
stage:
release
variables:
# Define the source image for the release
IMAGE_NAME: "${CI_REGISTRY_IMAGE}/cuda-samples"
VERSION: "${CI_COMMIT_SHORT_SHA}"
# OUT_IMAGE_VERSION is overridden for external releases
OUT_IMAGE_VERSION: "${CI_COMMIT_SHORT_SHA}"
before_script:
- !reference [.regctl-setup, before_script]

# We ensure that the OUT_IMAGE_VERSION is set
- 'echo Version: ${OUT_IMAGE_VERSION} ; [[ -n "${OUT_IMAGE_VERSION}" ]] || exit 1'

- apk add --no-cache make bash
script:
# Log in to the "output" registry, tag the image and push the image
- 'echo "Logging in to CI registry ${CI_REGISTRY}"'
- regctl registry login "${CI_REGISTRY}" -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}"
- '[ ${CI_REGISTRY} = ${OUT_REGISTRY} ] || echo "Logging in to output registry ${OUT_REGISTRY}"'
- '[ ${CI_REGISTRY} = ${OUT_REGISTRY} ] || regctl registry login "${OUT_REGISTRY}" -u "${OUT_REGISTRY_USER}" -p "${OUT_REGISTRY_TOKEN}"'

# Since OUT_IMAGE_NAME and OUT_IMAGE_VERSION are set, this will push the CI image to the
# Target
- make -f deployments/container/Makefile push-${DIST}

# Define a staging release step that pushes an image to an internal "staging" repository
# This is triggered for all pipelines (i.e. not only tags) to test the pipeline steps
# outside of the release process.
.release:staging:
extends:
- .release
variables:
OUT_REGISTRY_USER: "${CI_REGISTRY_USER}"
OUT_REGISTRY_TOKEN: "${CI_REGISTRY_PASSWORD}"
OUT_REGISTRY: "${CI_REGISTRY}"
OUT_IMAGE_NAME: "${CI_REGISTRY_IMAGE}/staging/cuda-samples"

# Define an external release step that pushes an image to an external repository.
# This includes a devlopment image off main.
.release:external:
extends:
- .release
rules:
- if: $CI_COMMIT_TAG
variables:
OUT_IMAGE_VERSION: "${CI_COMMIT_TAG}"
- if: $CI_COMMIT_BRANCH == $RELEASE_DEVEL_BRANCH
variables:
OUT_IMAGE_VERSION: "${DEVEL_RELEASE_IMAGE_VERSION}"

# Define the release jobs
release:staging-vectoradd-ubi9:
extends:
- .release:staging
- .dist-ubi9
- .sample-vectoradd
needs:
- image-vectoradd-ubi9

release:staging-vectoradd-ubuntu22.04:
extends:
- .release:staging
- .dist-ubuntu22.04
- .sample-vectoradd
needs:
- image-vectoradd-ubuntu22.04

release:staging-device-query-ubuntu22.04:
extends:
- .release:staging
- .dist-ubuntu22.04
- .sample-device-query
needs:
- image-device-query-ubuntu22.04

release:staging-vulkan:
extends:
- .release:staging
- .dist-ubuntu22.04
- .sample-vulkan
needs:
- image-vulkan-ubuntu22.04

release:staging-nvbandwidth:
extends:
- .release:staging
- .dist-ubuntu22.04
- .sample-nvbandwidth
needs:
- image-nvbandwidth-ubuntu22.04
27 changes: 6 additions & 21 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,13 @@ jobs:
strategy:
fail-fast: false
matrix:
dist:
- ubuntu22.04
- ubi9
sample:
- vectorAdd
- devicequery
- nbody
- deviceQuery
- nvbandwidth
- simpleMultiGPU
- simplemultigpu
- vectoradd
- vulkan
exclude:
- dist: ubi9
sample: deviceQuery
- dist: ubi9
sample: nbody
- dist: ubi9
sample: nvbandwidth
- dist: ubi9
sample: simpleMultiGPU
- dist: ubi9
sample: vulkan

steps:
- uses: actions/checkout@v4
Expand All @@ -61,7 +47,7 @@ jobs:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:qemu-v7.0.0
image: tonistiigi/binfmt:qemu-v9.2.2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -78,7 +64,6 @@ jobs:
IMAGE_NAME: ghcr.io/nvidia/k8s-samples
VERSION: ${{ inputs.version }}
PUSH_ON_BUILD: true
BUILD_MULTI_ARCH_IMAGES: ${{ inputs.build_multi_arch_images }}
run: |
echo "Building ${{ matrix.sample }} on ${{ matrix.dist }}"
SAMPLE=${{ matrix.sample }} make -f deployments/container/Makefile build-${{ matrix.dist }}
echo "Building ${{ matrix.sample }}"
make -f deployments/container/Makefile build-${{ matrix.sample }}
Loading