forked from flare-foundation/flare-ai-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
231 lines (195 loc) · 7.41 KB
/
docker-scripts.yml
File metadata and controls
231 lines (195 loc) · 7.41 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
name: Docker Scripts Validation
on:
push:
branches: ["main"]
paths:
- "Dockerfile"
- "scripts/**"
- "pyproject.toml"
- "uv.lock"
pull_request:
branches: ["main"]
paths:
- "Dockerfile"
- "scripts/**"
- "pyproject.toml"
- "uv.lock"
permissions:
contents: read
jobs:
validate-docker-scripts:
runs-on: ubuntu-latest
strategy:
matrix:
script:
- name: "PDF Ingestion"
extras: "pdf"
script_file: "ingest_pdf.py"
test_timeout: "300" # 5 minutes
env:
# Test environment variables
LOG_LEVEL: INFO
AGENT__GEMINI_MODEL: "gemini-2.0-flash"
AGENT__GEMINI_API_KEY: ${{ secrets.AGENT__GEMINI_API_KEY }}
ECOSYSTEM__WEB3_PROVIDER_URL: "https://stylish-light-theorem.flare-mainnet.quiknode.pro/ext/bc/C/rpc"
INGESTION__CHUNK_SIZE: 5000
TEE__SIMULATE_ATTESTATION_TOKEN: true
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image for ${{ matrix.script.name }}
run: |
docker build \
--build-arg EXTRAS=${{ matrix.script.extras }} \
--build-arg SCRIPT=${{ matrix.script.script_file }} \
--tag fai-script-${{ matrix.script.extras }} \
--cache-from type=gha \
--cache-to type=gha,mode=max \
.
- name: Validate script exists in image
run: |
docker run --rm fai-script-${{ matrix.script.extras }} \
test -f "/app/scripts/${{ matrix.script.script_file }}"
- name: Test script startup (dry run)
timeout-minutes: 5
run: |
# Simple validation that the script exists and dependencies are available
docker run --rm \
-e LOG_LEVEL="$LOG_LEVEL" \
-e AGENT__GEMINI_MODEL="$AGENT__GEMINI_MODEL" \
-e AGENT__GEMINI_API_KEY="$AGENT__GEMINI_API_KEY" \
-e ECOSYSTEM__WEB3_PROVIDER_URL="$ECOSYSTEM__WEB3_PROVIDER_URL" \
-e INGESTION__CHUNK_SIZE="$INGESTION__CHUNK_SIZE" \
-e TEE__SIMULATE_ATTESTATION_TOKEN="$TEE__SIMULATE_ATTESTATION_TOKEN" \
fai-script-${{ matrix.script.extras }} \
python -c "
import sys
import os
# Test that script file exists
script_path = '/app/scripts/${{ matrix.script.script_file }}'
if not os.path.exists(script_path):
print(f'❌ Script not found: {script_path}')
sys.exit(1)
print(f'✅ Script exists: {script_path}')
# Test that required dependencies are available
if '${{ matrix.script.extras }}' == 'pdf':
try:
import PIL
import fitz # pymupdf
import pytesseract
print('✅ PDF dependencies available')
except ImportError as e:
print(f'❌ PDF dependency missing: {e}')
sys.exit(1)
print('✅ Script validation completed successfully')
"
- name: Test container health
run: |
# Test that the container can start and the Python environment is healthy
docker run --rm fai-script-${{ matrix.script.extras }} \
python -c "
import sys
print(f'Python version: {sys.version}')
print(f'Python path: {sys.path}')
# Test core dependencies (some modules may require optional deps)
try:
import flare_ai_kit
print('✅ flare-ai-kit imported successfully')
except ImportError as e:
print(f'⚠️ flare-ai-kit import issue (may need more extras): {e}')
# Test basic Python packages instead
import httpx, pydantic, structlog
print('✅ Core Python dependencies available')
# Test that uv environment is working
import subprocess
result = subprocess.run(['/app/.venv/bin/python', '--version'],
capture_output=True, text=True)
print(f'Virtual env Python: {result.stdout.strip()}')
print('✅ Container health check passed')
"
- name: Test script dependencies for ${{ matrix.script.name }}
run: |
# Test that the specific extras are properly installed
docker run --rm fai-script-${{ matrix.script.extras }} \
python -c "
import sys
extras = '${{ matrix.script.extras }}'
print(f'Testing dependencies for extras: {extras}')
if 'pdf' in extras:
try:
import PIL
import fitz
import pytesseract
print('✅ PDF dependencies (PIL, fitz, pytesseract) available')
except ImportError as e:
print(f'❌ PDF dependency missing: {e}')
sys.exit(1)
if 'rag' in extras:
try:
import qdrant_client
import dulwich
print('✅ RAG dependencies (qdrant_client, dulwich) available')
except ImportError as e:
print(f'❌ RAG dependency missing: {e}')
sys.exit(1)
if 'a2a' in extras:
try:
import fastapi
print('✅ A2A dependencies (fastapi) available')
except ImportError as e:
print(f'❌ A2A dependency missing: {e}')
sys.exit(1)
print('✅ All expected dependencies are available')
"
validate-build-args:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Test build without extras
run: |
docker build \
--build-arg SCRIPT=ingest_pdf.py \
--tag fai-script-base \
.
- name: Test build with multiple extras
run: |
docker build \
--build-arg EXTRAS=pdf,rag \
--build-arg SCRIPT=ingest_pdf.py \
--tag fai-script-multi \
.
- name: Validate multi-extras build
run: |
docker run --rm fai-script-multi \
python -c "
import PIL, fitz, pytesseract # PDF deps
import qdrant_client, dulwich # RAG deps
print('✅ Multiple extras build successful')
"
validate-documentation:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Check documentation exists
run: |
test -f docs/docker_scripts_guide.md
echo "✅ Docker scripts guide exists"
- name: Validate README updates
run: |
grep -q "parametric Dockerfile" README.md
grep -q "EXTRAS" README.md
grep -q "docker_scripts_guide.md" README.md
echo "✅ README contains Docker scripts documentation"
- name: Check scripts directory structure
run: |
test -d scripts
test -f scripts/ingest_pdf.py
test -d scripts/data
test -f scripts/data/create_sample_invoice.py
echo "✅ Scripts directory structure is correct"