Repository navigation
172 lines (160 loc) · 5.6 KB
/
Copy pathpython-test-lint.yml
File metadata and controls
172 lines (160 loc) · 5.6 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
name: "Python: Test and Lint"
on:
workflow_call:
inputs:
ref:
required: true
type: string
secrets:
CODECOV_TOKEN:
required: false
jobs:
unit-test:
name: Unit Tests - Python ${{ matrix.python-version }} - ${{ matrix.os-name }}
permissions:
contents: read
strategy:
matrix:
include:
# Linux
- os: strands-agents_ubuntu-latest_4-core
os-name: 'linux'
python-version: "3.10"
- os: strands-agents_ubuntu-latest_4-core
os-name: 'linux'
python-version: "3.11"
- os: strands-agents_ubuntu-latest_4-core
os-name: 'linux'
python-version: "3.12"
- os: strands-agents_ubuntu-latest_4-core
os-name: 'linux'
python-version: "3.13"
- os: strands-agents_ubuntu-latest_4-core
os-name: 'linux'
python-version: "3.14"
# Windows
- os: strands-agents_windows-latest_4-core
os-name: 'windows'
python-version: "3.10"
- os: strands-agents_windows-latest_4-core
os-name: 'windows'
python-version: "3.11"
- os: strands-agents_windows-latest_4-core
os-name: 'windows'
python-version: "3.12"
- os: strands-agents_windows-latest_4-core
os-name: 'windows'
python-version: "3.13"
- os: strands-agents_windows-latest_4-core
os-name: 'windows'
python-version: "3.14"
# MacOS - latest only; not enough runners for macOS
- os: macos-latest
os-name: 'macOS'
python-version: "3.14"
fail-fast: true
runs-on: ${{ matrix.os }}
# Successful unit-test legs run in ~3-4 min (slowest observed ~16 min);
# 25 min caps a hung step instead of letting it run to the 6-hour default.
timeout-minutes: 25
env:
LOG_LEVEL: DEBUG
defaults:
run:
working-directory: strands-py
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
ref: ${{ inputs.ref }}
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v7.0.0
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --no-cache-dir hatch
- name: Run Unit tests
id: tests
# Retry failing tests so a flaky test doesn't block a release; a
# genuinely broken test still fails after the reruns and holds the gate.
run: hatch test tests --cover --reruns 2 --reruns-delay 5
continue-on-error: false
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
unit-test-mcp-v1:
name: MCP 1.x Compat
# The dependency range spans both `mcp` major versions and fresh installs resolve mcp 2.x, so the unit-test matrix
# only ever exercises 2.x and the 1.x branches of `_compat` run against mocks there. This job force-installs mcp
# 1.x to verify against the real package that `import strands` succeeds and the MCP client suite passes, including
# the legacy 2025-11-25 task workflow, which is 1.x-only. The modern-protocol integ tests
# (tests_integ/mcp/test_mcp_client_v2.py) require 2.x, so they run in the integration-test workflow's main scope.
runs-on: strands-agents_ubuntu-latest_4-core
timeout-minutes: 10
permissions:
contents: read
defaults:
run:
working-directory: strands-py
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
ref: ${{ inputs.ref }}
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v7.0.0
with:
python-version: '3.10'
- name: Install package, then force mcp 1.x
run: |
pip install --no-cache-dir -e . \
"pytest>=9.0.0,<10.0.0" \
"pytest-asyncio>=1.0.0,<1.5.0" \
"pytest-timeout>=2.0.0,<3.0.0" \
"pytest-cov>=6.0.0,<8.0.0" \
"moto>=5.1.0,<6.0.0"
pip install --no-cache-dir "mcp>=1.23.0,<2.0.0"
- name: Verify import and version flag
run: python -c "import strands; from strands.tools.mcp import _compat; assert not _compat.MCP_V2"
# With coverage: the 1.x branches of `_compat` execute only in this job,
# so without this upload they always show as uncovered on the patch.
- name: Run MCP tests
run: |
pytest tests/strands/tools/mcp -vv --cov=src/strands --cov-report=xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
lint:
name: Lint
runs-on: strands-agents_ubuntu-latest_4-core
# Lint typically runs in ~2 min; 20 min caps a hung step instead of
# letting it run to the 6-hour default.
timeout-minutes: 20
permissions:
contents: read
defaults:
run:
working-directory: strands-py
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
ref: ${{ inputs.ref }}
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v7.0.0
with:
python-version: '3.10'
cache: 'pip'
- name: Install dependencies
run: |
pip install --no-cache-dir hatch
- name: Run lint
id: lint
run: hatch fmt --check
continue-on-error: false