-
Notifications
You must be signed in to change notification settings - Fork 2
[python] Implement basic use-mojo-in-python that exposes decimo to Python via _decimo.so
#179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| name: Decimo Unit Tests | ||
| name: CI | ||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
@@ -7,66 +7,218 @@ permissions: | |
| contents: read | ||
| pull-requests: read | ||
|
|
||
| jobs: | ||
| testing-decimo: | ||
| name: with ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| # os: ["macos-latest"] | ||
| os: ["ubuntu-22.04"] | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| runs-on: ${{ matrix.os }} | ||
| timeout-minutes: 30 | ||
| # Shared setup repeated per job (GitHub Actions has no job-level includes, | ||
| # so we keep each job self-contained for clarity and parallelism). | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash | ||
| jobs: | ||
| # ── Test: BigDecimal ───────────────────────────────────────────────────────── | ||
| test-bigdecimal: | ||
| name: Test BigDecimal | ||
| runs-on: ubuntu-22.04 | ||
| timeout-minutes: 30 | ||
| env: | ||
| DEBIAN_FRONTEND: noninteractive | ||
|
|
||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v4 | ||
| - uses: actions/checkout@v4 | ||
| - name: Install pixi | ||
| run: curl -fsSL https://pixi.sh/install.sh | sh | ||
| - name: Add pixi to PATH | ||
| run: | | ||
| echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV | ||
| echo "$HOME/.pixi/bin" >> $GITHUB_PATH | ||
| - name: pixi install | ||
| run: pixi install | ||
| - name: Build packages | ||
| run: | | ||
| pixi run mojo package src/decimo && cp decimo.mojopkg tests/ | ||
| pixi run mojo package src/tomlmojo && mv tomlmojo.mojopkg tests/ | ||
| - name: Run tests | ||
| run: bash ./tests/test_bigdecimal.sh | ||
|
|
||
| # ── Test: BigInt ───────────────────────────────────────────────────────────── | ||
| test-bigint: | ||
| name: Test BigInt | ||
| runs-on: ubuntu-22.04 | ||
| timeout-minutes: 30 | ||
| env: | ||
| DEBIAN_FRONTEND: noninteractive | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install pixi | ||
| run: curl -fsSL https://pixi.sh/install.sh | sh | ||
| - name: Add pixi to PATH | ||
| run: | | ||
| echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV | ||
| echo "$HOME/.pixi/bin" >> $GITHUB_PATH | ||
| - name: pixi install | ||
| run: pixi install | ||
| - name: Build packages | ||
| run: | | ||
| curl -fsSL https://pixi.sh/install.sh | sh | ||
|
|
||
| - name: Add path | ||
| pixi run mojo package src/decimo && cp decimo.mojopkg tests/ | ||
| pixi run mojo package src/tomlmojo && mv tomlmojo.mojopkg tests/ | ||
| - name: Run tests | ||
| run: bash ./tests/test_bigint.sh | ||
|
|
||
| # ── Test: BigUint ──────────────────────────────────────────────────────────── | ||
| test-biguint: | ||
| name: Test BigUint | ||
| runs-on: ubuntu-22.04 | ||
| timeout-minutes: 30 | ||
| env: | ||
| DEBIAN_FRONTEND: noninteractive | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install pixi | ||
| run: curl -fsSL https://pixi.sh/install.sh | sh | ||
| - name: Add pixi to PATH | ||
| run: | | ||
| echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV | ||
| echo "$HOME/.pixi/bin" >> $GITHUB_PATH | ||
| echo "$HOME/.pixi/bin" >> $GITHUB_PATH | ||
| - name: pixi install | ||
| run: pixi install | ||
| - name: Build packages | ||
| run: | | ||
| pixi run mojo package src/decimo && cp decimo.mojopkg tests/ | ||
| pixi run mojo package src/tomlmojo && mv tomlmojo.mojopkg tests/ | ||
| - name: Run tests | ||
| run: bash ./tests/test_biguint.sh | ||
|
|
||
| - name: Activate virtualenv | ||
| # ── Test: BigInt10 ─────────────────────────────────────────────────────────── | ||
| test-bigint10: | ||
| name: Test BigInt10 | ||
| runs-on: ubuntu-22.04 | ||
| timeout-minutes: 30 | ||
| env: | ||
| DEBIAN_FRONTEND: noninteractive | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install pixi | ||
| run: curl -fsSL https://pixi.sh/install.sh | sh | ||
| - name: Add pixi to PATH | ||
| run: | | ||
| python3 -m venv $HOME/venv/ | ||
| . $HOME/venv/bin/activate | ||
| echo PATH=$PATH >> $GITHUB_ENV | ||
| echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV | ||
| echo "$HOME/.pixi/bin" >> $GITHUB_PATH | ||
| - name: pixi install | ||
| run: pixi install | ||
| - name: Build packages | ||
| run: | | ||
| pixi run mojo package src/decimo && cp decimo.mojopkg tests/ | ||
| pixi run mojo package src/tomlmojo && mv tomlmojo.mojopkg tests/ | ||
| - name: Run tests | ||
| run: bash ./tests/test_bigint10.sh | ||
|
|
||
| - name: Pixi install | ||
| # ── Test: Decimal128 ───────────────────────────────────────────────────────── | ||
| test-decimal128: | ||
| name: Test Decimal128 | ||
| runs-on: ubuntu-22.04 | ||
| timeout-minutes: 30 | ||
| env: | ||
| DEBIAN_FRONTEND: noninteractive | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install pixi | ||
| run: curl -fsSL https://pixi.sh/install.sh | sh | ||
| - name: Add pixi to PATH | ||
| run: | | ||
| pixi install | ||
| echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV | ||
| echo "$HOME/.pixi/bin" >> $GITHUB_PATH | ||
| - name: pixi install | ||
| run: pixi install | ||
| - name: Build packages | ||
| run: | | ||
| pixi run mojo package src/decimo && cp decimo.mojopkg tests/ | ||
| pixi run mojo package src/tomlmojo && mv tomlmojo.mojopkg tests/ | ||
| - name: Run tests | ||
| run: bash ./tests/test_decimal128.sh | ||
|
|
||
| - name: Build package | ||
| # ── Test: TomlMojo ─────────────────────────────────────────────────────────── | ||
| test-tomlmojo: | ||
| name: Test TomlMojo | ||
| runs-on: ubuntu-22.04 | ||
| timeout-minutes: 15 | ||
| env: | ||
| DEBIAN_FRONTEND: noninteractive | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install pixi | ||
| run: curl -fsSL https://pixi.sh/install.sh | sh | ||
| - name: Add pixi to PATH | ||
| run: | | ||
| echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV | ||
| echo "$HOME/.pixi/bin" >> $GITHUB_PATH | ||
| - name: pixi install | ||
| run: pixi install | ||
| - name: Build packages | ||
| run: | | ||
| pixi run mojo package src/decimo | ||
| pixi run mojo package src/tomlmojo | ||
| cp decimo.mojopkg tests/ | ||
| cp decimo.mojopkg benches/ | ||
| mv tomlmojo.mojopkg tests/ | ||
| pixi run mojo package src/decimo && cp decimo.mojopkg tests/ | ||
| pixi run mojo package src/tomlmojo && mv tomlmojo.mojopkg tests/ | ||
| - name: Run tests | ||
| run: bash ./tests/test_tomlmojo.sh | ||
|
|
||
| # ── Test: CLI ──────────────────────────────────────────────────────────────── | ||
| test-cli: | ||
| name: Test CLI | ||
| runs-on: ubuntu-22.04 | ||
| timeout-minutes: 15 | ||
| env: | ||
| DEBIAN_FRONTEND: noninteractive | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install pixi | ||
| run: curl -fsSL https://pixi.sh/install.sh | sh | ||
| - name: Add pixi to PATH | ||
| run: | | ||
| echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV | ||
| echo "$HOME/.pixi/bin" >> $GITHUB_PATH | ||
| - name: pixi install | ||
| run: pixi install | ||
| - name: Build CLI binary | ||
| run: pixi run buildcli | ||
| - name: Run tests | ||
| run: bash ./tests/test_cli.sh | ||
|
|
||
| # ── Test: Python bindings ──────────────────────────────────────────────────── | ||
| test-python: | ||
| name: Test Python bindings | ||
| runs-on: ubuntu-22.04 | ||
| timeout-minutes: 15 | ||
| env: | ||
| DEBIAN_FRONTEND: noninteractive | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install pixi | ||
| run: curl -fsSL https://pixi.sh/install.sh | sh | ||
| - name: Add pixi to PATH | ||
| run: | | ||
| bash ./tests/test_all.sh | ||
| bash ./tests/test_toml.sh | ||
| echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV | ||
| echo "$HOME/.pixi/bin" >> $GITHUB_PATH | ||
| - name: pixi install | ||
| run: pixi install | ||
| - name: Build & run Python tests | ||
| run: pixi run testpy | ||
|
|
||
|
Comment on lines
+201
to
203
|
||
| - name: Install pre-commit | ||
| # ── Format check ───────────────────────────────────────────────────────────── | ||
| format-check: | ||
| name: Format check | ||
| runs-on: ubuntu-22.04 | ||
| timeout-minutes: 10 | ||
| env: | ||
| DEBIAN_FRONTEND: noninteractive | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install pixi | ||
| run: curl -fsSL https://pixi.sh/install.sh | sh | ||
| - name: Add pixi to PATH | ||
| run: | | ||
| pip install pre-commit | ||
| pre-commit install | ||
|
|
||
| - name: Run pre-commit | ||
| run: | | ||
| pixi install | ||
| pre-commit run --all-files | ||
| echo "PIXI_HOME=$HOME/.pixi" >> $GITHUB_ENV | ||
| echo "$HOME/.pixi/bin" >> $GITHUB_PATH | ||
| - name: pixi install | ||
| run: pixi install | ||
| - name: Install pre-commit | ||
| run: pip install pre-commit | ||
| - name: Run format check | ||
| run: pre-commit run --all-files | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,4 +24,8 @@ kgen.trace.json* | |
| /test*.py | ||
| local | ||
| # CLI binary | ||
| /decimo | ||
| /decimo | ||
| # Python build artifacts | ||
| *.so | ||
| __pycache__/ | ||
| *.pyc | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -186,7 +186,7 @@ | |||||
| same "printed page" as the copyright notice for easier | ||||||
| identification within third-party archives. | ||||||
|
|
||||||
| Copyright [yyyy] [name of copyright owner] | ||||||
| Copyright 2026 Yuhao Zhu | ||||||
|
||||||
| Copyright 2026 Yuhao Zhu | |
| Copyright [yyyy] [name of copyright owner] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow runs
pixi run build, butpixi.tomlno longer defines abuildtask (it definesbuildcli). This step will fail at runtime unlessbuildis reintroduced or the workflow is updated to call the new task name.