-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (128 loc) · 4.18 KB
/
Copy pathvalidate.yml
File metadata and controls
152 lines (128 loc) · 4.18 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
schema:
name: Schema & Examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: pip install -r requirements.txt
- name: Validate schema is valid JSON
run: python -c "import json; json.load(open('schema/mif-v2.schema.json'))"
- name: Validate examples against schema
run: python validate.py examples/*.mif.json
- name: Round-trip test
run: python tests/round_trip.py examples/*.mif.json
python:
name: Python Package
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install mif-tools
run: pip install -e "./python[validate]"
- name: Test adapters (MIF v2 round-trip)
run: |
python -c "
from mif import load, dump
data = open('examples/full.mif.json').read()
doc = load(data)
assert len(doc.memories) == 3
assert doc.knowledge_graph is not None
rt = load(dump(doc))
assert len(rt.memories) == 3
print('MIF v2 round-trip: PASS')
"
- name: Test adapters (mem0 round-trip)
run: |
python -c "
from mif import load, dump
data = open('examples/full.mif.json').read()
doc = load(data)
mem0 = dump(doc, format='mem0')
doc2 = load(mem0, format='mem0')
assert len(doc2.memories) == len(doc.memories)
print('mem0 round-trip: PASS')
"
- name: Test adapters (markdown round-trip)
run: |
python -c "
from mif import load, dump
data = open('examples/full.mif.json').read()
doc = load(data)
md = dump(doc, format='markdown')
doc2 = load(md, format='markdown')
assert len(doc2.memories) == len(doc.memories)
print('markdown round-trip: PASS')
"
- name: Test adapters (generic JSON round-trip)
run: |
python -c "
from mif import load, dump
data = open('examples/full.mif.json').read()
doc = load(data)
gen = dump(doc, format='generic')
doc2 = load(gen, format='generic')
assert len(doc2.memories) == len(doc.memories)
print('generic JSON round-trip: PASS')
"
- name: Test auto-detection
run: |
python -c "
from mif import load
# mem0 auto-detect
doc = load('[{\"memory\": \"test\", \"created_at\": \"2026-01-01T00:00:00Z\"}]')
assert doc.memories[0].content == 'test'
# generic auto-detect
doc = load('[{\"content\": \"test2\", \"timestamp\": \"2026-01-01T00:00:00Z\"}]')
assert doc.memories[0].content == 'test2'
print('auto-detection: PASS')
"
- name: Test CLI
run: |
mif formats
mif inspect examples/full.mif.json
mif validate examples/minimal.mif.json examples/full.mif.json
- name: Test schema validation
run: |
python -c "
from mif import validate
data = open('examples/full.mif.json').read()
ok, errors = validate(data)
assert ok, f'Validation failed: {errors}'
print('schema validation: PASS')
"
- name: Install pytest
run: pip install pytest
- name: Run Python test suite
run: pytest python/tests/ -v
npm:
name: npm Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
working-directory: npm
run: npm install
- name: Build
working-directory: npm
run: npm run build
- name: Run tests (379 assertions)
working-directory: npm
run: npm test