Repository navigation
158 lines (140 loc) · 5.46 KB
/
Copy pathpython-sdk-tests.yml
File metadata and controls
158 lines (140 loc) · 5.46 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
name: "Python SDK Tests"
env:
PYTHONUTF8: 1
on:
workflow_dispatch:
workflow_call:
permissions:
contents: read
jobs:
validate:
name: "Python SDK Format and Typecheck"
if: github.event.repository.fork == false
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
shell: bash
working-directory: ./python
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: "3.11"
- name: Set up uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
with:
enable-cache: true
- name: Install Python dev dependencies
run: uv sync --all-extras --dev
- name: Run ruff format check
run: uv run ruff format --check .
- name: Run ruff lint
run: uv run ruff check
- name: Run ty type checking
run: uv run ty check copilot
test:
name: "Python SDK Tests (${{ matrix.os }}, ${{ matrix.transport }})"
if: github.event.repository.fork == false
env:
POWERSHELL_UPDATECHECK: Off
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# Test the oldest supported Python version to make sure compatibility is maintained.
python-version: ["3.11"]
transport: ["default", "inprocess"]
runs-on: ${{ matrix.os }}
timeout-minutes: 20
defaults:
run:
shell: bash
working-directory: ./python
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: ${{ matrix.python-version }}
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: "22"
cache: "npm"
cache-dependency-path: "./nodejs/package-lock.json"
- name: Set up uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
with:
enable-cache: true
- name: Install Python dev dependencies
run: uv sync --all-extras --dev
- name: Install Node.js dependencies (for CLI in tests)
working-directory: ./nodejs
run: npm ci --ignore-scripts --fetch-retries=4 --fetch-retry-mintimeout=10000 --fetch-retry-maxtimeout=60000
- name: Install test harness dependencies
working-directory: ./test/harness
run: npm ci --ignore-scripts --fetch-retries=4 --fetch-retry-mintimeout=10000 --fetch-retry-maxtimeout=60000
- name: Warm up PowerShell
if: runner.os == 'Windows'
run: pwsh.exe -Command "Write-Host 'PowerShell ready'"
- name: Select inprocess transport
if: matrix.transport == 'inprocess'
run: |
echo "COPILOT_SDK_DEFAULT_CONNECTION=inprocess" >> "$GITHUB_ENV"
- name: Run Python SDK tests
env:
COPILOT_HMAC_KEY: ${{ secrets.COPILOT_DEVELOPER_CLI_INTEGRATION_HMAC_KEY }}
# Keep each module's shared E2E client and proxy on one process while
# running independent modules concurrently in isolated workers.
run: uv run pytest -v -s -n 2 --dist=loadfile
- name: Upload Python test diagnostics
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: python-test-diagnostics-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.transport }}-${{ github.run_attempt }}
path: python/.pytest-diagnostics/
include-hidden-files: true
if-no-files-found: warn
retention-days: 7
# JavaScript actions use a glibc-linked Node runtime, so Alpine runs through Docker.
test-musl-arm64:
name: "Python SDK Tests (Alpine ARM64, ${{ matrix.transport }})"
if: github.event.repository.fork == false
strategy:
fail-fast: false
matrix:
transport: ["default", "inprocess"]
runs-on: ubuntu-24.04-arm
timeout-minutes: 20
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Run Python SDK tests on musl
uses: ./.github/actions/run-alpine-tests
env:
COPILOT_HMAC_KEY: ${{ secrets.COPILOT_DEVELOPER_CLI_INTEGRATION_HMAC_KEY }}
with:
image: python:3.11-alpine
workdir: /workspace
transport: ${{ matrix.transport }}
command: |
apk add --no-cache nodejs npm
python -m pip install --no-cache-dir uv
(
cd nodejs
npm ci --ignore-scripts --fetch-retries=4 --fetch-retry-mintimeout=10000 --fetch-retry-maxtimeout=60000
)
(
cd test/harness
npm ci --ignore-scripts --fetch-retries=4 --fetch-retry-mintimeout=10000 --fetch-retry-maxtimeout=60000
)
cd python
uv sync --all-extras --dev
uv run pytest -v -s -n 2 --dist=loadfile
- name: Upload Python test diagnostics
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: python-test-diagnostics-alpine-arm64-${{ matrix.transport }}-${{ github.run_attempt }}
path: python/.pytest-diagnostics/
include-hidden-files: true
if-no-files-found: warn
retention-days: 7