Repository navigation
131 lines (126 loc) · 4.58 KB
/
Copy pathpython.yml
File metadata and controls
131 lines (126 loc) · 4.58 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
name: Python surfaces
on:
push:
branches: [main]
paths: &python-paths
- '*/python/**'
- '*/conformance/**'
- 'pyproject.toml'
- 'uv.lock'
- 'mcp/examples/management-reference/**'
- '.github/workflows/python.yml'
pull_request:
paths: *python-paths
workflow_dispatch:
permissions:
contents: read
env:
CORE_REF: c89df2fcbe9224104151222006eeaa1b91f08d5e
jobs:
test:
name: Python ${{ matrix.version }} (${{ matrix.component }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component: [toolkit, mcp, a2a, cli]
version: ['3.12']
include:
- component: toolkit
version: '3.11'
defaults:
run:
working-directory: ${{ matrix.component }}/python
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- &checkout-core
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
repository: apstack/apcore
ref: ${{ env.CORE_REF }}
path: .ci-apcore-core
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: ${{ matrix.version }}
- &build-core-wheel
name: Build the pinned Core wheel
run: |
python -m pip install build
python -m build --wheel --outdir "$RUNNER_TEMP/core-wheel" "$GITHUB_WORKSPACE/.ci-apcore-core/python"
- name: Install and verify local dependencies
shell: bash
run: |
args=("$RUNNER_TEMP"/core-wheel/apcore-*.whl -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" "$RUNNER_TEMP"/core-wheel/apcore-*.whl
"$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:
name: Python distribution (${{ matrix.component }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component: [toolkit, mcp, a2a, cli]
defaults:
run:
working-directory: ${{ matrix.component }}/python
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- *checkout-core
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: '3.12'
- *build-core-wheel
- 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 "$RUNNER_TEMP"/core-wheel/apcore-*.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"