Repository navigation
109 lines (103 loc) · 3.52 KB
/
Copy pathci.yml
File metadata and controls
109 lines (103 loc) · 3.52 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
name: ci
on:
push:
branches: [main]
pull_request:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- run: pip install ".[dev]"
- run: ruff check .
- run: ruff format --check .
continue-on-error: true
- run: mypy microtensor_subnet
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: pip
- run: pip install ".[validator,dev]"
- name: Run the suite
run: |
if [ -d tests ]; then
pytest tests -q
else
echo "::notice::the suite is not published in this repository; skipping"
fi
- name: Every module imports
run: |
python - <<'PY'
import importlib, pkgutil, microtensor_subnet
skipped = []
for info in pkgutil.walk_packages(microtensor_subnet.__path__, "microtensor_subnet."):
try:
importlib.import_module(info.name)
except ImportError as exc:
skipped.append(f"{info.name}: {exc}")
print("\n".join(skipped) or "all modules import")
PY
mechanism:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- run: pip install ".[validator,dev]"
- name: The pool shares sum to one and the payout schedule is monotone
run: |
python - <<'PY'
import math
from microtensor_subnet.scoring.pools import POOL_SHARES, RANK_PAYOUT
assert math.isclose(sum(POOL_SHARES.values()), 1.0), POOL_SHARES
assert list(RANK_PAYOUT) == sorted(RANK_PAYOUT, reverse=True), RANK_PAYOUT
print("pools ok")
PY
- name: The sandbox image installs exactly the allowed packages
run: |
python - <<'PY'
from microtensor_subnet.artifact.contract import ALLOWED_PACKAGES
for name, version in ALLOWED_PACKAGES.items():
assert version.count(".") >= 1, f"{name} is not pinned"
print(f"{len(ALLOWED_PACKAGES)} pinned packages")
PY
- name: The package must build and carry the entrypoints
run: |
pip install build
python -m build --wheel
python - <<'PY'
import zipfile, glob
whl = glob.glob("dist/*.whl")[0]
names = zipfile.ZipFile(whl).namelist()
entry = next(n for n in names if n.endswith("entry_points.txt"))
text = zipfile.ZipFile(whl).read(entry).decode()
for script in ("mt =", "mt-validator =", "mt-operator ="):
assert script in text, f"{script} missing from {entry}"
assert any(n.startswith("neurons/") for n in names), "neurons package not packaged"
print(text)
PY
build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validator image builds
run: docker build -f deploy/Dockerfile.validator -t microtensor_subnet/validator:ci .
- name: Sandbox image builds
run: docker build -f deploy/Dockerfile.sandbox -t microtensor/sandbox:ci .