Skip to content

Commit

Permalink
feat: initial setup for the puya template (#1)
Browse files Browse the repository at this point in the history
* feat: initial draft; wip

* refactor: refining codebase

* chore: refining tests
  • Loading branch information
aorumbayev authored Dec 14, 2023
1 parent a241b02 commit a8c9a1b
Show file tree
Hide file tree
Showing 418 changed files with 4,278 additions and 6,427 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
- name: Install algokit
run: pipx install algokit

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

- name: Install dependencies
Expand Down
40 changes: 21 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
<div align="center">
<a href="https://github.com/algorandfoundation/algokit-beaker-default-template"><img src="https://bafybeiguaon767jcuyawcee4prtzx7om6kpbe5g66zck5pgbpd5mmucamu.ipfs.nftstorage.link/" width=60%></a>
<a href="https://github.com/algorandfoundation/algokit-puya-template"><img src="https://bafkreihnmpvtrgloxz5exuk2ybfxkeq5b2ka5vxfjejjslswl5ecr7pvpy.ipfs.nftstorage.link/" width=60%></a>
</div>

<p align="center">
<a target="_blank" href="https://github.com/algorandfoundation/algokit-cli"><img src="https://img.shields.io/badge/docs-repository-00dc94?logo=github&style=flat.svg" /></a>
<a target="_blank" href="https://developer.algorand.org/algokit/"><img src="https://img.shields.io/badge/learn-AlgoKit-00dc94?logo=algorand&mac=flat.svg" /></a>
<a target="_blank" href="https://github.com/algorandfoundation/algokit-beaker-default-template"><img src="https://img.shields.io/github/stars/algorandfoundation/algokit-beaker-default-template?color=00dc94&logo=star&style=flat" /></a>
<a target="_blank" href="https://developer.algorand.org/algokit/"><img src="https://vbr.wocr.tk/badge?page_id=algorandfoundation%2Falgokit-beaker-default-template&color=%2300dc94&style=flat" /></a>
<a target="_blank" href="https://github.com/algorandfoundation/algokit-puya-template"><img src="https://img.shields.io/github/stars/algorandfoundation/algokit-puya-template?color=00dc94&logo=star&style=flat" /></a>
<a target="_blank" href="https://developer.algorand.org/algokit/"><img src="https://vbr.wocr.tk/badge?page_id=algorandfoundation%2Falgokit-puya-template&color=%2300dc94&style=flat" /></a>
</p>

---

This template provides a production-ready baseline for developing and deploying [Beaker](https://github.com/algorand-devrel/beaker) smart contracts.
This template provides a production-ready baseline for developing and deploying [Puya](https://github.com/algorand-devrel/puya) smart contracts.

To use it [install AlgoKit](https://github.com/algorandfoundation/algokit-cli#readme) and then either pass in `-t beaker_production` to `algokit init` or select the `beaker_production` template.
To use it [install AlgoKit](https://github.com/algorandfoundation/algokit-cli#readme) and then either pass in `-t puya` to `algokit init` or select the `puya` template.

This is one of the official templates used by AlgoKit to initialize an Algorand smart contract project. It's a [Copier template](https://copier.readthedocs.io/en/stable/).

> Please note `Puya` smart contract development language is currently in alpha / developer preview. It is not recommended for production usage yet.
## Features

This template supports the following features:

- Compilation of [multiple Beaker contracts](template_content/smart_contracts/config.py) to a [predictable folder location and file layout](template_content/smart_contracts/__main__.py) where they can be deployed
- Deploy-time immutability and permanence control
- [Poetry](https://python-poetry.org/) for Python dependency management and virtual environment management
- Linting via [Ruff](https://github.com/charliermarsh/ruff) or [Flake8](https://flake8.pycqa.org/en/latest/)
- Formatting via [Black](https://github.com/psf/black)
- Type checking via [mypy](https://mypy-lang.org/)
- Testing via pytest (not yet used)
- Dependency vulnerability scanning via pip-audit (not yet used)
- VS Code configuration (linting, formatting, breakpoint debugging)
- dotenv (.env) file for configuration
- Automated testing of the compiled smart contracts
- [Output stability](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/articles/output_stability.md) tests of the TEAL output
- CI/CD pipeline using GitHub Actions:
- - Optionally pick deployments to Netlify or Vercel
- Compilation of [multiple Puya contracts](template_content/smart_contracts/config.py) to a [predictable folder location and file layout](template_content/smart_contracts/__main__.py) where they can be deployed
- Deploy-time immutability and permanence control
- [Poetry](https://python-poetry.org/) for Python dependency management and virtual environment management
- Linting via [Ruff](https://github.com/charliermarsh/ruff) or [Flake8](https://flake8.pycqa.org/en/latest/)
- Formatting via [Black](https://github.com/psf/black)
- Type checking via [mypy](https://mypy-lang.org/)
- Testing via pytest (not yet used)
- Dependency vulnerability scanning via pip-audit (not yet used)
- VS Code configuration (linting, formatting, breakpoint debugging)
- dotenv (.env) file for configuration
- Automated testing of the compiled smart contracts
- [Output stability](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/articles/output_stability.md) tests of the TEAL output
- CI/CD pipeline using GitHub Actions:
- - Optionally pick deployments to Netlify or Vercel

# Getting started

Expand Down
44 changes: 11 additions & 33 deletions copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ project_name:
help: Name for this project.
placeholder: "algorand-app"

preset_name:
type: str
help: Name of the preset to use. Starter is optimal for simpler projects, Production is optimal for more complex projects that require CI/CD and other features.
choices:
Starter: "starter"
Production: "production"
default: "starter"
# preset_name:
# type: str
# help: Name of the preset to use. Starter is optimal for simpler projects, Production is optimal for more complex projects that require CI/CD and other features.
# choices:
# Starter: "starter"
# Production: "production"
# default: "starter"

contract_name:
type: str
Expand Down Expand Up @@ -58,17 +58,12 @@ deployment_language:
python_linter:
type: str
help: Do you want to use a Python linter?
when: "{{ preset_name == 'production' }}"
choices:
Ruff: "ruff"
Flake8: "flake8"
No thanks: "none"
default: |-
{% if preset_name == 'production' -%}
ruff
{%- else -%}
none
{%- endif %}
ruff
use_python_black:
type: bool
Expand All @@ -77,14 +72,9 @@ use_python_black:

use_python_mypy:
type: bool
when: "{{ preset_name == 'production' }}"
help: Do you want to use a Python type checker (via mypy)?
default: |-
{% if preset_name == 'production' -%}
yes
{%- else -%}
no
{%- endif %}
yes
use_python_pytest:
type: bool
Expand All @@ -93,35 +83,23 @@ use_python_pytest:

use_python_pip_audit:
type: bool
when: "{{ preset_name == 'production' }}"
help: Do you want to include Python dependency vulnerability scanning (via pip-audit)?
default: yes

use_github_actions:
type: bool
when: "{{ preset_name == 'production' }}"
help: Do you want to include Github Actions workflows for build and testnet deployment?
default: |-
{% if preset_name == 'production' -%}
yes
{%- else -%}
no
{%- endif %}
yes
use_pre_commit:
type: bool
when: "{{ preset_name == 'production' }}"
help: Do you want to include pre-commit for linting, type checking and formatting?
default: |-
{% if preset_name == 'production' -%}
yes
{%- else -%}
no
{%- endif %}
yes
use_dispenser:
type: bool
when: "{{ preset_name == 'production' }}"
help: Do you want to fund your deployment account using an optional dispenser account?
default: no

Expand Down
Loading

0 comments on commit a8c9a1b

Please sign in to comment.