forked from jsbattig/code-indexer
-
Notifications
You must be signed in to change notification settings - Fork 1
191 lines (158 loc) · 6.15 KB
/
main.yml
File metadata and controls
191 lines (158 loc) · 6.15 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
name: CI/CD with Auto Release
on:
push:
branches: [ master, main, develop, development, staging ]
pull_request:
branches: [ master, main ]
permissions:
contents: write # Allow creating tags and releases
actions: read # Allow reading workflow runs
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python3 -m pip install -e third_party/hnswlib --break-system-packages
python3 -m pip install -e ".[dev]" --break-system-packages
- name: Run parity tests
run: |
python3 -m pytest tests/integration/parity/ -v --tb=short
- name: Run server smoke tests
run: |
python3 -m pytest tests/unit/server/storage/test_factory.py tests/unit/server/mcp/test_protocol.py tests/unit/services/test_database_health_cluster.py -v --tb=short --deselect=tests/unit/server/storage/test_factory.py::TestSQLiteProtocolSatisfaction::test_dependency_map_tracking_satisfies_protocol
- name: Generate parity matrix
if: always()
run: |
python3 scripts/generate_parity_matrix.py || echo "Parity matrix generation failed (script may not exist yet)"
- name: Upload parity matrix
if: always()
uses: actions/upload-artifact@v4
with:
name: parity-matrix-py${{ matrix.python-version }}
path: docs/mcp-rest-parity-matrix.md
if-no-files-found: ignore
check-version:
runs-on: ubuntu-latest
outputs:
version_changed: ${{ steps.check_version.outputs.version_changed }}
current_version: ${{ steps.check_version.outputs.current_version }}
previous_version: ${{ steps.check_version.outputs.previous_version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Get current version
id: get_version
run: |
echo "current_version=$(python3 -c "import sys; sys.path.insert(0, 'src'); from code_indexer import __version__; print(__version__)")" >> $GITHUB_OUTPUT
- name: Check if version file changed
run: |
if git diff --name-only HEAD~1 HEAD | grep -q "src/code_indexer/__init__.py"; then
echo "version_file_changed=true" >> $GITHUB_ENV
else
echo "version_file_changed=false" >> $GITHUB_ENV
fi
- name: Get previous version
if: env.version_file_changed == 'true'
run: |
echo "previous_version=$(git show HEAD~1:src/code_indexer/__init__.py | grep '__version__' | cut -d'\"' -f2)" >> $GITHUB_ENV
- name: Check if version changed
id: check_version
run: |
current_version="${{ steps.get_version.outputs.current_version }}"
echo "current_version=$current_version" >> $GITHUB_OUTPUT
if [ "${{ env.version_file_changed }}" = "true" ]; then
previous_version="${{ env.previous_version }}"
echo "previous_version=$previous_version" >> $GITHUB_OUTPUT
if [ "$current_version" != "$previous_version" ]; then
echo "version_changed=true" >> $GITHUB_OUTPUT
echo "Version changed from $previous_version to $current_version"
else
echo "version_changed=false" >> $GITHUB_OUTPUT
echo "Version file modified but version unchanged: $current_version"
fi
else
echo "version_changed=false" >> $GITHUB_OUTPUT
echo "Version file not modified: $current_version"
fi
create-tag:
runs-on: ubuntu-latest
needs: [check-version]
if: |
needs.check-version.outputs.version_changed == 'true' &&
github.ref == 'refs/heads/development'
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Create and Push Tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Extract version
VERSION="${{ needs.check-version.outputs.current_version }}"
# Check if tag already exists on remote (pushed manually)
if git ls-remote --tags origin "refs/tags/v$VERSION" | grep -q "v$VERSION"; then
echo "Tag v$VERSION already exists on remote -- skipping creation"
exit 0
fi
# Create git tag
git config user.name github-actions
git config user.email github-actions@github.com
git tag "v$VERSION" -m "Release version $VERSION"
git push origin "v$VERSION"
echo "Created and pushed tag v$VERSION from development branch"
create-release:
runs-on: ubuntu-latest
needs: [check-version]
if: |
needs.check-version.outputs.version_changed == 'true' &&
github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python3 -m pip install build twine --break-system-packages
- name: Build package
run: |
python3 -m build
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Extract version
VERSION="${{ needs.check-version.outputs.current_version }}"
# Check if release already exists (created from prior branch push)
if gh release view "v$VERSION" &>/dev/null; then
echo "Release v$VERSION already exists -- uploading dist artifacts only"
gh release upload "v$VERSION" dist/* --clobber || true
exit 0
fi
# Create GitHub release with auto-generated notes using existing tag
gh release create "v$VERSION" \
--title "Release v$VERSION" \
--generate-notes \
--draft=false \
--prerelease=false \
dist/*
echo "Created GitHub release v$VERSION from master branch"