Skip to content

Commit 54d6fc9

Browse files
refactor: centralize CI variables and add component image overrides
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent 2c49553 commit 54d6fc9

File tree

3 files changed

+76
-57
lines changed

3 files changed

+76
-57
lines changed

.github/workflows/e2e-tests.yaml

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -76,58 +76,13 @@ on:
7676

7777
jobs:
7878
variables:
79-
runs-on: ubuntu-latest
80-
outputs:
81-
operator_version: ${{ steps.vars.outputs.operator_version }}
82-
operator_image: ${{ steps.vars.outputs.operator_image }}
83-
toolkit_image: ${{ steps.vars.outputs.toolkit_image }}
84-
device_plugin_image: ${{ steps.vars.outputs.device_plugin_image }}
85-
mig_manager_image: ${{ steps.vars.outputs.mig_manager_image }}
86-
steps:
87-
- name: Checkout code
88-
if: ${{ github.event_name != 'workflow_call' }}
89-
uses: actions/checkout@v5
90-
- name: Calculate test variables
91-
id: vars
92-
run: |
93-
# Use inputs from workflow_call if available
94-
if [[ "${{ github.event_name }}" == "workflow_call" ]]; then
95-
OPERATOR_IMAGE="${{ inputs.operator_image }}"
96-
OPERATOR_VERSION="${{ inputs.operator_version }}"
97-
# Use workflow_dispatch inputs if provided
98-
elif [[ -n "${{ inputs.operator_version }}" && -n "${{ inputs.operator_image }}" ]]; then
99-
OPERATOR_VERSION="${{ inputs.operator_version }}"
100-
OPERATOR_IMAGE="${{ inputs.operator_image }}"
101-
else
102-
# Calculate for standalone runs
103-
COMMIT_SHORT_SHA="${GITHUB_SHA:0:8}"
104-
OPERATOR_VERSION="${COMMIT_SHORT_SHA}"
105-
OPERATOR_IMAGE="ghcr.io/nvidia/gpu-operator"
106-
fi
107-
108-
# Component images (optional, use inputs if provided)
109-
TOOLKIT_IMAGE="${{ inputs.toolkit_image }}"
110-
DEVICE_PLUGIN_IMAGE="${{ inputs.device_plugin_image }}"
111-
MIG_MANAGER_IMAGE="${{ inputs.mig_manager_image }}"
112-
113-
# Output all variables
114-
echo "operator_version=${OPERATOR_VERSION}" >> $GITHUB_OUTPUT
115-
echo "operator_image=${OPERATOR_IMAGE}" >> $GITHUB_OUTPUT
116-
echo "toolkit_image=${TOOLKIT_IMAGE}" >> $GITHUB_OUTPUT
117-
echo "device_plugin_image=${DEVICE_PLUGIN_IMAGE}" >> $GITHUB_OUTPUT
118-
echo "mig_manager_image=${MIG_MANAGER_IMAGE}" >> $GITHUB_OUTPUT
119-
120-
# Display for debugging
121-
echo "::notice::Testing operator: ${OPERATOR_IMAGE}:${OPERATOR_VERSION}"
122-
if [[ -n "${TOOLKIT_IMAGE}" ]]; then
123-
echo "::notice::Using custom toolkit: ${TOOLKIT_IMAGE}"
124-
fi
125-
if [[ -n "${DEVICE_PLUGIN_IMAGE}" ]]; then
126-
echo "::notice::Using custom device-plugin: ${DEVICE_PLUGIN_IMAGE}"
127-
fi
128-
if [[ -n "${MIG_MANAGER_IMAGE}" ]]; then
129-
echo "::notice::Using custom mig-manager: ${MIG_MANAGER_IMAGE}"
130-
fi
79+
uses: ./.github/workflows/variables.yaml
80+
with:
81+
operator_image: ${{ inputs.operator_image }}
82+
operator_version: ${{ inputs.operator_version }}
83+
toolkit_image: ${{ inputs.toolkit_image }}
84+
device_plugin_image: ${{ inputs.device_plugin_image }}
85+
mig_manager_image: ${{ inputs.mig_manager_image }}
13186

13287
e2e-tests-containerd:
13388
needs: [variables]
@@ -226,4 +181,3 @@ jobs:
226181
name: nvidiadriver-e2e-test-logs
227182
path: ./logs/
228183
retention-days: 15
229-

.github/workflows/forward-compatibility.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,4 @@ jobs:
128128
• MIG Manager: `${{ needs.fetch-latest-images.outputs.mig_manager_image }}`
129129
130130
*Details:* <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Failed Run>
131-
<@D044YE2MBAR> | <@D051KR3TAQN> | <@D04D866RKLH> | <@D045R30QRPS>
131+
<@S095E7BNGJU>

.github/workflows/variables.yaml

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,27 @@
1414

