-
Notifications
You must be signed in to change notification settings - Fork 1
153 lines (131 loc) · 3.9 KB
/
python-sdk.yml
File metadata and controls
153 lines (131 loc) · 3.9 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
name: Python SDK
on:
push:
branches: [main]
paths:
- 'link/sdks/python/**'
- 'link/kalam-client/**'
- 'link/link-common/**'
- '.github/workflows/python-sdk.yml'
workflow_dispatch:
inputs:
publish:
description: "Publish wheels to PyPI"
type: boolean
required: false
default: false
workflow_call:
inputs:
publish:
description: "Publish wheels to PyPI"
type: boolean
required: false
default: false
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test (${{ matrix.os }}, Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.92.0"
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
with:
workspaces: link/sdks/python -> target
- name: Create venv and install maturin + pytest
working-directory: link/sdks/python
shell: bash
run: |
python -m venv .venv
if [ -f .venv/bin/activate ]; then source .venv/bin/activate; else source .venv/Scripts/activate; fi
python -m pip install --upgrade pip
pip install maturin pytest pytest-asyncio
- name: Build SDK in develop mode (inside venv)
working-directory: link/sdks/python
shell: bash
run: |
if [ -f .venv/bin/activate ]; then source .venv/bin/activate; else source .venv/Scripts/activate; fi
maturin develop --release
- name: Run unit tests (no server required)
working-directory: link/sdks/python
shell: bash
run: |
if [ -f .venv/bin/activate ]; then source .venv/bin/activate; else source .venv/Scripts/activate; fi
pytest tests/test_auth.py tests/test_exceptions.py tests/test_agent.py -v
build-wheels:
name: Build wheels (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: test
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
working-directory: link/sdks/python
command: build
args: --release --strip --out dist
rust-toolchain: "1.92.0"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: link/sdks/python/dist/*.whl
build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
working-directory: link/sdks/python
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: link/sdks/python/dist/*.tar.gz
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build-wheels, build-sdist]
if: ${{ inputs.publish }}
environment:
name: pypi
permissions:
id-token: write
steps:
- name: Download all wheels
uses: actions/download-artifact@v4
with:
path: dist
pattern: wheels-*
merge-multiple: true
- name: Download sdist
uses: actions/download-artifact@v4
with:
name: sdist
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist