-
-
Notifications
You must be signed in to change notification settings - Fork 19
206 lines (185 loc) · 6.54 KB
/
lint_and_unit.yaml
File metadata and controls
206 lines (185 loc) · 6.54 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
name: Lint and unit checks
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
permissions:
contents: read
jobs:
lint:
name: Python lint with pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
requirements-dev.txt
requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Run pre-commit hooks
run: |
pre-commit run --all-files
unit:
name: Unit tests (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
needs: lint
strategy:
matrix:
include:
- arch: amd64
runner: ubuntu-latest
platform: linux/amd64
- arch: arm64
runner: ubuntu-24.04-arm
platform: linux/arm64
env:
PLATFORM: ${{ matrix.platform }}
services:
postgres:
image: postgres:11
env:
POSTGRES_PASSWORD: queridodiario
POSTGRES_USER: queridodiario
POSTGRES_DB: queridodiariodb
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
opensearch:
image: opensearchproject/opensearch:2.9.0
env:
discovery.type: single-node
plugins.security.ssl.http.enabled: false
plugins.security.disabled: true
OPENSEARCH_INITIAL_ADMIN_PASSWORD: admin
options: >-
--health-cmd "curl -s http://localhost:9200 >/dev/null || exit 1"
--health-interval 15s
--health-timeout 10s
--health-retries 20
ports:
- 9200:9200
apache-tika:
image: ghcr.io/${{ github.repository }}/apache-tika:latest
ports:
- 9998:9998
steps:
- uses: actions/checkout@v4
- name: Start MinIO
run: |
docker run -d \
--name minio \
--network host \
--health-cmd "curl -f http://localhost:9000/minio/health/live || exit 1" \
--health-interval 10s \
--health-timeout 5s \
--health-retries 5 \
-e MINIO_ROOT_USER=minio-access-key \
-e MINIO_ROOT_PASSWORD=minio-secret-key \
quay.io/minio/minio:RELEASE.2025-09-07T16-13-09Z \
server /data --console-address :9001
# Wait for MinIO to be ready
echo "Waiting for MinIO to be ready..."
timeout 60 bash -c 'until curl -sf http://localhost:9000/minio/health/live > /dev/null 2>&1; do sleep 2; done'
echo "MinIO is ready"
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Create MinIO bucket
run: |
# Wait for MinIO to be ready
for i in {1..30}; do
if curl -sf http://localhost:9000/minio/health/live > /dev/null 2>&1; then
echo "MinIO is ready"
break
fi
echo "Waiting for MinIO... ($i/30)"
sleep 2
done
# Detect architecture and download appropriate MinIO client
ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
MC_URL="https://dl.min.io/client/mc/release/linux-arm64/mc"
else
MC_URL="https://dl.min.io/client/mc/release/linux-amd64/mc"
fi
echo "Downloading MinIO client for architecture: $ARCH"
curl -sLo /tmp/mc "$MC_URL"
chmod +x /tmp/mc
# Configure MinIO client
/tmp/mc alias set minio http://localhost:9000 minio-access-key minio-secret-key
# Create bucket if it doesn't exist
/tmp/mc mb minio/queridodiariobucket --ignore-existing || true
echo "MinIO bucket created successfully"
- name: Create OpenSearch index
timeout-minutes: 2
run: |
echo "=== Creating OpenSearch index ==="
echo "OpenSearch host: http://localhost:9200"
echo "Testing connectivity..."
curl -v http://localhost:9200/_cluster/health || echo "OpenSearch not responding"
echo "Running init script..."
chmod +x init-scripts/opensearch/create-opensearch-index.sh
OPENSEARCH_HOST=http://localhost:9200 \
OPENSEARCH_USER=admin \
OPENSEARCH_PASSWORD=admin \
INDEX_NAME=querido-diario \
./init-scripts/opensearch/create-opensearch-index.sh
echo "=== OpenSearch index creation completed ==="
- name: Run unit tests
timeout-minutes: 5
env:
PYTHONPATH: ${{ github.workspace }}
PYTHONUNBUFFERED: 1
POSTGRES_PASSWORD: queridodiario
POSTGRES_USER: queridodiario
POSTGRES_DB: queridodiariodb
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
STORAGE_REGION: us-east-1
STORAGE_ENDPOINT: http://localhost:9000
STORAGE_ACCESS_KEY: minio-access-key
STORAGE_ACCESS_SECRET: minio-secret-key
STORAGE_BUCKET: queridodiariobucket
OPENSEARCH_HOST: http://localhost:9200
OPENSEARCH_INDEX: querido-diario
OPENSEARCH_USER: admin
OPENSEARCH_PASSWORD: admin
APACHE_TIKA_SERVER: http://localhost:9998
DEBUG: 1
HF_HUB_OFFLINE: 1
TRANSFORMERS_OFFLINE: 1
SENTENCE_TRANSFORMERS_HOME: /tmp/sentence_transformers
run: |
echo "========================================="
echo "🧪 STARTING INSTRUMENTED TEST RUN"
echo "========================================="
echo "Working directory: $(pwd)"
echo "Python: $(which python)"
echo "Python version: $(python --version)"
echo "Time: $(date)"
echo ""
# Make runner executable
chmod +x instrumented_test_runner.py
# Run with our instrumented runner
python instrumented_test_runner.py
echo ""
echo "========================================="
echo "Test run completed at: $(date)"
echo "========================================="