-
Notifications
You must be signed in to change notification settings - Fork 115
603 lines (521 loc) · 24.7 KB
/
genai-pre-merge.yaml
File metadata and controls
603 lines (521 loc) · 24.7 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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
---
# SPDX-FileCopyrightText: (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
name: "[GENAI] PR Scans and Unit Tests"
run-name: "[GENAI] PR workflow (by @${{ github.actor }} via ${{ github.event_name }})"
# Only run at most 1 workflow concurrently per PR, unlimited for branches
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
on:
pull_request:
branches:
- main
paths:
- 'sample-applications/chat-question-and-answer-core/**'
- 'sample-applications/chat-question-and-answer/**'
- 'microservices/document-ingestion/pgvector/**'
jobs:
zizmor-workflow-scan:
runs-on: ubuntu-22.04-32core-128GB
permissions:
contents: read
env:
ZIZMOR_VERSION: 1.5.2
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb
- name: Run Zizmor Workflow Security Scan
continue-on-error: true
run: uvx zizmor=="$ZIZMOR_VERSION" "$GITHUB_WORKSPACE" --no-exit-codes > zizmor_workflow_scan_report.txt
- name: Upload Zizmor Scan Report
uses: actions/upload-artifact@v4
if: always()
with:
name: zizmor-workflow-security-report
path: zizmor_workflow_scan_report.txt
detect-changes:
runs-on: ubuntu-22.04-32core-128GB
permissions:
contents: read
outputs:
changed_projects: ${{ steps.discover.outputs.changed_projects }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Discover Changed Subfolders
id: discover
uses: ./.github/actions/discover-changed-subfolders
with:
project_folder: "."
include_folders: "sample-applications/chat-question-and-answer-core,sample-applications/chat-question-and-answer,microservices/document-ingestion/pgvector"
- name: Debug Changed Projects
shell: bash
env:
CHANGED_PROJECTS: ${{ steps.discover.outputs.changed_projects }}
run: |
echo "GITHUB_WORKSPACE: $GITHUB_WORKSPACE"
echo "PWD: $(pwd)"
echo "Changed Projects: $CHANGED_PROJECTS"
chat-question-and-answer-core-job:
needs: detect-changes
permissions:
contents: read
if: contains(fromJson(needs.detect-changes.outputs.changed_projects), 'sample-applications/chat-question-and-answer-core')
runs-on: ubuntu-22.04-32core-128GB
env:
HUGGINGFACEHUB_API_TOKEN: ${{ secrets.HUGGINGFACE_API_TOKEN }}
LLM_MODEL: Intel/neural-chat-7b-v3-3
EMBEDDING_MODEL_NAME: BAAI/bge-small-en-v1.5
RERANKER_MODEL: BAAI/bge-reranker-base
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Tools
uses: ./.github/actions/setup-tools
- name: Run Unit Tests for Core
continue-on-error: true
shell: bash
run: |
cd sample-applications/chat-question-and-answer-core
echo "Running unit test cases"
python3.12 -m venv venv
source venv/bin/activate
poetry install --with dev || true
poetry add pytest-html
source scripts/setup_env.sh
poetry run pytest tests/ --html=pytest-coverage.html
coverage run --source=. -m pytest
coverage report -m
# Install required packages
#poetry add pytest-cov pytest-html
# Run tests with coverage and HTML report in one command
# poetry run pytest tests/ --cov=. --cov-report=html --html=pytest-report.html
# For a combined coverage and test report
# poetry run pytest tests/ --cov=. --cov-report=term --cov-report=html:coverage-html --html=pytest-report.html
deactivate
rm -rf venv
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
continue-on-error: true
with:
name: core-coverage-report
path: |
sample-applications/chat-question-and-answer-core/pytest-coverage.html
sample-applications/chat-question-and-answer-core/pytest-report.html
# sample-applications/chat-question-and-answer-core/htmlcov/index.html
# sample-applications/chat-question-and-answer-core/coverage-html/index.html
- name: Setup Node.js
uses: actions/setup-node@v4
continue-on-error: true
with:
node-version: '22'
- name: Install npm dependencies
continue-on-error: true
shell: bash
run: |
pwd
cd sample-applications/chat-question-and-answer-core/ui/
# Install with verbose logging
npm install
npm install -D vitest@2.1.9
npm run test
npm run test:ui
npm run coverage
npx vitest run --reporter=html --outputFile=ui-results.html --coverage --coverage.reporter=html --coverage.reportsDirectory=ui-coverage-html
- name: Upload UI Results
uses: actions/upload-artifact@v4
continue-on-error: true
if: always()
with:
name: ui-test-results-core
path: |
sample-applications/chat-question-and-answer-core/ui/ui-results.html
sample-applications/chat-question-and-answer-core/ui/ui-coverage-html/
- name: trivy repo scan
continue-on-error: true
shell: bash
run: |
pwd
cd sample-applications/chat-question-and-answer-core/
trivy --version
which trivy
trivy image --download-db-only
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/html.tpl -o trivy-html.tpl
# Use the downloaded template
trivy fs . --format template --template "@trivy-html.tpl" -o "trivy_code_scan_core.html"
- name: Upload trivy reports
continue-on-error: true
uses: actions/upload-artifact@v4
if: always()
with:
name: trivy-code-scan-results-core
path: |
sample-applications/chat-question-and-answer-core/trivy_code_scan_core.html
- name: ClamAV Antivirus Scan
continue-on-error: true
shell: bash
run: |
echo "Starting ClamAV scan on sample-applications/chat-question-and-answer-core/..."
docker run --rm \
--mount type=bind,source=./sample-applications/chat-question-and-answer-core/,target=/scandir \
clamav/clamav:stable \
clamscan --recursive --log=/scandir/clamav-scan-report.log \
/scandir
SCAN_EXIT_CODE=$?
sudo chown $USER:$USER sample-applications/chat-question-and-answer-core/clamav-scan-report.log 2>/dev/null || true
if [ $SCAN_EXIT_CODE -ne 0 ]; then
echo "ClamAV scan failed or found issues"
exit 1
fi
- name: Upload Antivirus Report
continue-on-error: true
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: antivirus-report-core
path: sample-applications/chat-question-and-answer-core/clamav-scan-report.log
- name: Trivy Image Scan
continue-on-error: true
shell: bash
run: |
pwd
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/html.tpl -o trivy-html.tpl
echo "Building image chatqna-core-backend and scanning"
docker build -f ./sample-applications/chat-question-and-answer-core/docker/Dockerfile -t chatqna-core-backend:latest ./sample-applications/chat-question-and-answer-core/
trivy image chatqna-core-backend:latest --ignore-unfixed --format template --template "@trivy-html.tpl" -o sample-applications/chat-question-and-answer-core/trivy_image_scan_core-backend.html
trivy image --quiet --format spdx-json --output sample-applications/chat-question-and-answer-core/trivy_image_scan_core-backend.spdx.json chatqna-core-backend:latest
echo "completed chatqna-core-backend scanning"
echo "**************************************************************"
echo "Building image chatqna-core-frontend and scanning"
docker build -t="chatqna-core-frontend:latest" ./sample-applications/chat-question-and-answer-core/ui
trivy image chatqna-core-frontend:latest --ignore-unfixed --format template --template "@trivy-html.tpl" -o sample-applications/chat-question-and-answer-core/trivy_image_scan_core-frontend.html
trivy image --quiet --format spdx-json --output sample-applications/chat-question-and-answer-core/trivy_image_scan_core-frontend.spdx.json chatqna-core-frontend:latest
echo "completed chatqna-core-frontend scanning"
echo "print all the files"
pwd
ls -lrt
echo "**************************************************************"
- name: Upload Trivy Image Report
continue-on-error: true
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: Trivy image scan report-core
path: |
sample-applications/chat-question-and-answer-core/trivy_image_scan_core-backend.html
sample-applications/chat-question-and-answer-core/trivy_image_scan_core-backend.spdx.json
sample-applications/chat-question-and-answer-core/trivy_image_scan_core-frontend.html
sample-applications/chat-question-and-answer-core/trivy_image_scan_core-frontend.spdx.json
- name: Run Bandit Security Scan
continue-on-error: true
shell: bash
run: |
echo "Running Bandit security scan..."
python -m bandit -r sample-applications/chat-question-and-answer-core/ -v --exit-zero > bandit_scan_report_summary.txt || echo "Bandit found security issues"
echo "Bandit scan completed"
- name: Upload Bandit Security Report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: bandit-security-report-core
path: |
bandit_scan_report_summary.txt
chat-question-and-answer-job:
needs: detect-changes
permissions:
contents: read
if: contains(fromJson(needs.detect-changes.outputs.changed_projects), 'sample-applications/chat-question-and-answer')
runs-on: ubuntu-22.04-32core-128GB
env:
HUGGINGFACEHUB_API_TOKEN: ${{ secrets.HUGGINGFACE_API_TOKEN }}
LLM_MODEL: Intel/neural-chat-7b-v3-3
EMBEDDING_MODEL_NAME: BAAI/bge-small-en-v1.5
RERANKER_MODEL: BAAI/bge-reranker-base
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Tools
uses: ./.github/actions/setup-tools
- name: Run Unit Tests for Core
continue-on-error: true
shell: bash
run: |
cd sample-applications/chat-question-and-answer
echo "Running unit test cases"
python3.12 -m venv venv
source venv/bin/activate
poetry install --with dev || true
#poetry add pytest-html
#source setup.sh
source setup.sh llm=TGI embed=TEI
poetry run pytest tests/unit_tests/ --html=pytest-coverage-chatqna.html
coverage run --source=. -m pytest
coverage report -m
# Install required packages
# poetry add pytest-cov pytest-html
# Run tests with coverage and HTML report in one command
#poetry run pytest tests/unit_tests/ --cov=. --cov-report=html --html=pytest-report-chatqna.html
# For a combined coverage and test report
# poetry run pytest tests/unit_tests/ --cov=. --cov-report=term --cov-report=html:coverage-html --html=pytest-report-chatqna.html
deactivate
rm -rf venv
- name: Upload Coverage Report
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: chatqna-coverage-report-qa
path: |
sample-applications/chat-question-and-answer/pytest-coverage-chatqna.html
sample-applications/chat-question-and-answer/pytest-report-chatqna.html
# sample-applications/chat-question-and-answer/htmlcov/index.html
# sample-applications/chat-question-and-answer/coverage-html/index.html
# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: '22'
- name: Install npm dependencies
continue-on-error: true
shell: bash
run: |
pwd
cd sample-applications/chat-question-and-answer/ui/react
npm install
npm install -D vitest@2.1.9
npm run test
npm run test:ui
npm run coverage
npx vitest run --reporter=html --outputFile=chatqna-ui-results.html --coverage --coverage.reporter=html --coverage.reportsDirectory=chat-qna-ui-coverage-html
- name: Upload UI Results
continue-on-error: true
uses: actions/upload-artifact@v4
if: always()
with:
name: chatqna-ui-test-results-qa
path: |
sample-applications/chat-question-and-answer/ui/react/ui-results.html
sample-applications/chat-question-and-answer/ui/react/ui-coverage-html/
- name: trivy repo scan
continue-on-error: true
shell: bash
run: |
pwd
cd sample-applications/chat-question-and-answer/
trivy --version
trivy image --download-db-only
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/html.tpl -o trivy-html.tpl
# Use the downloaded template
trivy fs . --format template --template "@trivy-html.tpl" -o "trivy_code_scan_chatqna.html"
- name: Upload trivy reports
continue-on-error: true
uses: actions/upload-artifact@v4
if: always()
with:
name: trivy-code-scan-results-chatqna
path: |
sample-applications/chat-question-and-answer/trivy_code_scan_chatqna.html
- name: ClamAV Antivirus Scan
continue-on-error: true
shell: bash
run: |
echo "Starting ClamAV scan on sample-applications/chat-question-and-answer/..."
docker run --rm \
--mount type=bind,source=./sample-applications/chat-question-and-answer/,target=/scandir \
clamav/clamav:stable \
clamscan --recursive --log=/scandir/clamav-scan-report.log \
/scandir
SCAN_EXIT_CODE=$?
sudo chown $USER:$USER sample-applications/chat-question-and-answer/clamav-scan-report.log 2>/dev/null || true
if [ $SCAN_EXIT_CODE -ne 0 ]; then
echo "ClamAV scan failed or found issues"
exit 1
fi
- name: Upload Antivirus Report
continue-on-error: true
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: antivirus-report-qa
path: sample-applications/chat-question-and-answer/clamav-scan-report.log
- name: Trivy Image Scan
continue-on-error: true
shell: bash
run: |
pwd
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/html.tpl -o trivy-html.tpl
echo "Building image chatqna-backend and scanning"
docker build -f ./sample-applications/chat-question-and-answer/Dockerfile -t chatqna-backend:latest ./sample-applications/chat-question-and-answer/
trivy image chatqna-backend:latest --ignore-unfixed --format template --template "@trivy-html.tpl" -o sample-applications/chat-question-and-answer/trivy_image_scan_chatqna_backend.html
trivy image --quiet --format spdx-json --output sample-applications/chat-question-and-answer/trivy_image_scan_chatqna_backend.spdx.json chatqna-backend:latest
echo "completed chatqna-backend scanning"
echo "**************************************************************"
echo "Building image chatqna-frontend and scanning"
docker build -t="chatqna-frontend:latest" ./sample-applications/chat-question-and-answer/ui/react
trivy image chatqna-frontend:latest --ignore-unfixed --format template --template "@trivy-html.tpl" -o sample-applications/chat-question-and-answer/trivy_image_scan_chatqna_frontend.html
trivy image --quiet --format spdx-json --output sample-applications/chat-question-and-answer/trivy_image_scan_chatqna_frontend.spdx.json chatqna-frontend:latest
echo "completed chatqna-frontend scanning"
echo "print all the files"
pwd
ls -lrt
echo "**************************************************************"
- name: Upload Trivy Image Report
continue-on-error: true
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: Trivy image scan report-qa
path: |
sample-applications/chat-question-and-answer/trivy_image_scan_chatqna_backend.html
sample-applications/chat-question-and-answer/trivy_image_scan_chatqna_backend.spdx.json
sample-applications/chat-question-and-answer/trivy_image_scan_chatqna_frontend.html
sample-applications/chat-question-and-answer/trivy_image_scan_chatqna_frontend.spdx.json
- name: Run Bandit Security Scan
continue-on-error: true
shell: bash
run: |
echo "Running Bandit security scan..."
python -m bandit -r sample-applications/chat-question-and-answer/ -v --exit-zero > bandit_scan_report_summary_chatqna.txt || echo "Bandit found security issues"
echo "Bandit scan completed"
- name: Upload Bandit Security Report
continue-on-error: true
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: bandit-security-report-qa
path: |
bandit_scan_report_summary_chatqna.txt
document-ingestion-job:
needs: detect-changes
permissions:
contents: read
if: contains(fromJson(needs.detect-changes.outputs.changed_projects), 'microservices/document-ingestion/pgvector')
runs-on: ubuntu-22.04-32core-128GB
env:
HUGGINGFACEHUB_API_TOKEN: ${{ secrets.HUGGINGFACE_API_TOKEN }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Tools
uses: ./.github/actions/setup-tools
- name: Run Unit Tests for Core
continue-on-error: true
shell: bash
run: |
cd microservices/document-ingestion/pgvector/
echo "Running unit test cases"
python3.12 -m venv venv
source venv/bin/activate
poetry install --with dev || true
poetry add pytest-html
source run.sh --nosetup
poetry run pytest tests/unit_tests/ --html=pytest-coverage-doc_ing.html
coverage run --source=. -m pytest
coverage report -m
# Install required packages
#poetry add pytest-cov pytest-html
# Run tests with coverage and HTML report in one command
#poetry run pytest tests/unit_tests/ --cov=. --cov-report=html --html=pytest-report-doc_ing.html
# For a combined coverage and test report
#poetry run pytest tests/unit_tests/ --cov=. --cov-report=term --cov-report=html:coverage-html --html=pytest-report-doc_ing.html
deactivate
rm -rf venv
- name: Upload Coverage Report
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: doc_ing-coverage-report
path: |
microservices/document-ingestion/pgvector/pytest-coverage-doc_ing.html
microservices/document-ingestion/pgvector/pytest-report-doc_ing.html
# microservices/document-ingestion/pgvector/htmlcov/index.html
# microservices/document-ingestion/pgvector/coverage-html/index.html
- name: trivy repo scan
continue-on-error: true
shell: bash
run: |
pwd
cd microservices/document-ingestion/pgvector/
trivy --version
trivy image --download-db-only
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/html.tpl -o trivy-html.tpl
# Use the downloaded template
trivy fs . --format template --template "@trivy-html.tpl" -o "trivy_code_scan_doc_ing.html"
- name: Upload trivy reports
continue-on-error: true
uses: actions/upload-artifact@v4
if: always()
with:
name: trivy-code-scan-results-doc_ing
path: |
microservices/document-ingestion/pgvector/trivy_code_scan_doc_ing.html
- name: ClamAV Antivirus Scan
continue-on-error: true
shell: bash
run: |
echo "Starting ClamAV scan on sample-applications/chat-question-and-answer/..."
docker run --rm \
--mount type=bind,source=./microservices/document-ingestion/pgvector/,target=/scandir \
clamav/clamav:stable \
clamscan --recursive --log=/scandir/clamav-scan-report.log \
/scandir
SCAN_EXIT_CODE=$?
sudo chown $USER:$USER microservices/document-ingestion/pgvector/clamav-scan-report.log 2>/dev/null || true
if [ $SCAN_EXIT_CODE -ne 0 ]; then
echo "ClamAV scan failed or found issues"
exit 1
fi
- name: Upload Antivirus Report
continue-on-error: true
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: antivirus-report-doc
path: microservices/document-ingestion/pgvector/clamav-scan-report.log
- name: Trivy Image Scan
continue-on-error: true
shell: bash
run: |
echo "print pwd"
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/html.tpl -o trivy-html.tpl
echo "Building image doc_ing-backend and scanning"
docker build -f ./microservices/document-ingestion/pgvector/docker/Dockerfile -t doc_ing-backend:latest ./microservices/document-ingestion/pgvector/
trivy image doc_ing-backend:latest --ignore-unfixed --format template --template "@trivy-html.tpl" -o microservices/document-ingestion/pgvector/trivy_image_scan_doc_ing.html
trivy image --quiet --format spdx-json --output microservices/document-ingestion/pgvector/trivy_image_scan_doc_ing.spdx.json doc_ing-backend:latest
echo "completed doc_ing-backend scanning"
- name: Upload Trivy Image Report
continue-on-error: true
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: Trivy image scan report-doc
path: |
microservices/document-ingestion/pgvector/trivy_image_scan_doc_ing.html
microservices/document-ingestion/pgvector/trivy_image_scan_doc_ing.spdx.json
- name: Run Bandit Security Scan
continue-on-error: true
shell: bash
run: |
echo "Running Bandit security scan..."
python -m bandit -r microservices/document-ingestion/ -v --exit-zero > bandit_scan_report_summary_doc_ing.txt || echo "Bandit found security issues"
echo "Bandit scan completed"
- name: Upload Bandit Security Report
continue-on-error: true
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: bandit-security-report-doc
path: |
bandit_scan_report_summary_doc_ing.txt