-
Notifications
You must be signed in to change notification settings - Fork 5
210 lines (180 loc) · 5.65 KB
/
ci.yml
File metadata and controls
210 lines (180 loc) · 5.65 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
name: CI
on:
push:
branches: [ main, develop ]
paths-ignore:
- '**/*.md'
- 'docs/**'
pull_request:
branches: [ main, develop ]
paths-ignore:
- '**/*.md'
- 'docs/**'
# Cancel previous runs for the same ref to save CI minutes.
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
PYTHONDONTWRITEBYTECODE: 1
PIP_DISABLE_PIP_VERSION_CHECK: 1
jobs:
test:
name: Test Suite (${{ matrix.os }}, python=${{ matrix.python }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
python: [ '3.11' ]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ./gts
pip install pytest pytest-cov ruff mypy httpx
- name: Show Python version
run: python --version
# Formatting check (fast fail for style issues)
- name: ruff format (check)
run: ruff format --check gts/src
# Linting
- name: ruff check
run: ruff check gts/src
# Type checking
- name: mypy
run: mypy gts/src/gts --ignore-missing-imports
continue-on-error: true
# Unit tests (skip if no tests exist)
- name: pytest
shell: bash
run: |
if [ -n "$(find tests/ -name 'test_*.py' -o -name '*_test.py' 2>/dev/null)" ]; then
pytest tests/ -v --no-header
else
echo "No unit tests found in tests/, skipping..."
fi
security:
name: Security (pip-audit on Ubuntu)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ./gts
pip install pip-audit
# Run security audit but do not fail CI (as requested).
- name: pip-audit
run: pip-audit
continue-on-error: true
coverage:
name: Code Coverage (pytest-cov)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ./gts
pip install pytest pytest-cov
# Generate coverage report (skip if no tests exist)
- name: Coverage
run: |
if [ -n "$(find tests/ -name 'test_*.py' -o -name '*_test.py' 2>/dev/null)" ]; then
pytest tests/ --cov=gts --cov-report=xml --cov-report=term
else
echo "No unit tests found in tests/, skipping coverage..."
fi
# Upload to Codecov; do not fail CI if Codecov is down/misconfigured.
- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
files: coverage.xml
fail_ci_if_error: false
# token: ${{ secrets.CODECOV_TOKEN }} # Uncomment if required for private repos
e2e:
name: E2E Tests (gts-spec)
runs-on: ubuntu-latest
env:
PYTHONDONTWRITEBYTECODE: 1
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Install httprunner first to get pydantic<1.9 constraint
pip install httprunner pytest requests
# Then install gts (will use already-installed pydantic v1)
pip install -e ./gts
- name: Run e2e tests
run: |
# Start server in background with logs
gts server --port 8000 > .server.log 2>&1 &
SERVER_PID=$!
echo "Started GTS server with PID $SERVER_PID"
# Wait for server to be ready
echo "Waiting for GTS server to start..."
for i in $(seq 1 30); do
if ! kill -0 $SERVER_PID 2>/dev/null; then
echo "ERROR: Server process died unexpectedly"
echo "=== Server logs ==="
cat .server.log || true
exit 1
fi
if curl -sf http://127.0.0.1:8000/entities > /dev/null 2>&1; then
echo "GTS server is ready!"
break
fi
if [ $i -eq 30 ]; then
echo "ERROR: GTS server failed to start within 30 seconds"
echo "=== Server logs ==="
cat .server.log || true
kill $SERVER_PID 2>/dev/null || true
exit 1
fi
echo "Attempt $i/30: Server not ready yet, waiting..."
sleep 1
done
# Run tests
pytest -p no:cacheprovider ./.gts-spec/tests -v
TEST_EXIT=$?
# Stop server
echo "Stopping GTS server..."
kill $SERVER_PID 2>/dev/null || true
wait $SERVER_PID 2>/dev/null || true
exit $TEST_EXIT