Skip to content

Commit 21d41d1

Browse files
authored
Merge pull request #30 from elezar/simplify-makefile
Improve image publishing
2 parents 99e6ed6 + f0838e5 commit 21d41d1

File tree

10 files changed

+320
-653
lines changed

10 files changed

+320
-653
lines changed

.common-ci.yml

Lines changed: 22 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -13,202 +13,45 @@
1313
# limitations under the License.
1414

1515
default:
16-
image: docker:stable
16+
image: docker
1717
services:
18-
- name: docker:stable-dind
18+
- name: docker:dind
1919
command: ["--experimental"]
2020

2121
variables:
2222
GIT_SUBMODULE_STRATEGY: recursive
2323
BUILD_MULTI_ARCH_IMAGES: "true"
2424

2525
stages:
26-
- image
27-
- lint
28-
- go-checks
29-
- go-build
30-
- unit-tests
31-
- package-build
32-
- image-build
33-
- test
26+
- pull
3427
- scan
35-
- aws_kube_setup
36-
- integration_tests
37-
- e2e_tests
38-
- aws_kube_clean
3928
- release
29+
- sign
4030

41-
# Define the distribution targets
42-
.dist-ubuntu22.04:
43-
variables:
44-
DIST: ubuntu22.04
45-
46-
.dist-ubi9:
47-
variables:
48-
DIST: ubi9
49-
50-
# Define the platform targets
51-
.platform-amd64:
52-
variables:
53-
PLATFORM: linux/amd64
54-
55-
.platform-arm64:
56-
variables:
57-
PLATFORM: linux/arm64
58-
59-
# Define the sample targets
60-
.sample-vectoradd:
61-
variables:
62-
SAMPLE: vectorAdd
63-
LOWER_CASE_SAMPLE: vectoradd
64-
PUSH_SAMPLE_ONLY_TAG: "false"
65-
66-
.sample-nbody:
67-
variables:
68-
SAMPLE: nbody
69-
LOWER_CASE_SAMPLE: nbody
70-
PUSH_SAMPLE_ONLY_TAG: "true"
71-
72-
.sample-device-query:
73-
variables:
74-
SAMPLE: deviceQuery
75-
LOWER_CASE_SAMPLE: devicequery
76-
PUSH_SAMPLE_ONLY_TAG: "true"
77-
78-
.sample-simple-multi-gpu:
79-
variables:
80-
SAMPLE: simpleMultiGPU
81-
LOWER_CASE_SAMPLE: simplemultigpu
82-
PUSH_SAMPLE_ONLY_TAG: "true"
83-
84-
# Define the sample targets
85-
.sample-vulkan:
86-
variables:
87-
SAMPLE: vulkan
88-
LOWER_CASE_SAMPLE: vulkan
89-
PUSH_SAMPLE_ONLY_TAG: "true"
90-
91-
.sample-nvbandwidth:
92-
variables:
93-
SAMPLE: nvbandwidth
94-
LOWER_CASE_SAMPLE: nvbandwidth
95-
PUSH_SAMPLE_ONLY_TAG: "true"
96-
97-
# Make buildx available as a docker CLI plugin
98-
.buildx-setup:
99-
before_script:
100-
- export BUILDX_VERSION=v0.6.3
101-
- apk add --no-cache curl
102-
- mkdir -p ~/.docker/cli-plugins
103-
- curl -sSLo ~/.docker/cli-plugins/docker-buildx "https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-amd64"
104-
- chmod a+x ~/.docker/cli-plugins/docker-buildx
105-
106-
- docker buildx create --use --platform=linux/amd64,linux/arm64
107-
108-
- '[[ -n "${SKIP_QEMU_SETUP}" ]] || docker run --rm --privileged multiarch/qemu-user-static --reset -p yes'
31+
.pipeline-trigger-rules:
32+
rules:
33+
# We trigger the pipeline if started manually
34+
- if: $CI_PIPELINE_SOURCE == "web"
35+
# We trigger the pipeline on the main branch
36+
- if: $CI_COMMIT_BRANCH == "main"
37+
# We trigger the pipeline on the release- branches
38+
- if: $CI_COMMIT_BRANCH =~ /^release-.*$/
39+
# We trigger the pipeline on tags
40+
- if: $CI_COMMIT_TAG && $CI_COMMIT_TAG != ""
41+
42+
workflow:
43+
rules:
44+
# We trigger the pipeline on a merge request
45+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
46+
# We then add all the regular triggers
47+
- !reference [.pipeline-trigger-rules, rules]
10948

