-
Notifications
You must be signed in to change notification settings - Fork 28
198 lines (162 loc) · 6.91 KB
/
Copy pathci.yml
File metadata and controls
198 lines (162 loc) · 6.91 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
# ── Python tests ─────────────────────────────────────────────────────────────
python-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: Swatinem/rust-cache@v2
with:
workspaces: ". -> target"
- name: Build engram-core wheel
run: |
pip install maturin
maturin build --release --manifest-path engram-core/Cargo.toml --out dist
pip install dist/engram_core-*.whl
- name: Install Python dependencies
run: pip install ".[dev]" faiss-cpu
- name: Run tests
run: python -m pytest tests/ -q --tb=short --cov=engram --cov-report=term-missing
# ── Type checking ─────────────────────────────────────────────────────────────
typecheck:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
pip install ".[dev]"
pip install bittensor --quiet || true # optional; mypy ignore_missing_imports=true
- name: mypy
run: mypy engram/ --ignore-missing-imports --no-error-summary
# ── Rust tests ────────────────────────────────────────────────────────────────
rust-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: Swatinem/rust-cache@v2
with:
workspaces: ". -> target"
- name: Run Rust tests
run: cargo test --manifest-path engram-core/Cargo.toml --no-default-features
# ── Build wheel smoke-test ────────────────────────────────────────────────────
build-wheel:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install maturin
run: pip install maturin
- name: Build engram-core wheel
run: maturin build --release --manifest-path engram-core/Cargo.toml --out dist
- name: Smoke-test wheel
run: |
pip install dist/engram_core-*.whl
python -c "
import engram_core
# CID round-trip
cid = engram_core.generate_cid([0.1, 0.2, 0.3], {}, 'v1')
assert cid.startswith('v1::') and len(cid.split('::')[1]) == 64
# Single-CID proof
challenge = engram_core.generate_challenge(cid, 30)
response = engram_core.generate_response(challenge, [0.1, 0.2, 0.3])
assert engram_core.verify_response(challenge, response, [0.1, 0.2, 0.3])
response2 = engram_core.generate_response_from_parts(
challenge.cid,
challenge.nonce_hex,
challenge.expires_at,
[0.1, 0.2, 0.3],
)
assert response2.proof == response.proof
assert response2.embedding_hash == response.embedding_hash
# Batch proof
cid2 = engram_core.generate_cid([0.4, 0.5, 0.6], {}, 'v1')
batch = engram_core.generate_batch_challenge([cid, cid2], 30)
embs = [[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]]
br = engram_core.generate_batch_response(batch, embs)
results = engram_core.verify_batch_response(batch, br, embs)
assert results == [True, True], f'batch verify failed: {results}'
print('engram_core smoke test: PASS')
"
# ── Docker image — GHCR ──────────────────────────────────────────────────────
# Builds and pushes ghcr.io/dipraise1/engram:latest on every push to main.
# This image is used by the cloud mining layer (Akash SDL manifests).
docker:
needs: [python-tests, rust-tests]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions:
contents: read
packages: write
steps:
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet /usr/share/swift /opt/ghc /opt/hostedtoolcache/CodeQL
sudo docker image prune -af
df -h
- name: Checkout
uses: actions/checkout@v4
- name: Log in to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
- name: Build miner image
run: |
IMAGE="ghcr.io/$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')/engram"
docker build -t "${IMAGE}:latest" -t "${IMAGE}:${{ github.sha }}" .
echo "IMAGE=${IMAGE}" >> "$GITHUB_ENV"
- name: Push miner image
run: |
docker push "${IMAGE}:latest"
docker push "${IMAGE}:${{ github.sha }}"
# ── Publish to PyPI ───────────────────────────────────────────────────────────
# Triggered on version tags: git tag v0.1.2 && git push --tags
publish:
needs: [python-tests, typecheck, rust-tests, build-wheel]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
environment: pypi
permissions:
id-token: write # required for trusted publishing (OIDC)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build tools
run: pip install build twine
- name: Build Python distribution
run: python -m build --sdist --wheel
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
# Uses OIDC trusted publishing — no API token needed.
# Configure at: https://pypi.org/manage/project/engram-subnet/settings/publishing/
# Add publisher: owner=Dipraise1, repo=-Engram-, workflow=ci.yml, env=pypi
skip-existing: true