Skip to content

test: comprehensive test suites for Python (247) and npm (379) #7

test: comprehensive test suites for Python (247) and npm (379)

test: comprehensive test suites for Python (247) and npm (379) #7

Workflow file for this run

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')
"
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