forked from MemMachine/MemMachine
-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (105 loc) · 4.27 KB
/
test-python-client-package.yml
File metadata and controls
125 lines (105 loc) · 4.27 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
name: Test Python Client Package
# Validates the Python REST client package build and import surface.
permissions:
contents: read
# Cancel any preceding run on the pull request after a new commit is pushed.
concurrency:
# Use a stable key across event types (push vs pull_request):
# - PRs: key by PR number
# - Pushes: key by branch ref (prefer head_ref when present)
group: test-python-client-package-${{ github.event.pull_request.number || github.head_ref || github.ref }}
# Don't cancel if running on a push to the main branch.
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
jobs:
test-python-client-package:
name: Test Python Client Package (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.14"]
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install uv build
- name: Build Python client package
shell: bash
run: |
uv build --project packages/common -o dist/
uv build --project packages/client -o dist/
python -c "import pathlib, sys; d=sorted(pathlib.Path('dist').glob('memmachine_common-*.whl')); [print(p.name) for p in d]; sys.exit(1 if not d else 0)"
python -c "import pathlib, sys; d=sorted(pathlib.Path('dist').glob('memmachine_client-*.whl')); [print(p.name) for p in d]; sys.exit(1 if not d else 0)"
- name: Install Python client package
shell: bash
run: |
set -eo pipefail
whl_name=$(python -c "import pathlib; d=sorted(pathlib.Path('dist').glob('memmachine_client-*.whl')); print(d[0] if d else '')")
if [ -z "$whl_name" ]; then
echo "No client wheel found" >&2
exit 1
fi
python -m pip install --find-links dist/ "$whl_name"
- name: Test Python client package imports
shell: bash
run: |
set -eo pipefail
python -c "
from memmachine_client import MemMachineClient, Memory, Project
from memmachine_common.api import MemoryType
print('All imports successful')
print(f'Python version: {__import__(\"sys\").version}')
print(f'MemoryType.Semantic = {MemoryType.Semantic.value}')
print(f'MemoryType.Episodic = {MemoryType.Episodic.value}')
print(f'MemMachineClient class: {MemMachineClient}')
print(f'Memory class: {Memory}')
print(f'Project class: {Project}')
"
- name: Test Python client package basic functionality
shell: bash
run: |
set -eo pipefail
python -c "
from memmachine_client import MemMachineClient
from memmachine_common.api import MemoryType
# Test client instantiation
client = MemMachineClient(base_url='http://localhost:8080')
print('Client instantiation successful')
# Test MemoryType enum
assert MemoryType.Semantic.value == 'semantic'
assert MemoryType.Episodic.value == 'episodic'
print('MemoryType enum values correct')
# Test that client has expected methods
assert hasattr(client, 'get_project')
assert hasattr(client, 'create_project')
assert hasattr(client, 'close')
print('Client has expected methods')
"
- name: Verify Python client package structure
shell: bash
run: |
set -eo pipefail
python -c "
import memmachine_client
import memmachine_common.api
# Check that modules exist
assert hasattr(memmachine_common.api, 'MemoryType')
assert hasattr(memmachine_client, 'MemMachineClient')
assert hasattr(memmachine_client, 'Memory')
assert hasattr(memmachine_client, 'Project')
print('Package structure verified')
"