-
Notifications
You must be signed in to change notification settings - Fork 10
168 lines (142 loc) · 5.51 KB
/
ci.yml
File metadata and controls
168 lines (142 loc) · 5.51 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
name: CI - Build, Test, and Publish SDKs
permissions:
contents: read
# This workflow builds, tests, and publishes Python SDK packages
# - Builds and tests run on all branches (main, release/*)
# - Publishing to package repository ONLY happens on release/* branches
# - Development versions (with 'dev' suffix) are created on all non-tagged commits
# - Official releases (without 'dev' suffix) require a Git tag on a release/* branch
on:
push:
branches: [ main, "release/*" ]
pull_request:
branches: [ main, "release/*" ]
jobs:
version-number:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history for git versioning
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install setuptools-git-versioning
run: |
python -m pip install --upgrade pip
python -m pip install setuptools-git-versioning
- id: package_version
name: Calculate Package Version
run: |
cd ./versioning
version=$(python -m setuptools_git_versioning)
echo "Package version calculated: $version"
echo "PACKAGE_VERSION=$version" >> $GITHUB_OUTPUT
outputs:
PACKAGE_VERSION: ${{ steps.package_version.outputs.PACKAGE_VERSION }}
changed-sdks:
name: Determine Changed SDKs
runs-on: ubuntu-latest
outputs:
python-sdk: ${{ steps.check_python_sdk.outputs.changed }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- id: git_refs
name: Set Git refs for diff
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "base=${{ github.event.pull_request.base.sha }}" >> "$GITHUB_OUTPUT"
echo "head=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
else
echo "base=${{ github.event.before }}" >> "$GITHUB_OUTPUT"
echo "head=${{ github.sha }}" >> "$GITHUB_OUTPUT"
fi
- id: check_python_sdk
name: Check Python SDK changes
run: |
if git diff --name-only "${{ steps.git_refs.outputs.base }}" "${{ steps.git_refs.outputs.head }}" -- 'libraries/**' 'setup.py' 'pyproject.toml' 'versioning/**' | grep -q .; then
echo "Python SDK changes detected"
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "No Python SDK changes detected"
echo "changed=false" >> $GITHUB_OUTPUT
fi
python-sdk:
name: Python SDK
needs: [version-number, changed-sdks]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./
strategy:
matrix:
python-version: ['3.11', '3.12']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install the latest version of uv and set the python version
uses: astral-sh/setup-uv@v6
with:
version: '0.6.x'
python-version: ${{ matrix.python-version }}
working-directory: ./
enable-cache: true
cache-dependency-glob: "./pyproject.toml"
- name: Install the project
run: uv lock && uv sync --locked --all-extras --dev
- name: Verify centralized version constraints
run: python scripts/verify_constraints.py
- name: Check linting
run: |
uv run --frozen ruff check . --preview
- name: Check formatting
run: |
uv run --frozen ruff format --check .
- name: Build package
run: |
AGENT365_PYTHON_SDK_PACKAGE_VERSION=${{ needs.version-number.outputs.PACKAGE_VERSION }} uv build --all-packages --wheel
env:
AGENT365_PYTHON_SDK_PACKAGE_VERSION: ${{ needs.version-number.outputs.PACKAGE_VERSION }}
- name: Run unit tests
run: |
uv run --frozen pytest tests/ -v --tb=short -m "not integration"
- name: Run integration tests
# Only run integration tests if secrets are available
if: ${{ vars.RUN_INTEGRATION_TESTS == 'true' }}
run: |
uv run --frozen pytest -m integration -v --tb=short
env:
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
AZURE_OPENAI_ENDPOINT: ${{ vars.AZURE_OPENAI_ENDPOINT }}
AZURE_OPENAI_DEPLOYMENT: ${{ vars.AZURE_OPENAI_DEPLOYMENT }}
AZURE_OPENAI_API_VERSION: ${{ vars.AZURE_OPENAI_API_VERSION }}
ENABLE_OBSERVABILITY: true
# Copy package and samples to drop folder
- name: Copy package and samples to drop folder
run: |
mkdir -p ~/drop/python-${{ matrix.python-version }}/dist && cp -v dist/*.whl $_
# Zip files since upload-artifact does not seem like to like folders
- name: Create zip
run: cd ~/drop/python-${{ matrix.python-version }} && zip -r ~/drop/python-${{ matrix.python-version }}.zip .
- name: Upload package and samples as artifacts
uses: actions/upload-artifact@v4
with:
name: python-${{ matrix.python-version }}
path: ~/drop/python-${{ matrix.python-version }}.zip
- name: Publish
# Only publish when:
# 1. It's a push event (not a PR)
# 2. The branch is a release/* branch
# 3. There are SDK changes
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/') && needs.changed-sdks.outputs.python-sdk == 'true'
run: |
uv run twine upload --config-file .pypirc -r Agent365 dist/*
continue-on-error: true
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.AZURE_DEVOPS_TOKEN }}