-
Notifications
You must be signed in to change notification settings - Fork 4
249 lines (207 loc) · 7.96 KB
/
ci.yml
File metadata and controls
249 lines (207 loc) · 7.96 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
# AgentOps Toolkit — CI/CD Pipelines
#
# Workflows:
# 1. ci.yml — Lint + test on every push/PR; publish dev builds to TestPyPI on develop; VSIX build validation
# 2. _build.yml — Reusable build (test + package), called by staging and release
# 3. staging.yml — Staging: release/* branch → TestPyPI → verify; VSIX pre-release → Marketplace
# 4. release.yml — Production: v* tag → TestPyPI → verify → PyPI → GH Release; VSIX stable → Marketplace
# 5. cut-release.yml — Manual dispatch: create release branch + PR from develop
#
# NOTE: VSIX publishing is handled exclusively by staging.yml (pre-release)
# and release.yml (stable). CI only validates that the VSIX packages correctly.
#
# Trusted Publishing (OIDC):
# The publish-dev job uses PyPI Trusted Publishing — no API tokens required.
# Authentication is handled via OpenID Connect (OIDC) between GitHub Actions
# and TestPyPI.
#
# Setup (Trusted Publishing):
# 1. https://test.pypi.org/manage/project/agentops-accelerator/settings/publishing/
# → Add publisher: GitHub, owner=Azure, repo=agentops, workflow=ci.yml, environment=staging
# (This is a SEPARATE entry from the workflow=staging.yml / workflow=release.yml
# publishers — TestPyPI matches workflow filename exactly.)
# 2. GitHub repo → Settings → Environments → "staging" → confirm "Deployment branches
# and tags" allows `develop` (publish-dev is the only consumer triggered from develop).
name: CI
on:
push:
branches: [develop]
pull_request:
branches: [develop]
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: ">=0.9.0"
enable-cache: false # test matrix saves this cache key
- name: Set up Python
run: uv python install 3.11
- name: Install dependencies
run: uv sync --group dev
- name: Lint with ruff
run: uv run ruff check src/ tests/
- name: Type check with mypy
run: uv run mypy src/agentops/ --ignore-missing-imports
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: ">=0.9.0"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --group dev
- name: Run tests
run: uv run pytest tests/ -v --tb=short --junitxml=test-results.xml
- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
with:
name: test-results-${{ matrix.os }}-py${{ matrix.python-version }}
path: test-results.xml
coverage:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: ">=0.9.0"
enable-cache: false # test matrix saves this cache key
- name: Set up Python
run: uv python install 3.13
- name: Install dependencies
run: uv sync --group dev
- name: Run tests with coverage
run: uv run pytest tests/ --cov=agentops --cov-report=xml --cov-report=term-missing
- name: Upload coverage
uses: actions/upload-artifact@v7
with:
name: coverage-report
path: coverage.xml
# Publish dev build to TestPyPI on every push to develop (not PRs)
publish-dev:
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
needs: [lint, test]
runs-on: ubuntu-latest
environment: staging
permissions:
id-token: write # Required for PyPI Trusted Publishing (OIDC)
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Full history for setuptools-scm
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: ">=0.9.0"
enable-cache: false # test matrix saves this cache key
- name: Set up Python
run: uv python install 3.12
- name: Install dependencies
run: uv sync --group dev
- name: Build package
run: uv build
- name: Show version
run: |
ls -la dist/
uv run python -c "from importlib.metadata import version; print(f'Dev version: {version(\"agentops-accelerator\")}')"
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
skip-existing: true
# Verify the dev build installs correctly
verify-dev:
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
needs: publish-dev
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Determine expected version
id: version
run: |
pip install setuptools-scm
VERSION=$(python -m setuptools_scm)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Expected dev version: $VERSION"
- name: Install from TestPyPI
run: |
for i in 1 2 3 4 5; do
echo "Attempt $i: installing agentops-accelerator==${{ steps.version.outputs.version }}"
if pip install \
"agentops-accelerator==${{ steps.version.outputs.version }}" \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/; then
exit 0
fi
if [ "$i" -lt 5 ]; then
echo "Not available yet, waiting 30s..."
sleep 30
fi
done
echo "::error::agentops-accelerator==${{ steps.version.outputs.version }} was not available from TestPyPI after 5 attempts."
exit 1
- name: Smoke test
run: |
agentops --version
agentops --help
- name: Summary
run: |
echo "## ✅ Dev build published and verified" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "- Version: \`${{ steps.version.outputs.version }}\`" >> "$GITHUB_STEP_SUMMARY"
echo "- TestPyPI: https://test.pypi.org/project/agentops-accelerator/${{ steps.version.outputs.version }}/" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "Install: \`pip install agentops-accelerator==${{ steps.version.outputs.version }} --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/\`" >> "$GITHUB_STEP_SUMMARY"
# Validate that the VSIX extension packages correctly
build-vsix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
# CI uses the committed package.json version as-is (no publish, dry-run only).
# The version in package.json is synced by cut-release.yml when a release branch is created.
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "22"
- name: Install vsce
run: npm install -g @vscode/vsce
- name: Copy root assets for VSIX
run: |
cp CHANGELOG.md plugins/agentops/CHANGELOG.md
cp icon.png plugins/agentops/icon.png
- name: Package VSIX (dry run)
working-directory: plugins/agentops
run: vsce package -o agentops-skills.vsix
- name: Show VSIX info
run: |
ls -la plugins/agentops/*.vsix
echo "✅ VSIX packaging validated"
- name: Upload VSIX artifact
uses: actions/upload-artifact@v7
with:
name: vsix
path: plugins/agentops/*.vsix