Skip to content

Commit 1a696d6

Browse files
authored
Merge pull request #1550 from tariq1890/custom-go-proxy
add support for building gpu-operator with a custom GOPROXY
2 parents 1dda249 + 7f6b2e2 commit 1a696d6

File tree

3 files changed

+118
-10
lines changed

3 files changed

+118
-10
lines changed

.github/workflows/ci.yaml

Lines changed: 113 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ jobs:
6666
### Golang checks and build ###
6767
go-check:
6868
needs: [helm-lint, validate-csv, validate-helm-values]
69-
runs-on: ubuntu-latest
69+
runs-on: linux-amd64-cpu4
70+
permissions:
71+
contents: read
72+
id-token: write
7073
steps:
7174
- uses: actions/checkout@v4
7275
name: Checkout code
@@ -87,11 +90,29 @@ jobs:
8790
version: ${{ env.GOLANGCI_LINT_VERSION }}
8891
args: -v --timeout 5m
8992
skip-cache: true
90-
- run: make check
93+
- name: Setup JFrog CLI
94+
id: jfrog
95+
uses: jfrog/setup-jfrog-cli@v4
96+
env:
97+
JF_URL: https://${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}/
98+
with:
99+
oidc-provider-name: nvgithub
100+
oidc-audience: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
101+
- env:
102+
OIDC_USER: ${{ steps.jfrog.outputs.oidc-user }}
103+
OIDC_TOKEN: ${{ steps.jfrog.outputs.oidc-token }}
104+
OIDC_ARTIFACTORY_ENDPOINT: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
105+
run: |
106+
OIDC_USER_ENCODED=$(python3 -c 'import urllib.parse, os; print(urllib.parse.quote_plus(os.environ["OIDC_USER"]))')
107+
export GOPROXY="https://${OIDC_USER_ENCODED}:${OIDC_TOKEN}@${OIDC_ARTIFACTORY_ENDPOINT}/artifactory/api/go/edge-go-remote-virtual"
108+
make check
91109
go-test:
92110
needs: [helm-lint, validate-csv, validate-helm-values]
93111
name: unit tests
94-
runs-on: ubuntu-latest
112+
runs-on: linux-amd64-cpu4
113+
permissions:
114+
contents: read
115+
id-token: write
95116
steps:
96117
- name: Checkout code
97118
uses: actions/checkout@v4
@@ -104,25 +125,67 @@ jobs:
104125
uses: actions/setup-go@v5
105126
with:
106127
go-version: ${{ env.GOLANG_VERSION }}
107-
- run: make coverage
128+
- name: Setup JFrog CLI
129+
id: jfrog
130+
uses: jfrog/setup-jfrog-cli@v4
131+
env:
132+
JF_URL: https://${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}/
133+
with:
134+
oidc-provider-name: nvgithub
135+
oidc-audience: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
136+
- env:
137+
OIDC_USER: ${{ steps.jfrog.outputs.oidc-user }}
138+
OIDC_TOKEN: ${{ steps.jfrog.outputs.oidc-token }}
139+
OIDC_ARTIFACTORY_ENDPOINT: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
140+
run: |
141+
OIDC_USER_ENCODED=$(python3 -c 'import urllib.parse, os; print(urllib.parse.quote_plus(os.environ["OIDC_USER"]))')
142+
export GOPROXY="https://${OIDC_USER_ENCODED}:${OIDC_TOKEN}@${OIDC_ARTIFACTORY_ENDPOINT}/artifactory/api/go/edge-go-remote-virtual"
143+
make coverage
108144
go-build:
109145
needs: [helm-lint, validate-csv, validate-helm-values]
110-
runs-on: ubuntu-latest
146+
runs-on: linux-amd64-cpu4
147+
permissions:
148+
contents: read
149+
id-token: write
111150
steps:
112151
- uses: actions/checkout@v4
113152
name: Checkout code
114153
- run: make docker-build
115154
coverage:
116155
needs: [go-test]
117-
runs-on: ubuntu-latest
156+
runs-on: linux-amd64-cpu4
157+
permissions:
158+
contents: read
159+
id-token: write
118160
steps:
119-
- uses: actions/checkout@v4
161+
- name: Checkout code
162+
uses: actions/checkout@v4
163+
- name: Get Golang version
164+
id: vars
165+
run: |
166+
GOLANG_VERSION=$( grep "GOLANG_VERSION ?=" versions.mk )
167+
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION ?= }" >> $GITHUB_ENV
120168
- name: Set up Go
121169
uses: actions/setup-go@v5
122170
with:
123171
go-version: ${{ env.GOLANG_VERSION }}
172+
- name: Setup JFrog CLI
173+
id: jfrog
174+
uses: jfrog/setup-jfrog-cli@v4
175+
env:
176+
JF_URL: https://${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}/
177+
with:
178+
oidc-provider-name: nvgithub
179+
oidc-audience: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
124180
- name: Generate coverage report
125-
run: make cov-report
181+
env:
182+
OIDC_USER: ${{ steps.jfrog.outputs.oidc-user }}
183+
OIDC_TOKEN: ${{ steps.jfrog.outputs.oidc-token }}
184+
OIDC_ARTIFACTORY_ENDPOINT: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
185+
run: |
186+
OIDC_USER_ENCODED=$(python3 -c 'import urllib.parse, os; print(urllib.parse.quote_plus(os.environ["OIDC_USER"]))')
187+
export GOPROXY="https://${OIDC_USER_ENCODED}:${OIDC_TOKEN}@${OIDC_ARTIFACTORY_ENDPOINT}/artifactory/api/go/edge-go-remote-virtual"
188+
make cov-report
126189
- name: Upload to Coveralls
127190
uses: coverallsapp/github-action@v2
128191
with:
@@ -132,7 +195,11 @@ jobs:
132195
### Image builds ###
133196
build-gpu-operator-arm64:
134197
needs: [go-check, go-test, go-build]
135-
runs-on: ubuntu-24.04-arm
198+
runs-on: linux-arm64-cpu4
199+
permissions:
200+
contents: read
201+
id-token: write
202+
packages: write
136203
steps:
137204
- uses: actions/checkout@v4
138205
name: Check out code
@@ -163,16 +230,33 @@ jobs:
163230
registry: ghcr.io
164231
username: ${{ github.actor }}
165232
password: ${{ secrets.GITHUB_TOKEN }}
233+
- name: Setup JFrog CLI
234+
id: jfrog
235+
uses: jfrog/setup-jfrog-cli@v4
236+
env:
237+
JF_URL: https://${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}/
238+
with:
239+
oidc-provider-name: nvgithub
240+
oidc-audience: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
166241
- name: Build image
167242
env:
168243
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/gpu-operator
169244
VERSION: ${COMMIT_SHORT_SHA}-arm64
245+
OIDC_USER: ${{ steps.jfrog.outputs.oidc-user }}
246+
OIDC_TOKEN: ${{ steps.jfrog.outputs.oidc-token }}
247+
OIDC_ARTIFACTORY_ENDPOINT: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
170248
run: |
249+
OIDC_USER_ENCODED=$(python3 -c 'import urllib.parse, os; print(urllib.parse.quote_plus(os.environ["OIDC_USER"]))')
250+
export GOPROXY="https://${OIDC_USER_ENCODED}:${OIDC_TOKEN}@${OIDC_ARTIFACTORY_ENDPOINT}/artifactory/api/go/edge-go-remote-virtual"
171251
echo "${VERSION}"
172252
make build-image
173253
build-gpu-operator-amd64:
174254
needs: [go-check, go-test, go-build]
175-
runs-on: ubuntu-latest
255+
runs-on: linux-amd64-cpu4
256+
permissions:
257+
contents: read
258+
id-token: write
259+
packages: write
176260
steps:
177261
- uses: actions/checkout@v4
178262
name: Check out code
@@ -203,11 +287,24 @@ jobs:
203287
registry: ghcr.io
204288
username: ${{ github.actor }}
205289
password: ${{ secrets.GITHUB_TOKEN }}
290+
- name: Setup JFrog CLI
291+
id: jfrog
292+
uses: jfrog/setup-jfrog-cli@v4
293+
env:
294+
JF_URL: https://${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}/
295+
with:
296+
oidc-provider-name: nvgithub
297+
oidc-audience: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
206298
- name: Build image
207299
env:
208300
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/gpu-operator
209301
VERSION: ${COMMIT_SHORT_SHA}-amd64
302+
OIDC_USER: ${{ steps.jfrog.outputs.oidc-user }}
303+
OIDC_TOKEN: ${{ steps.jfrog.outputs.oidc-token }}
304+
OIDC_ARTIFACTORY_ENDPOINT: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
210305
run: |
306+
OIDC_USER_ENCODED=$(python3 -c 'import urllib.parse, os; print(urllib.parse.quote_plus(os.environ["OIDC_USER"]))')
307+
export GOPROXY="https://${OIDC_USER_ENCODED}:${OIDC_TOKEN}@${OIDC_ARTIFACTORY_ENDPOINT}/artifactory/api/go/edge-go-remote-virtual"
211308
echo "${VERSION}"
212309
make build-image
213310
@@ -244,6 +341,9 @@ jobs:
244341
e2e-tests-containerd:
245342
needs: [build-multi-arch-images]
246343
runs-on: linux-amd64-cpu4
344+
permissions:
345+
contents: read
346+
id-token: write
247347
steps:
248348
- uses: actions/checkout@v4
249349
name: Check out code
@@ -294,6 +394,9 @@ jobs:
294394
e2e-tests-nvidiadriver:
295395
needs: [build-multi-arch-images]
296396
runs-on: linux-amd64-cpu4
397+
permissions:
398+
contents: read
399+
id-token: write
297400
steps:
298401
- uses: actions/checkout@v4
299402
name: Check out code

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ include $(CURDIR)/versions.mk
2626

2727
MODULE := github.com/NVIDIA/gpu-operator
2828
BUILDER_IMAGE ?= golang:$(GOLANG_VERSION)
29+
GOPROXY ?= direct
2930

3031
ifeq ($(IMAGE_NAME),)
3132
REGISTRY ?= nvcr.io/nvidia/cloud-native
@@ -280,6 +281,7 @@ build-image:
280281
--build-arg BUILDER_IMAGE="$(BUILDER_IMAGE)" \
281282
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
282283
--build-arg GIT_COMMIT="$(GIT_COMMIT)" \
284+
--build-arg GOPROXY="$(GOPROXY)" \
283285
--file $(DOCKERFILE) $(CURDIR)
284286

285287
# Provide a utility target to build the images to allow for use in external tools.

docker/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ RUN set -eux; \
3434
ENV GOPATH=/go
3535
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
3636

37+
ARG GOPROXY=direct
38+
ENV GOPROXY=$GOPROXY
39+
3740
WORKDIR /workspace
3841
# Copy the Go Modules manifests
3942
COPY go.mod go.mod

0 commit comments

Comments
 (0)