forked from TracecatHQ/tracecat
-
Notifications
You must be signed in to change notification settings - Fork 0
250 lines (215 loc) · 7.09 KB
/
Copy pathtest-python.yml
File metadata and controls
250 lines (215 loc) · 7.09 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
name: Run Python tests
on:
push:
branches: ["main"]
paths:
- tracecat/**
- registry/**
- tests/**
- packages/tracecat-ee/**
- packages/tracecat-registry/**
- pyproject.toml
- uv.lock
- Dockerfile
- docker-compose.yml
- docker-compose.dev.yml
- .github/workflows/test-python.yml
pull_request:
branches: ["main", "staging"]
paths:
- tracecat/**
- registry/**
- tests/**
- packages/tracecat-ee/**
- packages/tracecat-registry/**
- pyproject.toml
- uv.lock
- Dockerfile
- docker-compose.yml
- docker-compose.dev.yml
- .github/workflows/test-python.yml
workflow_dispatch:
inputs:
git-ref:
description: "Git Ref (Optional)"
required: true
permissions:
contents: read
packages: write
env:
UV_SYSTEM_PYTHON: 1
DENO_VERSION: "2.3.5"
PYODIDE_VERSION: "0.27.6"
jobs:
test-custom-registry-install:
runs-on: blacksmith-4vcpu-ubuntu-2204
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.git-ref }}
- name: Install uv
uses: useblacksmith/setup-uv@v4
with:
version: "0.9.7"
- name: Set up Python 3.12
uses: useblacksmith/setup-python@v6
with:
python-version: "3.12"
- name: Clone custom registry starter
run: |
git clone https://github.com/TracecatHQ/custom-integrations-starter-kit
cd custom-integrations-starter-kit
- name: Install dependencies
run: uv sync --frozen
test-workflow-codec:
runs-on: blacksmith-4vcpu-ubuntu-2204
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.git-ref }}
- name: Install uv
uses: useblacksmith/setup-uv@v4
with:
version: "0.9.7"
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Set up Python 3.12
uses: useblacksmith/setup-python@v6
with:
python-version: "3.12"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Run environment setup script
run: |
echo "y
localhost
n
test@tracecat.com" | bash env.sh
- name: Start core Docker services
env:
COMPOSE_BAKE: "true"
TRACECAT__UNSAFE_DISABLE_SM_MASKING: "true"
run: |
docker compose -f docker-compose.dev.yml up -d temporal api worker executor postgres_db caddy
# Wait for services to become healthy
echo "Waiting for services to become healthy..."
timeout 300 bash -c '
while true; do
if docker compose -f docker-compose.dev.yml ps --format json | jq -r ".[].Health" | grep -v "healthy" | grep -q "starting\|unhealthy"; then
echo "Waiting for services to be healthy..."
sleep 5
else
echo "All services are healthy"
break
fi
done
'
# Show final service status
docker compose -f docker-compose.dev.yml ps
- name: Install dependencies
run: uv sync --frozen
- name: Run workflow tests with compression
env:
TRACECAT__SYSTEM_PATH: "/usr/local/bin:/usr/bin:/bin"
# Enable compression
TRACECAT__CONTEXT_COMPRESSION_ENABLED: true
# Apply unconditionally
TRACECAT__CONTEXT_COMPRESSION_THRESHOLD_KB: 0
run: uv run pytest tests/unit/test_workflows.py -ra
test-all:
runs-on: blacksmith-4vcpu-ubuntu-2204
timeout-minutes: 60
strategy:
matrix:
test_group:
- unit
- registry
- regression
# - ee # TODO: re-enable this when we have tests
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.git-ref }}
- name: Install uv
uses: useblacksmith/setup-uv@v4
with:
version: "0.9.7"
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Set up Python 3.12
uses: useblacksmith/setup-python@v6
with:
python-version: "3.12"
- name: Install Deno
uses: denoland/setup-deno@v2.0.3
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Cache Deno dependencies
uses: actions/cache@v3
with:
path: |
~/.deno
~/.cache/deno
node_modules
key: ${{ runner.os }}-deno-${{ env.DENO_VERSION }}-pyodide-${{ env.PYODIDE_VERSION }}
- name: Warm up Pyodide
run: |
# Create a simple script to pre-cache pyodide
mkdir -p node_modules
cat > warmup.js << 'EOF'
import { loadPyodide } from "npm:pyodide@${{ env.PYODIDE_VERSION }}";
async function main() {
console.log("Loading Pyodide...");
const pyodide = await loadPyodide();
console.log("Pyodide loaded successfully");
console.log("Python version:", await pyodide.runPythonAsync("import sys; sys.version"));
}
main().catch(console.error);
EOF
# Run with minimal permissions
deno run -N -R=node_modules -W=node_modules --node-modules-dir=auto warmup.js
# Set environment variables for tests
echo "DENO_DIR=$HOME/.deno" >> $GITHUB_ENV
echo "NODE_MODULES_DIR=$(pwd)/node_modules" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Install kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
kind version
- name: Create kind cluster
run: |
kind create cluster --name tracecat-ci
kubectl cluster-info --context kind-tracecat-ci
kubectl get nodes
- name: Run environment setup script
run: |
echo "y
localhost
n
test@tracecat.com" | bash env.sh
- name: Start core Docker services
env:
COMPOSE_BAKE: "true"
TRACECAT__UNSAFE_DISABLE_SM_MASKING: "true"
run: docker compose -f docker-compose.dev.yml up -d temporal api worker executor postgres_db caddy minio
- name: Install dependencies
run: uv sync --frozen
- name: Run tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
TRACECAT__SYSTEM_PATH: "/usr/local/bin:/usr/bin:/bin"
run: |
if [ "${{ matrix.test_group }}" = "ee" ]; then
uv run pytest packages/tracecat-ee/tests/ -ra
elif [ "${{ matrix.test_group }}" = "registry" ]; then
uv run pytest tests/${{ matrix.test_group }} -n auto -ra
else
uv run pytest tests/${{ matrix.test_group }} -ra
fi