-
Notifications
You must be signed in to change notification settings - Fork 29
251 lines (223 loc) · 9.62 KB
/
Copy pathci-fast.yml
File metadata and controls
251 lines (223 loc) · 9.62 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
name: Fast CI (GitHub Runners)
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: read
jobs:
lint:
name: Lint & Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Install linting dependencies
run: |
uv pip install --system ruff
- name: Run Ruff linter
run: |
RUFF_TARGETS="rl_trading_agent_binance/hybrid_prompt.py rl_trading_agent_binance/trade_binance_live.py evaluate_binance_lora_candidate.py scripts/evaluate_binance_lora_candidate.py trltraining tests/test_hybrid_allocation_prompt.py tests/test_hybrid_prompt_parsing.py tests/test_rl_only_fallback.py tests/test_evaluate_binance_lora_candidate.py tests/test_validate_hybrid_cycle_snapshots.py tests/test_trltraining.py"
ruff check $RUFF_TARGETS --output-format=github
- name: Run Ruff format check
run: |
RUFF_TARGETS="rl_trading_agent_binance/hybrid_prompt.py rl_trading_agent_binance/trade_binance_live.py evaluate_binance_lora_candidate.py scripts/evaluate_binance_lora_candidate.py trltraining tests/test_hybrid_allocation_prompt.py tests/test_hybrid_prompt_parsing.py tests/test_rl_only_fallback.py tests/test_evaluate_binance_lora_candidate.py tests/test_validate_hybrid_cycle_snapshots.py tests/test_trltraining.py"
ruff format --check $RUFF_TARGETS
- name: Report to CI Sentinel
if: always()
env:
CI_SENTINEL_ID: ${{ vars.CI_SENTINEL_ID }}
CI_SENTINEL_KEY: ${{ secrets.CODEX_INFINITY_API_KEY }}
run: |
if [ -z "$CI_SENTINEL_ID" ] || [ -z "$CI_SENTINEL_KEY" ]; then
echo "CI Sentinel not configured, skipping report"
exit 0
fi
# Collect failure output from previous steps
FAILURE_OUTPUT=""
if [ "${{ job.status }}" = "failure" ]; then
FAILURE_OUTPUT=$(cat /tmp/ci-failure-output.txt 2>/dev/null | tail -c 12288 || echo "See GitHub Actions logs")
fi
curl -sf -X POST "https://codex-infinity.com/api/ci-sentinels/${CI_SENTINEL_ID}/events" \
-H "Authorization: Bearer ${CI_SENTINEL_KEY}" \
-H "Content-Type: application/json" \
-d "{
\"external_id\": \"${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}\",
\"repo\": \"${GITHUB_REPOSITORY}\",
\"branch\": \"${GITHUB_REF_NAME}\",
\"commit_sha\": \"${GITHUB_SHA}\",
\"workflow\": \"${GITHUB_WORKFLOW}\",
\"job_name\": \"${GITHUB_JOB}\",
\"run_number\": ${GITHUB_RUN_NUMBER},
\"run_attempt\": ${GITHUB_RUN_ATTEMPT},
\"status\": \"completed\",
\"conclusion\": \"${{ job.status }}\",
\"logs_url\": \"https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}\",
\"failure_output\": $(echo "$FAILURE_OUTPUT" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))' 2>/dev/null || echo '\"\"')
}" || echo "Warning: Failed to report to CI Sentinel"
fast-unit-tests:
name: Fast Unit Tests (CPU)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.13"]
env:
# CI mode flags
CI: "1"
FAST_CI: "1"
CPU_ONLY: "1"
FAST_SIMULATE: "1"
# Market simulator flags
MARKETSIM_ALLOW_MOCK_ANALYTICS: "1"
MARKETSIM_SKIP_REAL_IMPORT: "1"
MARKETSIM_ALLOW_CPU_FALLBACK: "1"
# Trading flags
ALP_PAPER: "1"
PYTHONUNBUFFERED: "1"
# Skip heavy dependencies for unit tests
SKIP_TORCH_CHECK: "0"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1 # Shallow clone for faster checkout
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: |
requirements.txt
requirements-ci.txt
- name: Install CPU-only dependencies
run: |
# Install all dependencies from CPU-only requirements
uv pip install --system --requirement requirements-ci.txt
uv pip install --system pytest-cov
- name: Run fast unit tests with coverage
run: |
python -m pytest \
-v \
-m "unit and not slow and not model_required and not cuda_required" \
--tb=short \
--maxfail=10 \
--cov=scripts --cov=src --cov=trade_daily_stock_prod \
--cov-report=term-missing \
--cov-report=html:htmlcov \
tests/
- name: Run smoke tests (minimal model tests)
continue-on-error: true
run: |
python -m pytest \
-v \
-m "smoke and model_required and not cuda_required" \
--tb=short \
--maxfail=3 \
tests/
- name: Report to CI Sentinel
if: always()
env:
CI_SENTINEL_ID: ${{ vars.CI_SENTINEL_ID }}
CI_SENTINEL_KEY: ${{ secrets.CODEX_INFINITY_API_KEY }}
run: |
if [ -z "$CI_SENTINEL_ID" ] || [ -z "$CI_SENTINEL_KEY" ]; then
echo "CI Sentinel not configured, skipping report"
exit 0
fi
# Collect failure output from previous steps
FAILURE_OUTPUT=""
if [ "${{ job.status }}" = "failure" ]; then
FAILURE_OUTPUT=$(cat /tmp/ci-failure-output.txt 2>/dev/null | tail -c 12288 || echo "See GitHub Actions logs")
fi
curl -sf -X POST "https://codex-infinity.com/api/ci-sentinels/${CI_SENTINEL_ID}/events" \
-H "Authorization: Bearer ${CI_SENTINEL_KEY}" \
-H "Content-Type: application/json" \
-d "{
\"external_id\": \"${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}\",
\"repo\": \"${GITHUB_REPOSITORY}\",
\"branch\": \"${GITHUB_REF_NAME}\",
\"commit_sha\": \"${GITHUB_SHA}\",
\"workflow\": \"${GITHUB_WORKFLOW}\",
\"job_name\": \"${GITHUB_JOB}\",
\"run_number\": ${GITHUB_RUN_NUMBER},
\"run_attempt\": ${GITHUB_RUN_ATTEMPT},
\"status\": \"completed\",
\"conclusion\": \"${{ job.status }}\",
\"logs_url\": \"https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}\",
\"failure_output\": $(echo "$FAILURE_OUTPUT" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))' 2>/dev/null || echo '\"\"')
}" || echo "Warning: Failed to report to CI Sentinel"
type-check:
name: Type Checking
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: requirements-ci.txt
- name: Install dependencies
run: |
uv pip install --system --requirement requirements-ci.txt
uv pip install --system ty pyright
- name: Type check with ty
run: |
ty check \
rl_trading_agent_binance/hybrid_prompt.py \
rl_trading_agent_binance/trade_binance_live.py \
evaluate_binance_lora_candidate.py \
scripts/evaluate_binance_lora_candidate.py \
trltraining
- name: Type check with Pyright
continue-on-error: true
run: python -m pyright src
- name: Report to CI Sentinel
if: always()
env:
CI_SENTINEL_ID: ${{ vars.CI_SENTINEL_ID }}
CI_SENTINEL_KEY: ${{ secrets.CODEX_INFINITY_API_KEY }}
run: |
if [ -z "$CI_SENTINEL_ID" ] || [ -z "$CI_SENTINEL_KEY" ]; then
echo "CI Sentinel not configured, skipping report"
exit 0
fi
# Collect failure output from previous steps
FAILURE_OUTPUT=""
if [ "${{ job.status }}" = "failure" ]; then
FAILURE_OUTPUT=$(cat /tmp/ci-failure-output.txt 2>/dev/null | tail -c 12288 || echo "See GitHub Actions logs")
fi
curl -sf -X POST "https://codex-infinity.com/api/ci-sentinels/${CI_SENTINEL_ID}/events" \
-H "Authorization: Bearer ${CI_SENTINEL_KEY}" \
-H "Content-Type: application/json" \
-d "{
\"external_id\": \"${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}\",
\"repo\": \"${GITHUB_REPOSITORY}\",
\"branch\": \"${GITHUB_REF_NAME}\",
\"commit_sha\": \"${GITHUB_SHA}\",
\"workflow\": \"${GITHUB_WORKFLOW}\",
\"job_name\": \"${GITHUB_JOB}\",
\"run_number\": ${GITHUB_RUN_NUMBER},
\"run_attempt\": ${GITHUB_RUN_ATTEMPT},
\"status\": \"completed\",
\"conclusion\": \"${{ job.status }}\",
\"logs_url\": \"https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}\",
\"failure_output\": $(echo "$FAILURE_OUTPUT" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))' 2>/dev/null || echo '\"\"')
}" || echo "Warning: Failed to report to CI Sentinel"