-
Notifications
You must be signed in to change notification settings - Fork 3
215 lines (176 loc) · 5.77 KB
/
ci.yml
File metadata and controls
215 lines (176 loc) · 5.77 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
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
jobs:
lint-and-format:
name: Lint & Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.11"
- name: Set up Python
run: uv python install 3.14
- name: Install dependencies
run: uv sync
- name: Run ruff linting
run: uv run ruff check
- name: Run ruff format check
run: uv run ruff format --check
build-test:
name: Build Test
runs-on: ubuntu-latest
needs: lint-and-format
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.11"
- name: Set up Python
run: uv python install 3.14
- name: Install dependencies
run: uv sync
- name: Test package build
run: uv build
- name: Test package installation
run: uv pip install dist/*.whl
- name: Test application startup
run: |
set -euo pipefail
# Start the server in background with dummy env vars
export FIREFLY_BASE_URL="https://demo.firefly-iii.org"
export FIREFLY_TOKEN="dummy_token_for_ci_testing"
export MCP_TRANSPORT="http"
# Avoid log buffering when redirecting to a file
export PYTHONUNBUFFERED="1"
# Run server in background and capture output
timeout 30s uv run lampyrid > startup.log 2>&1 &
PID=$!
cleanup() {
kill "$PID" 2>/dev/null || true
# Also terminate any child process spawned by timeout
pkill -TERM -P "$PID" 2>/dev/null || true
}
trap cleanup EXIT
# Wait for startup (max 30 seconds to match timeout)
echo "Waiting for server to start..."
for i in {1..30}; do
if grep -q "Application startup complete" startup.log; then
echo "✓ Server started successfully!"
cat startup.log
exit 0
fi
# Abort early if process already exited
if ! kill -0 "$PID" 2>/dev/null; then
echo "✗ Server process exited before completing startup"
echo "=== Server output ==="
cat startup.log || true
exit 1
fi
sleep 1
done
# If we get here, startup failed
echo "✗ Server failed to start within timeout"
echo "=== Server output ==="
cat startup.log
exit 1
docker-build-test:
name: Docker Build Test
runs-on: ubuntu-latest
needs: lint-and-format
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
push: false
load: true
tags: lampyrid:test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test Docker container startup
run: |
set -euo pipefail
# Setup cleanup trap
cleanup() {
docker rm -f lampyrid-test >/dev/null 2>&1 || true
}
trap cleanup EXIT
# Start container in background with dummy env vars
echo "Starting container..."
docker run -d --name lampyrid-test \
-e FIREFLY_BASE_URL="https://demo.firefly-iii.org" \
-e FIREFLY_TOKEN="dummy_token_for_ci_testing" \
-e MCP_TRANSPORT="http" \
lampyrid:test
# Wait for startup (max 20 seconds)
echo "Waiting for container to start..."
for i in {1..20}; do
if docker logs lampyrid-test 2>&1 | grep -q "Application startup complete"; then
echo "✓ Container started successfully!"
echo "=== Container logs ==="
docker logs lampyrid-test 2>&1
exit 0
fi
# Early exit if container died
if ! docker ps -q --filter "name=lampyrid-test" | grep -q .; then
echo "✗ Container exited unexpectedly"
echo "=== Container logs ==="
docker logs lampyrid-test 2>&1
exit 1
fi
sleep 1
done
# If we get here, startup failed
echo "✗ Container failed to start within timeout"
echo "=== Container logs ==="
docker logs lampyrid-test 2>&1
exit 1
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
needs: [lint-and-format, build-test]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.11"
- name: Set up Python
run: uv python install 3.14
- name: Install dependencies
run: uv sync
- name: Setup Firefly III test environment
run: |
set -euo pipefail
chmod +x tests/setup_test_env.sh
./tests/setup_test_env.sh
- name: Run integration tests
run: |
uv run pytest tests/ -v --cov=src/lampyrid --cov-report=xml --cov-report=term
- name: Upload coverage report
uses: codecov/codecov-action@v4
if: always()
with:
files: ./coverage.xml
flags: integration
name: integration-tests
token: ${{ secrets.CODECOV_TOKEN }}
- name: Stop Firefly III
if: always()
run: |
docker compose -f docker-compose.test.yml down -v