-
Notifications
You must be signed in to change notification settings - Fork 34
162 lines (136 loc) · 4.6 KB
/
Copy pathci.yaml
File metadata and controls
162 lines (136 loc) · 4.6 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
name: Run CI Checks
on:
pull_request:
branches:
- main
push:
branches:
- main
# Add concurrency control to cancel redundant runs
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
# NOTE: Add new jobs to `ci-final-status.needs` to make them required!
jobs:
lint-and-format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
run: pip install uv
- name: Install dependencies
run: uv sync
- name: Check formatting with Ruff
working-directory: packages/datacommons-mcp
run: uv run ruff format --check
- name: Lint with Ruff
working-directory: packages/datacommons-mcp
run: uv run ruff check
# Determines if source code has changed to avoid running subsequent jobs unnecessarily.
dc-mcp-path-filter:
runs-on: ubuntu-latest
outputs:
run_downstream_jobs: ${{ steps.filter.outputs.run_tests }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check for changed test paths
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
run_tests:
- 'packages/datacommons-mcp/datacommons_mcp/**'
- 'packages/datacommons-mcp/tests/**'
- 'packages/datacommons-mcp/pyproject.toml'
unit-tests:
runs-on: ubuntu-latest
needs: dc-mcp-path-filter
if: needs.dc-mcp-path-filter.outputs.run_downstream_jobs == 'true'
strategy:
matrix:
python-version: ["3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
run: pip install uv
- name: Install dependencies
run: uv sync
- name: Run tests with pytest. Skip eval tests.
run: uv run --extra test pytest -k "not eval"
build-and-test-wheel:
runs-on: ubuntu-latest
needs: dc-mcp-path-filter
if: needs.dc-mcp-path-filter.outputs.run_downstream_jobs == 'true'
strategy:
matrix:
python-version: ["3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
run: pip install uv
- name: Build wheel
working-directory: packages/datacommons-mcp
run: uv build
- name: Test running server from installed wheel
run: |
# Create and activate a temporary environment
uv venv wheel_test_venv
source wheel_test_venv/bin/activate
# Find the built wheel file and install it
WHEEL_FILE=$(find ${{ github.workspace }}/dist -name "*.whl")
echo "Installing wheel: $WHEEL_FILE"
uv pip install --quiet "$WHEEL_FILE"
# Start the server in the background
echo "Starting server in background, logging to server.log..."
datacommons-mcp serve http --port 8088 --skip-api-key-validation &> server.log &
SERVER_PID=$!
# Poll the server to see if it's healthy, with a 15-second timeout
echo "Waiting for server to become healthy..."
for i in {1..15}; do
if curl -s --fail http://localhost:8088/mcp/health > /dev/null; then
echo "Server started successfully!"
kill $SERVER_PID
exit 0
fi
sleep 1
done
echo "Error: Server did not start in time."
echo "--- Server Logs (server.log) ---"
cat server.log
echo "--------------------------------"
kill $SERVER_PID
exit 1
ci-final-status:
runs-on: ubuntu-latest
needs:
- lint-and-format
- unit-tests
- build-and-test-wheel
if: always() # Ensures this job runs even if depenendencies fail.
steps:
- name: Report overall CI status
run: |
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || \
"${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
echo "One or more CI checks failed or were cancelled."
exit 1
else
echo "All CI checks passed!"
exit 0
fi