-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (118 loc) · 4.01 KB
/
ci.yml
File metadata and controls
142 lines (118 loc) · 4.01 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
name: APEX CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:
permissions:
contents: read
defaults:
run:
working-directory: TFT-main
jobs:
lint:
name: Lint & Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install black flake8 mypy yamllint
- name: Check formatting (black)
run: black --check . --exclude '/(\.git|__pycache__|venv|\.venv|lightning_logs)/'
- name: Lint (flake8)
continue-on-error: true
run: flake8 . --max-line-length 120 --exclude .git,__pycache__,venv,.venv,lightning_logs,advanced_copilot_prompts.py
- name: Type check (mypy) — warning only
continue-on-error: true
run: mypy . --ignore-missing-imports --no-error-summary --exclude '(venv|\.venv|lightning_logs)'
- name: YAML lint
continue-on-error: true
run: |
yamllint -d "{extends: default, rules: {line-length: {max: 200}, truthy: disable}}" \
.github/workflows/*.yml \
monitoring/prometheus/*.yml \
monitoring/grafana/datasources/*.yml \
docker-compose.yml
test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Run tests with coverage
run: |
pytest tests/ -v --tb=short --junitxml=test-results.xml \
--ignore=tests/test_api_playwright.py \
--ignore=tests/test_dashboard_browser.py \
--ignore=tests/test_chaos.py \
--ignore=tests/test_database_full.py \
--cov=models --cov=strategies --cov=trading --cov=services \
--cov-report=term-missing --cov-report=xml:coverage.xml \
--cov-fail-under=40
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
TFT-main/test-results.xml
TFT-main/coverage.xml
retention-days: 30
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pip-audit detect-secrets
- name: Check for vulnerable dependencies
continue-on-error: true
run: pip-audit --strict
- name: Scan for leaked secrets
continue-on-error: true
run: detect-secrets scan . --exclude-files '\.env$' --exclude-files '\.env\.example$'
docker:
name: Docker Build
runs-on: ubuntu-latest
continue-on-error: true
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
needs: [lint, test]
steps:
- uses: actions/checkout@v4
- name: Create external network
run: docker network create tft_network || true
- name: Build images
run: docker compose build --no-cache
- name: Verify containers start
run: |
docker compose up -d
sleep 10
EXITED=$(docker compose ps --filter "status=exited" -q | wc -l)
if [ "$EXITED" -gt 0 ]; then
echo "::warning::$EXITED container(s) exited unexpectedly"
docker compose logs --tail=20
fi
docker compose down