Skip to content

Commit

Permalink
feat: v2 - leveraging new AlgoKit interfaces and support for algokit-…
Browse files Browse the repository at this point in the history
…utils-py v3 (#33)

BREAKING CHANGE: Generator overhaul with ARC-56 support and TypeScript alignment

- Complete generator rewrite using new core interfaces:
  - Split `generator.py` into specialized generators for `Arc56Contract`, `AppClient`, and `AppFactory`
  - Added struct handling and default argument support from type hints
- Aligned generator output with TypeScript implementation:
  - Consistent ARC-32 spec formatting (single-line JSON)
  - Matching transaction field handling and nested struct resolution
- Removed deprecated `AlgorandClientProtocol`
- Added support for app call inner transaction fee coverage
- Updated CI to test Python 3.10, 3.11, and 3.12

> Migration Required: Client generation now uses new ARC-56 based interfaces. Update generator calls to use new specialized generators and consult migration guide for struct handling changes. Requires algokit-utils v3
  • Loading branch information
aorumbayev authored Jan 29, 2025
1 parent 49a1136 commit de55aae
Show file tree
Hide file tree
Showing 78 changed files with 88,665 additions and 6,893 deletions.
101 changes: 50 additions & 51 deletions .github/workflows/build-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,63 @@ name: Build, Test and Publish Python
on: [workflow_call]

jobs:
build-python:
strategy:
matrix:
os: ["ubuntu-latest"]
# TODO: fix setuptools bug in 3.12, steps to reproduce (add 3.12 below)
python: ["3.10", "3.11"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
build-python:
strategy:
matrix:
os: ["ubuntu-latest"]
python: ["3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install pipx
run: |
python -m pip install --upgrade pip
python -m pip install pipx
python -m pipx ensurepath
- name: Install pipx
run: |
python -m pip install --upgrade pip
python -m pip install pipx
python -m pipx ensurepath
- name: Cache Poetry
uses: actions/cache@v2
with:
path: ~/.local/share/pipx/venvs/poetry
key: ${{ runner.os }}-poetry-${{ matrix.python }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-${{ matrix.python }}-
- name: Cache Poetry
uses: actions/cache@v4
with:
path: ~/.local/share/pipx/venvs/poetry
key: ${{ runner.os }}-poetry-${{ matrix.python }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-${{ matrix.python }}-
- name: Install poetry
run: pipx install poetry
- name: Install poetry
run: pipx install poetry

- name: Install dependencies
run: poetry install --no-interaction
- name: Install dependencies
run: poetry install --no-interaction

- name: Start LocalNet
shell: bash
run: |
pipx install algokit
algokit -v localnet start
sleep 10 # workaround for slow startup
- name: Start LocalNet
shell: bash
run: |
pipx install algokit
algokit -v localnet start
sleep 10 # workaround for slow startup
- name: pytest + coverage
shell: bash
run: poetry run pytest --junitxml=pytest-junit.xml --cov-report=term-missing:skip-covered --cov=src | tee pytest-coverage.txt
- name: pytest + coverage
shell: bash
run: poetry run pytest -n auto --junitxml=pytest-junit.xml --cov-report=term-missing:skip-covered --cov=src | tee pytest-coverage.txt

- name: Stop LocalNet
shell: bash
run: algokit localnet stop
- name: Stop LocalNet
shell: bash
run: algokit localnet stop

- name: pytest coverage comment - using Python 3.10 on ubuntu-latest
if: matrix.python == '3.10' && matrix.os == 'ubuntu-latest'
uses: MishaKav/pytest-coverage-comment@main
continue-on-error: true # forks fail to add a comment, so continue any way
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest-junit.xml
- name: pytest coverage comment - using Python 3.10 on ubuntu-latest
if: matrix.python == '3.10' && matrix.os == 'ubuntu-latest'
uses: MishaKav/pytest-coverage-comment@main
continue-on-error: true # forks fail to add a comment, so continue any way
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest-junit.xml

- name: Build Wheel
run: poetry build --format wheel
- name: Build Wheel
run: poetry build --format wheel
144 changes: 72 additions & 72 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -1,92 +1,92 @@
name: Continuous Delivery of Python package

on:
push:
branches:
- main
workflow_dispatch:
inputs:
production_release:
description: "Production release?"
type: boolean
required: true
default: true
push:
branches:
- main
workflow_dispatch:
inputs:
production_release:
description: "Production release?"
type: boolean
required: true
default: true

concurrency: release

permissions:
contents: write
packages: read
contents: write
packages: read

jobs:
ci-check-python:
name: Check Python
uses: ./.github/workflows/check-python.yaml
ci-check-python:
name: Check Python
uses: ./.github/workflows/check-python.yaml

ci-build-python:
name: Build Python
uses: ./.github/workflows/build-python.yaml
needs: ci-check-python
ci-build-python:
name: Build Python
uses: ./.github/workflows/build-python.yaml
needs: ci-check-python

release:
name: Release Library
needs: ci-build-python
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
contents: write
packages: read
release:
name: Release Library
needs: ci-build-python
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
contents: write
packages: read

steps:
- uses: actions/checkout@v3
with:
# Fetch entire repository history so we can determine version number from it
fetch-depth: 0
steps:
- uses: actions/checkout@v3
with:
# Fetch entire repository history so we can determine version number from it
fetch-depth: 0

- name: Install poetry
run: pipx install poetry
- name: Install poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "poetry"
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "poetry"

- name: Install dependencies
run: poetry install --no-interaction --no-root
- name: Install dependencies
run: poetry install --no-interaction --no-root

- name: Get branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: get_branch
- name: Get branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: get_branch

- name: Set Git user as GitHub actions
run: git config --global user.email "[email protected]" && git config --global user.name "github-actions"
- name: Set Git user as GitHub actions
run: git config --global user.email "[email protected]" && git config --global user.name "github-actions"

- name: Create Continuous Deployment - Beta (non-prod)
if: steps.get_branch.outputs.branch == 'main' && !inputs.production_release
run: |
poetry run semantic-release \
-v DEBUG \
--prerelease \
--define=branch=main \
publish
gh release edit --prerelease "v$(poetry run semantic-release print-version --current)"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Continuous Deployment - Beta (non-prod)
if: steps.get_branch.outputs.branch == 'main' && !inputs.production_release
run: |
poetry run semantic-release \
-v DEBUG \
--prerelease \
--define=branch=main \
publish
gh release edit --prerelease "v$(poetry run semantic-release print-version --current)"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Continuous Deployment - Production
if: steps.get_branch.outputs.branch == 'main' && inputs.production_release
run: |
poetry run semantic-release \
-v DEBUG \
--define=version_source="commit" \
--define=patch_without_tag=true \
--define=branch=main \
publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Continuous Deployment - Production
if: steps.get_branch.outputs.branch == 'main' && inputs.production_release
run: |
poetry run semantic-release \
-v DEBUG \
--define=version_source="commit" \
--define=patch_without_tag=true \
--define=branch=main \
publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
113 changes: 58 additions & 55 deletions .github/workflows/check-python.yaml
Original file line number Diff line number Diff line change
@@ -1,60 +1,63 @@
name: Check Python Code

on:
workflow_call:
workflow_call:

jobs:
check-python:
runs-on: "ubuntu-latest"
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install pipx
run: |
python -m pip install --upgrade pip
python -m pip install pipx
python -m pipx ensurepath
- name: Cache Poetry
uses: actions/cache@v2
with:
path: ~/.local/share/pipx/venvs/poetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install poetry
run: pipx install poetry

- name: Install dependencies
run: poetry install --no-interaction --no-root

- name: Audit with pip-audit
run: |
# audit non dev dependencies, no exclusions
poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt
# audit all dependencies, with exclusions.
# If a vulnerability is found in a dev dependency without an available fix,
# it can be temporarily ignored by adding --ignore-vuln e.g.
# --ignore-vuln "GHSA-hcpj-qp55-gfph" # GitPython vulnerability, dev only dependency
poetry run pip-audit
- name: Check formatting with Ruff
run: |
# stop the build if there are files that don't meet formatting requirements
poetry run ruff format --check .
- name: Check linting with Ruff
run: |
# stop the build if there are Python syntax errors or undefined names
poetry run ruff .
- name: Check types with mypy
run: poetry run mypy
check-python:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install pipx
run: |
python -m pip install --upgrade pip
python -m pip install pipx
python -m pipx ensurepath
- name: Cache Poetry
uses: actions/cache@v4
with:
path: ~/.local/share/pipx/venvs/poetry
key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-${{ matrix.python-version }}-
- name: Install poetry
run: pipx install poetry

- name: Install dependencies
run: poetry install --no-interaction --no-root

- name: Audit with pip-audit
run: |
# audit non dev dependencies, no exclusions
poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt
# audit all dependencies, with exclusions.
# If a vulnerability is found in a dev dependency without an available fix,
# it can be temporarily ignored by adding --ignore-vuln e.g.
# --ignore-vuln "GHSA-hcpj-qp55-gfph" # GitPython vulnerability, dev only dependency
poetry run pip-audit
- name: Check formatting with Ruff
run: |
# stop the build if there are files that don't meet formatting requirements
poetry run ruff format --check .
- name: Check linting with Ruff
run: |
# stop the build if there are Python syntax errors or undefined names
poetry run ruff check .
- name: Check types with mypy
run: poetry run mypy
Loading

1 comment on commit de55aae

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/algokit_client_generator
   __main__.py220%1–3
   cli.py48480%1–87
   document.py82890%44, 47, 49–50, 55, 69, 74–75
   generator.py31197%23
   spec.py2071692%86, 116–119, 219–223, 253, 269, 350–351, 395, 410
   utils.py2194878%11, 20, 24, 28, 32, 36, 40, 44, 55, 58, 63–64, 75–76, 82–84, 89–91, 94–96, 99, 102, 105, 108–110, 159–160, 194, 198, 201–202, 218, 220, 231–232, 249, 261–264, 268, 278, 281, 283
src/algokit_client_generator/generators
   composer.py51198%29
   typed_client.py330898%105, 234, 333, 632, 722, 732, 771, 880
   typed_factory.py219399%64, 94, 226
TOTAL126013589% 

Tests Skipped Failures Errors Time
40 0 💤 0 ❌ 0 🔥 17.917s ⏱️

Please sign in to comment.