Repository navigation
135 lines (130 loc) · 4.55 KB
/
Copy pathpython.yml
File metadata and controls
135 lines (130 loc) · 4.55 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
name: Python surfaces
on:
push:
branches: [main]
paths: &python-paths
- '*/python/**'
- '*/conformance/**'
- 'pyproject.toml'
- 'uv.lock'
- 'mcp/examples/management-reference/**'
- '.github/workflows/python.yml'
- 'scripts/ci-components.py'
pull_request:
paths: *python-paths
workflow_dispatch:
permissions:
contents: read
jobs:
changes:
runs-on: ubuntu-latest
outputs:
components: ${{ steps.select.outputs.components }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
persist-credentials: false
- id: select
run: python3 scripts/ci-components.py python
test:
needs: changes
if: needs.changes.outputs.components != '[]'
name: Python ${{ matrix.version }} (${{ matrix.component }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component: ${{ fromJSON(needs.changes.outputs.components) }}
version: ['3.12', '3.11']
exclude:
- component: mcp
version: '3.11'
- component: a2a
version: '3.11'
- component: cli
version: '3.11'
defaults:
run:
working-directory: ${{ matrix.component }}/python
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: ${{ matrix.version }}
- name: Install and verify local dependencies
shell: bash
run: |
args=(-e '.[dev]')
if [[ "${{ matrix.component }}" != toolkit ]]; then
args+=(-e "$GITHUB_WORKSPACE/toolkit/python")
fi
if [[ "${{ matrix.component }}" == a2a ]]; then
args+=(aiohttp)
fi
if [[ -f constraints.txt ]]; then
args+=(-c constraints.txt)
fi
python -m pip install "${args[@]}"
python -m pip check
python - <<'PY'
import os
from pathlib import Path
import apcore_toolkit
expected = Path(os.environ["GITHUB_WORKSPACE"]) / "toolkit/python/src/apcore_toolkit"
assert Path(apcore_toolkit.__file__).resolve().parent == expected.resolve()
PY
- run: ruff check src/ tests/
- run: python -m pytest
- name: Verify the MCP management reference with both SDK versions
if: matrix.component == 'mcp'
working-directory: .
shell: bash
run: |
example=mcp/examples/management-reference
reference="$RUNNER_TEMP/mcp-management-reference"
legacy="$RUNNER_TEMP/mcp-management-legacy"
python -m venv "$reference"
python -m venv "$legacy"
"$reference/bin/python" -m pip install -r "$example/requirements-test.txt"
"$reference/bin/python" -m pip check
"$reference/bin/python" -m pytest -q "$example"
"$legacy/bin/python" -m pip install 'mcp==1.30.0'
"$legacy/bin/python" "$example/legacy_smoke.py" "$reference/bin/python"
package:
needs: changes
if: needs.changes.outputs.components != '[]'
name: Python distribution (${{ matrix.component }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component: ${{ fromJSON(needs.changes.outputs.components) }}
defaults:
run:
working-directory: ${{ matrix.component }}/python
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: '3.12'
- name: Build wheel and sdist
run: |
python -m pip install build
python -m build
- name: Install and import the built wheel in isolation
shell: bash
env:
COMPONENT: ${{ matrix.component }}
run: |
wheels=( "$PWD"/dist/*.whl )
temporary=$(mktemp -d)
if [[ "$COMPONENT" == a2a || "$COMPONENT" == cli ]]; then
python -m build --wheel --outdir "$temporary/wheels" "$GITHUB_WORKSPACE/toolkit/python"
wheels+=( "$temporary"/wheels/apcore_toolkit-*.whl )
fi
python -m venv "$temporary/venv"
cd "$temporary"
"$temporary/venv/bin/python" -m pip install "${wheels[@]}"
"$temporary/venv/bin/python" -m pip check
"$temporary/venv/bin/python" -c 'import importlib, sys; importlib.import_module("apcore_" + sys.argv[1])' "$COMPONENT"