forked from opendatahub-io/ogx-distribution
-
Notifications
You must be signed in to change notification settings - Fork 0
237 lines (209 loc) · 8 KB
/
Copy pathtest-pr-in-showroom.yml
File metadata and controls
237 lines (209 loc) · 8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
name: Test PR in Showroom
on:
schedule:
- cron: '0 8 * * *' # daily at 08:00 UTC
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to build and test'
required: true
type: string
catalog_image:
description: 'OLM catalog image (optional, uses default if not specified)'
required: false
type: string
operator_image:
description: 'Operator image (optional, uses default if not specified)'
required: false
type: string
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
pull-requests: read
outputs:
tag: ${{ steps.build.outputs.tag }}
sha: ${{ steps.pr-info.outputs.sha }}
steps:
- name: Get PR information
if: inputs.pr_number != ''
id: pr-info
env:
PR_NUMBER: ${{ inputs.pr_number }}
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const prNumber = Number(process.env.PR_NUMBER);
if (!Number.isInteger(prNumber) || prNumber < 1) {
core.setFailed('Invalid PR number');
return;
}
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});
core.setOutput('sha', pr.data.head.sha);
core.setOutput('ref', pr.data.head.ref);
core.setOutput('repo', pr.data.head.repo.full_name);
console.log(`PR #${prNumber}:`);
console.log(` SHA: ${pr.data.head.sha}`);
console.log(` Ref: ${pr.data.head.ref}`);
console.log(` Repo: ${pr.data.head.repo.full_name}`);
- name: Checkout PR code
if: inputs.pr_number != ''
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
repository: ${{ steps.pr-info.outputs.repo }}
ref: ${{ steps.pr-info.outputs.sha }}
persist-credentials: false
- name: Checkout pushed code
if: inputs.pr_number == ''
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
- name: Regenerate distribution artifacts
uses: ./.github/actions/regenerate-artifacts
- name: Build image
id: build
env:
PR_NUMBER: ${{ inputs.pr_number }}
PR_SHA: ${{ steps.pr-info.outputs.sha }}
PUSH_SHA: ${{ github.sha }}
run: |
if [ -n "$PR_NUMBER" ]; then
if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then
echo "Invalid PR_NUMBER"
exit 1
fi
if ! [[ "$PR_SHA" =~ ^[0-9a-f]{7,40}$ ]]; then
echo "Invalid PR_SHA"
exit 1
fi
TAG="pr-${PR_NUMBER}-${PR_SHA}"
else
SHORT_SHA="${PUSH_SHA:0:12}"
TAG="push-${SHORT_SHA}"
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Building image: ogx-test:$TAG"
podman build -f Containerfile -t "ogx-test:$TAG" .
- name: Save image as artifact
env:
TAG: ${{ steps.build.outputs.tag }}
run: |
podman save "ogx-test:$TAG" | zstd -T0 -o ogx-test-image.tar.zst
- name: Upload image artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ogx-test-image
path: ogx-test-image.tar.zst
retention-days: 1
test:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 30
concurrency:
group: openshift-cluster-1
cancel-in-progress: false
permissions:
contents: read
env:
REGISTRY_IMAGE: "image-registry.openshift-image-registry.svc:5000/redhat-ods-operator/ogx-test:${{ needs.build.outputs.tag }}"
steps:
- name: Download image artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ogx-test-image
- name: Load image
env:
TAG: ${{ needs.build.outputs.tag }}
run: |
zstd -d ogx-test-image.tar.zst --stdout | podman load
rm ogx-test-image.tar.zst
podman image exists "ogx-test:$TAG"
- name: Setup CI environment
id: setup
uses: derekhiggins/llama-stack-showroom@f32973c9b7389b14d1988b55abfe74dd98c2432f # main as of 2026-06-05
with:
catalog_image: ${{ inputs.catalog_image }}
llama_stack_image: ${{ env.REGISTRY_IMAGE }}
operator_image: ${{ inputs.operator_image }}
oc_server: ${{ secrets.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
env: |
SHOWROOM_PULL_SECRET=${{ secrets.SHOWROOM_PULL_SECRET }}
SHOWROOM_VLLM_URL=https://llama-3-2-3b-maas-apicast-production.apps.prod.rhoai.rh-aiservices-bu.com:443/v1
SHOWROOM_VLLM_API_TOKEN=${{ secrets.SHOWROOM_VLLM_API_TOKEN }}
SHOWROOM_VLLM_EMBEDDING_URL=https://nomic-embed-text-v1-5-maas-apicast-production.apps.prod.rhoai.rh-aiservices-bu.com:443/v1
SHOWROOM_VLLM_EMBEDDING_API_TOKEN=${{ secrets.SHOWROOM_VLLM_EMBEDDING_API_TOKEN }}
SHOWROOM_OPENAI_API_KEY=${{ secrets.SHOWROOM_OPENAI_API_KEY }}
- name: Push image to OpenShift registry
env:
TAG: ${{ needs.build.outputs.tag }}
run: |
"${{ steps.setup.outputs.scripts_dir }}/push-image-to-registry.sh" \
"ogx-test:$TAG" \
redhat-ods-operator \
"ogx-test:$TAG"
- name: Run setup.sh
run: |
"${{ steps.setup.outputs.scripts_dir }}/setup.sh"
- name: Run provision.sh
run: |
"${{ steps.setup.outputs.scripts_dir }}/provision.sh"
- name: Run tests
run: |
cd "${{ steps.setup.outputs.scripts_dir }}"
./test.sh
- name: Debug - Capture OpenShift state
if: always()
run: |
echo -e "\n=== Recent Events ==="
oc get events -n redhat-ods-applications --sort-by='.lastTimestamp' \
-o custom-columns=TIME:.lastTimestamp,TYPE:.type,REASON:.reason,OBJECT:.involvedObject.name,MESSAGE:.message
echo -e "\n=== All Resources ==="
oc get all -n redhat-ods-applications
echo -e "\n=== Pod Logs (first 5 lines) ==="
oc logs -n redhat-ods-applications -l app=ogx --tail=-1 | head -5 || echo "No logs available"
echo -e "\n=== Pod Logs (last 150 lines) ==="
oc logs -n redhat-ods-applications --tail=150 -l app=ogx || echo "No logs available"
- name: Run unprovision.sh
if: always()
run: |
"${{ steps.setup.outputs.scripts_dir }}/unprovision.sh"
- name: Run cleanup.sh
if: always()
run: |
"${{ steps.setup.outputs.scripts_dir }}/cleanup.sh"
- name: Output summary
if: always()
env:
PR_NUMBER: ${{ inputs.pr_number }}
PR_SHA: ${{ needs.build.outputs.sha }}
PUSH_SHA: ${{ github.sha }}
IMAGE_TAG: ${{ needs.build.outputs.tag }}
JOB_STATUS: ${{ job.status }}
run: |
{
echo "# Test in Showroom - Summary"
echo ""
echo "## Build Information"
if [ -n "$PR_NUMBER" ]; then
echo "- **PR Number**: #${PR_NUMBER}"
echo "- **Commit SHA**: ${PR_SHA}"
else
echo "- **Trigger**: push"
echo "- **Commit SHA**: ${PUSH_SHA}"
fi
echo "- **Image Tag**: \`${IMAGE_TAG}\`"
echo ""
echo "## Test Results"
if [ "$JOB_STATUS" = "success" ]; then
echo "✅ All tests passed successfully!"
else
echo "❌ Tests failed. Check the logs above for details."
fi
} >> "$GITHUB_STEP_SUMMARY"