forked from strands-agents/harness-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (176 loc) · 5.47 KB
/
Copy pathpython-test-lint.yml
File metadata and controls
183 lines (176 loc) · 5.47 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
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: ubuntu-latest
os-name: 'linux'
python-version: "3.10"
- os: ubuntu-latest
os-name: 'linux'
python-version: "3.11"
- os: ubuntu-latest
os-name: 'linux'
python-version: "3.12"
- os: ubuntu-latest
os-name: 'linux'
python-version: "3.13"
- os: ubuntu-latest
os-name: 'linux'
python-version: "3.14"
# Windows
- os: windows-latest
os-name: 'windows'
python-version: "3.10"
- os: windows-latest
os-name: 'windows'
python-version: "3.11"
- os: windows-latest
os-name: 'windows'
python-version: "3.12"
- os: windows-latest
os-name: 'windows'
python-version: "3.13"
- os: windows-latest
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 (e.g. apt) 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@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install system audio dependencies (Linux)
if: matrix.os-name == 'linux'
working-directory: .
timeout-minutes: 5
env:
DEBIAN_FRONTEND: noninteractive
run: |
for attempt in 1 2 3; do
if sudo apt-get -o Acquire::Retries=3 update \
&& sudo apt-get -o Acquire::Retries=3 install -y portaudio19-dev libasound2-dev; then
exit 0
fi
if [ "$attempt" -lt 3 ]; then
echo "apt-get attempt $attempt failed; retrying in 15s..."
sleep 15
fi
done
echo "apt-get failed after 3 attempts" >&2
exit 1
- name: Install system audio dependencies (macOS)
if: matrix.os-name == 'macOS'
working-directory: .
timeout-minutes: 5
run: |
for attempt in 1 2 3; do
if brew install portaudio; then
exit 0
fi
if [ "$attempt" -lt 3 ]; then
echo "brew install attempt $attempt failed; retrying in 15s..."
sleep 15
fi
done
echo "brew install failed after 3 attempts" >&2
exit 1
- name: Install system audio dependencies (Windows)
if: matrix.os-name == 'windows'
working-directory: .
run: |
# Windows typically has audio libraries available by default
echo "Windows audio dependencies handled by PyAudio wheels"
- 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@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
lint:
name: Lint
runs-on: ubuntu-latest
# 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@v6
with:
python-version: '3.10'
cache: 'pip'
- name: Install system audio dependencies (Linux)
working-directory: .
timeout-minutes: 5
env:
DEBIAN_FRONTEND: noninteractive
run: |
for attempt in 1 2 3; do
if sudo apt-get -o Acquire::Retries=3 update \
&& sudo apt-get -o Acquire::Retries=3 install -y portaudio19-dev libasound2-dev; then
exit 0
fi
if [ "$attempt" -lt 3 ]; then
echo "apt-get attempt $attempt failed; retrying in 15s..."
sleep 15
fi
done
echo "apt-get failed after 3 attempts" >&2
exit 1
- name: Install dependencies
run: |
pip install --no-cache-dir hatch
- name: Run lint
id: lint
run: hatch fmt --linter --check
continue-on-error: false