11049
# Download the regctl binary for use in the release steps
11150
.regctl-setup:
11251
before_script:
113-
- export REGCTL_VERSION=v0.3.10
52+
- export REGCTL_VERSION=v0.9.0
11453
- apk add --no-cache curl
11554
- mkdir -p bin
11655
- curl -sSLo bin/regctl https://github.com/regclient/regclient/releases/download/${REGCTL_VERSION}/regctl-linux-amd64
11756
- chmod a+x bin/regctl
11857
- export PATH=$(pwd)/bin:${PATH}
119-
120-
# .release forms the base of the deployment jobs which push images to the CI registry.
121-
# This is extended with the version to be deployed (e.g. the SHA or TAG) and the
122-
# target os.
123-
.release:
124-
stage:
125-
release
126-
variables:
127-
# Define the source image for the release
128-
IMAGE_NAME: "${CI_REGISTRY_IMAGE}/cuda-samples"
129-
VERSION: "${CI_COMMIT_SHORT_SHA}"
130-
# OUT_IMAGE_VERSION is overridden for external releases
131-
OUT_IMAGE_VERSION: "${CI_COMMIT_SHORT_SHA}"
132-
before_script:
133-
- !reference [.regctl-setup, before_script]
134-
135-
# We ensure that the OUT_IMAGE_VERSION is set
136-
- 'echo Version: ${OUT_IMAGE_VERSION} ; [[ -n "${OUT_IMAGE_VERSION}" ]] || exit 1'
137-
138-
- apk add --no-cache make bash
139-
script:
140-
# Log in to the "output" registry, tag the image and push the image
141-
- 'echo "Logging in to CI registry ${CI_REGISTRY}"'
142-
- regctl registry login "${CI_REGISTRY}" -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}"
143-
- '[ ${CI_REGISTRY} = ${OUT_REGISTRY} ] || echo "Logging in to output registry ${OUT_REGISTRY}"'
144-
- '[ ${CI_REGISTRY} = ${OUT_REGISTRY} ] || regctl registry login "${OUT_REGISTRY}" -u "${OUT_REGISTRY_USER}" -p "${OUT_REGISTRY_TOKEN}"'
145-
146-
# Since OUT_IMAGE_NAME and OUT_IMAGE_VERSION are set, this will push the CI image to the
147-
# Target
148-
- make -f deployments/container/Makefile push-${DIST}
149-
150-
# Define a staging release step that pushes an image to an internal "staging" repository
151-
# This is triggered for all pipelines (i.e. not only tags) to test the pipeline steps
152-
# outside of the release process.
153-
.release:staging:
154-
extends:
155-
- .release
156-
variables:
157-
OUT_REGISTRY_USER: "${CI_REGISTRY_USER}"
158-
OUT_REGISTRY_TOKEN: "${CI_REGISTRY_PASSWORD}"
159-
OUT_REGISTRY: "${CI_REGISTRY}"
160-
OUT_IMAGE_NAME: "${CI_REGISTRY_IMAGE}/staging/cuda-samples"
161-
162-
# Define an external release step that pushes an image to an external repository.
163-
# This includes a devlopment image off main.
164-
.release:external:
165-
extends:
166-
- .release
167-
rules:
168-
- if: $CI_COMMIT_TAG
169-
variables:
170-
OUT_IMAGE_VERSION: "${CI_COMMIT_TAG}"
171-
- if: $CI_COMMIT_BRANCH == $RELEASE_DEVEL_BRANCH
172-
variables:
173-
OUT_IMAGE_VERSION: "${DEVEL_RELEASE_IMAGE_VERSION}"
174-
175-
# Define the release jobs
176-
release:staging-vectoradd-ubi9:
177-
extends:
178-
- .release:staging
179-
- .dist-ubi9
180-
- .sample-vectoradd
181-
needs:
182-
- image-vectoradd-ubi9
183-
184-
release:staging-vectoradd-ubuntu22.04:
185-
extends:
186-
- .release:staging
187-
- .dist-ubuntu22.04
188-
- .sample-vectoradd
189-
needs:
190-
- image-vectoradd-ubuntu22.04
191-
192-
release:staging-device-query-ubuntu22.04:
193-
extends:
194-
- .release:staging
195-
- .dist-ubuntu22.04
196-
- .sample-device-query
197-
needs:
198-
- image-device-query-ubuntu22.04
199-
200-
release:staging-vulkan:
201-
extends:
202-
- .release:staging
203-
- .dist-ubuntu22.04
204-
- .sample-vulkan
205-
needs:
206-
- image-vulkan-ubuntu22.04
207-
208-
release:staging-nvbandwidth:
209-
extends:
210-
- .release:staging
211-
- .dist-ubuntu22.04
212-
- .sample-nvbandwidth
213-
needs:
214-
- image-nvbandwidth-ubuntu22.04

.github/workflows/image.yaml

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,13 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
dist:
36-
- ubuntu22.04
37-
- ubi9
3835
sample:
39-
- vectorAdd
36+
- devicequery
4037
- nbody
41-
- deviceQuery
4238
- nvbandwidth
43-
- simpleMultiGPU
39+
- simplemultigpu
40+
- vectoradd
4441
- vulkan
45-
exclude:
46-
- dist: ubi9
47-
sample: deviceQuery
48-
- dist: ubi9
49-
sample: nbody
50-
- dist: ubi9
51-
sample: nvbandwidth
52-
- dist: ubi9
53-
sample: simpleMultiGPU
54-
- dist: ubi9
55-
sample: vulkan
5642

5743
steps:
5844
- uses: actions/checkout@v4
@@ -61,7 +47,7 @@ jobs:
6147
- name: Set up QEMU
6248
uses: docker/setup-qemu-action@v3
6349
with:
64-
image: tonistiigi/binfmt:qemu-v7.0.0
50+
image: tonistiigi/binfmt:qemu-v9.2.2
6551

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

0 commit comments

Comments
 (0)