Add Mintlayer Python SDK (port of go-sdk) #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| # Least privilege: the workflow only reads the repo. | |
| permissions: | |
| contents: read | |
| # Cancel superseded runs on rapid pushes. | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint: | |
| name: Lint & typecheck | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| persist-credentials: false | |
| - uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: uv.lock | |
| - name: Install Python | |
| run: uv python install 3.12 | |
| - name: Sync dependencies (locked) | |
| run: uv sync --locked --group dev --python 3.12 | |
| - name: Ruff lint | |
| run: uv run ruff check . | |
| # Scoped to Python paths: repo-wide format would also reformat the | |
| # illustrative snippets inside docs/*.md and README.md. | |
| - name: Ruff format | |
| run: uv run ruff format --check mintlayer/ tests/ examples/ | |
| - name: Mypy | |
| run: uv run mypy mintlayer/ | |
| test: | |
| name: Test (Python ${{ matrix.python }}) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python: ["3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| persist-credentials: false | |
| - uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: uv.lock | |
| - name: Install Python ${{ matrix.python }} | |
| run: uv python install ${{ matrix.python }} | |
| - name: Sync dependencies (locked) | |
| run: uv sync --locked --group dev --python ${{ matrix.python }} | |
| # WASM init costs ~400 ms per Client; the session-scoped fixture keeps | |
| # the suite to ~2 min. Coverage gate: total must stay above 80%. | |
| - name: Run tests with coverage | |
| run: > | |
| uv run pytest tests/ -q | |
| --cov --cov-report=term-missing | |
| --cov-fail-under=80 | |
| build: | |
| name: Build wheel | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| persist-credentials: false | |
| - uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: uv.lock | |
| - name: Install Python | |
| run: uv python install 3.12 | |
| - name: Build sdist and wheel | |
| run: uv build | |
| - name: Smoke-test wheel contents | |
| run: | | |
| python3 - <<'EOF' | |
| import zipfile, glob | |
| wheels = glob.glob("dist/*.whl") | |
| assert wheels, "no wheel produced by uv build" | |
| wheel = wheels[0] | |
| names = zipfile.ZipFile(wheel).namelist() | |
| assert any(n.endswith("wasm_wrappers_bg.wasm") for n in names), "wasm binary missing" | |
| assert any(n.endswith("wasm_wrappers_bg.wasm.sha256") for n in names), "sha256 pin missing" | |
| assert any(n == "mintlayer/__init__.py" for n in names), "package missing" | |
| print(f"{wheel}: {len(names)} entries OK") | |
| EOF | |
| all-green: | |
| name: All checks passed | |
| runs-on: ubuntu-latest | |
| needs: [lint, test, build] | |
| steps: | |
| - run: echo "All CI jobs green" |