-
Notifications
You must be signed in to change notification settings - Fork 0
255 lines (218 loc) · 6.84 KB
/
ci.yml
File metadata and controls
255 lines (218 loc) · 6.84 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
252
253
254
255
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# Format check - fastest, runs first
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
# Clippy linting
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-clippy-
- name: Run Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
# Unit tests - no external dependencies
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-test-
- name: Run unit tests
run: cargo test --workspace --exclude codegraph-integration-tests
- name: Run integration tests (no external deps)
run: cargo test -p codegraph-integration-tests
# Build check
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Build release
run: cargo build --release
# Integration tests with Docker services
integration:
name: Integration Tests
runs-on: ubuntu-latest
needs: [test] # Run after unit tests pass
services:
neo4j:
image: neo4j:5.15-community
ports:
- 7687:7687
- 7474:7474
env:
NEO4J_AUTH: neo4j/codegraph123
NEO4J_PLUGINS: '["apoc"]'
options: >-
--health-cmd "cypher-shell -u neo4j -p codegraph123 'RETURN 1'"
--health-interval 10s
--health-timeout 5s
--health-retries 10
qdrant:
image: qdrant/qdrant:v1.7.4
ports:
- 6333:6333
- 6334:6334
options: >-
--health-cmd "curl -f http://localhost:6333/health || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-integration-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-integration-
- name: Wait for services
run: |
echo "Waiting for Neo4j..."
timeout 60 bash -c 'until nc -z localhost 7687; do sleep 1; done'
echo "Waiting for Qdrant..."
timeout 60 bash -c 'until nc -z localhost 6334; do sleep 1; done'
echo "Services ready!"
- name: Run integration tests with databases
env:
NEO4J_URI: bolt://localhost:7687
NEO4J_USER: neo4j
NEO4J_PASSWORD: codegraph123
QDRANT_URL: http://localhost:6334
run: cargo test -p codegraph-integration-tests -- --ignored --test-threads=1
# Code coverage with tarpaulin
coverage:
name: Coverage
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-coverage-
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
- name: Run coverage on critical crates
run: |
cargo tarpaulin \
--packages codegraph-extraction codegraph-retrieval codegraph-generation codegraph-graph codegraph-feedback \
--out xml --out html \
--output-dir coverage \
--ignore-tests \
--timeout 300
- name: Check coverage threshold (60%)
run: |
COVERAGE=$(cargo tarpaulin \
--packages codegraph-extraction codegraph-retrieval codegraph-generation codegraph-graph codegraph-feedback \
--ignore-tests \
--timeout 300 2>&1 | grep -oP '\d+\.\d+(?=% coverage)' | tail -1)
echo "Coverage: ${COVERAGE}%"
if (( $(echo "$COVERAGE < 60" | bc -l) )); then
echo "Coverage ${COVERAGE}% is below 60% threshold"
exit 1
fi
echo "Coverage ${COVERAGE}% meets 60% threshold"
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/
- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
files: coverage/cobertura.xml
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# Documentation build
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-docs-
- name: Build documentation
run: cargo doc --workspace --no-deps
env:
RUSTDOCFLAGS: -D warnings