1515
on:
1616
workflow_call:
17+
inputs:
18+
operator_image:
19+
description: 'Operator image to use (optional override)'
20+
required: false
21+
type: string
22+
operator_version:
23+
description: 'Operator version to use (optional override)'
24+
required: false
25+
type: string
26+
toolkit_image:
27+
description: 'Full container-toolkit image path (optional)'
28+
required: false
29+
type: string
30+
device_plugin_image:
31+
description: 'Full device-plugin image path (optional)'
32+
required: false
33+
type: string
34+
mig_manager_image:
35+
description: 'Full mig-manager image path (optional)'
36+
required: false
37+
type: string
1738
outputs:
1839
commit_short_sha:
1940
description: "The short SHA to use as a version string"
@@ -33,6 +54,18 @@ on:
3354
operator_version:
3455
description: "The operator version"
3556
value: ${{ jobs.variables.outputs.operator_version }}
57+
operator_image:
58+
description: "The operator image (with override support)"
59+
value: ${{ jobs.variables.outputs.operator_image }}
60+
toolkit_image:
61+
description: "The container-toolkit image override"
62+
value: ${{ jobs.variables.outputs.toolkit_image }}
63+
device_plugin_image:
64+
description: "The device-plugin image override"
65+
value: ${{ jobs.variables.outputs.device_plugin_image }}
66+
mig_manager_image:
67+
description: "The mig-manager image override"
68+
value: ${{ jobs.variables.outputs.mig_manager_image }}
3669

3770
jobs:
3871
variables:
@@ -44,6 +77,10 @@ jobs:
4477
push_on_build: ${{ steps.vars.outputs.push_on_build }}
4578
operator_image_base: ${{ steps.vars.outputs.operator_image_base }}
4679
operator_version: ${{ steps.vars.outputs.operator_version }}
80+
operator_image: ${{ steps.vars.outputs.operator_image }}
81+
toolkit_image: ${{ steps.vars.outputs.toolkit_image }}
82+
device_plugin_image: ${{ steps.vars.outputs.device_plugin_image }}
83+
mig_manager_image: ${{ steps.vars.outputs.mig_manager_image }}
4784
steps:
4885
- name: Checkout code
4986
uses: actions/checkout@v5
@@ -73,9 +110,24 @@ jobs:
73110
fi
74111
fi
75112
76-
# Image and version information
113+
# Image and version information (with override support)
77114
OPERATOR_IMAGE_BASE="ghcr.io/nvidia/gpu-operator"
78-
OPERATOR_VERSION="${COMMIT_SHORT_SHA}"
115+
if [[ -n "${{ inputs.operator_version }}" ]]; then
116+
OPERATOR_VERSION="${{ inputs.operator_version }}"
117+
else
118+
OPERATOR_VERSION="${COMMIT_SHORT_SHA}"
119+
fi
120+
121+
if [[ -n "${{ inputs.operator_image }}" ]]; then
122+
OPERATOR_IMAGE="${{ inputs.operator_image }}"
123+
else
124+
OPERATOR_IMAGE="${OPERATOR_IMAGE_BASE}"
125+
fi
126+
127+
# Component images (optional overrides)
128+
TOOLKIT_IMAGE="${{ inputs.toolkit_image }}"
129+
DEVICE_PLUGIN_IMAGE="${{ inputs.device_plugin_image }}"
130+
MIG_MANAGER_IMAGE="${{ inputs.mig_manager_image }}"
79131
80132
# Output all variables
81133
echo "commit_short_sha=${COMMIT_SHORT_SHA}" >> $GITHUB_OUTPUT
@@ -84,9 +136,22 @@ jobs:
84136
echo "push_on_build=${PUSH_ON_BUILD}" >> $GITHUB_OUTPUT
85137
echo "operator_image_base=${OPERATOR_IMAGE_BASE}" >> $GITHUB_OUTPUT
86138
echo "operator_version=${OPERATOR_VERSION}" >> $GITHUB_OUTPUT
139+
echo "operator_image=${OPERATOR_IMAGE}" >> $GITHUB_OUTPUT
140+
echo "toolkit_image=${TOOLKIT_IMAGE}" >> $GITHUB_OUTPUT
141+
echo "device_plugin_image=${DEVICE_PLUGIN_IMAGE}" >> $GITHUB_OUTPUT
142+
echo "mig_manager_image=${MIG_MANAGER_IMAGE}" >> $GITHUB_OUTPUT
87143
88144
# Display for debugging
89145
echo "::notice::Commit SHA: ${COMMIT_SHORT_SHA}"
90146
echo "::notice::Push on build: ${PUSH_ON_BUILD}"
91-
echo "::notice::Operator image: ${OPERATOR_IMAGE_BASE}:${OPERATOR_VERSION}"
147+
echo "::notice::Operator image: ${OPERATOR_IMAGE}:${OPERATOR_VERSION}"
148+
if [[ -n "${TOOLKIT_IMAGE}" ]]; then
149+
echo "::notice::Using custom toolkit: ${TOOLKIT_IMAGE}"
150+
fi
151+
if [[ -n "${DEVICE_PLUGIN_IMAGE}" ]]; then
152+
echo "::notice::Using custom device-plugin: ${DEVICE_PLUGIN_IMAGE}"
153+
fi
154+
if [[ -n "${MIG_MANAGER_IMAGE}" ]]; then
155+
echo "::notice::Using custom mig-manager: ${MIG_MANAGER_IMAGE}"
156+
fi
92157

0 commit comments

Comments
 (0)