From 64c9245af78241d0e9cdb1613042790ec405fb58 Mon Sep 17 00:00:00 2001 From: Al Date: Fri, 18 Oct 2024 13:45:50 +0200 Subject: [PATCH] fix: mypy 1.11 pin; skipping clients on lsig compile; remove package-mode (#74) * fix: mypy 1.11 pin; skipping clients on lsig compile; remove package-mode * chore: disabling tealer with snapshots by default (regular audit still runs) * fix: remove usage of poetry export --- .../.algokit.toml | 3 +-- ...ction-python-smart-contract-python-ci.yaml | 8 +++++-- .../.gitignore | 2 +- .../.pre-commit-config.yaml | 21 ++++++++++--------- .../pyproject.toml | 3 +-- .../smart_contracts/_helpers/build.py | 9 ++++---- .../.algokit.toml | 3 +-- ...n-python-smart-contract-typescript-ci.yaml | 8 +++++-- .../.gitignore | 2 +- .../.pre-commit-config.yaml | 21 ++++++++++--------- .../pyproject.toml | 3 +-- .../smart_contracts/_helpers/build.py | 9 ++++---- .../.gitignore | 2 +- .../pyproject.toml | 1 - .../smart_contracts/_helpers/build.py | 9 ++++---- .../.gitignore | 2 +- .../pyproject.toml | 1 - .../smart_contracts/_helpers/build.py | 9 ++++---- examples/production_python/.algokit.toml | 3 +-- .../workflows/production-python-ci.yaml | 8 +++++-- examples/production_python/.gitignore | 2 +- .../production_python/.pre-commit-config.yaml | 21 ++++++++++--------- examples/production_python/pyproject.toml | 3 +-- .../smart_contracts/_helpers/build.py | 9 ++++---- examples/starter_python/.gitignore | 2 +- examples/starter_python/pyproject.toml | 1 - .../smart_contracts/_helpers/build.py | 9 ++++---- template_content/.algokit.toml.jinja | 3 +-- template_content/.gitignore.jinja | 2 +- template_content/pyproject.toml.jinja | 3 +-- .../smart_contracts/_helpers/build.py.jinja | 9 ++++---- ...roject_name_kebab.jinja') %}-ci.yaml.jinja | 8 +++++-- ...%}.pre-commit-config.yaml{% endif %}.jinja | 21 ++++++++++--------- 33 files changed, 118 insertions(+), 102 deletions(-) diff --git a/examples/generators/production_python_smart_contract_python/.algokit.toml b/examples/generators/production_python_smart_contract_python/.algokit.toml index 181101f..69bba4a 100644 --- a/examples/generators/production_python_smart_contract_python/.algokit.toml +++ b/examples/generators/production_python_smart_contract_python/.algokit.toml @@ -33,8 +33,7 @@ test = { commands = [ 'poetry run pytest', ], description = 'Run smart contract tests' } audit = { commands = [ - 'poetry export --without=dev -o requirements.txt', - 'poetry run pip-audit -r requirements.txt', + 'poetry run pip-audit', ], description = 'Audit with pip-audit' } lint = { commands = [ 'poetry run black --check --diff .', diff --git a/examples/generators/production_python_smart_contract_python/.github/workflows/production-python-smart-contract-python-ci.yaml b/examples/generators/production_python_smart_contract_python/.github/workflows/production-python-smart-contract-python-ci.yaml index de310d8..ce0bd08 100644 --- a/examples/generators/production_python_smart_contract_python/.github/workflows/production-python-smart-contract-python-ci.yaml +++ b/examples/generators/production_python_smart_contract_python/.github/workflows/production-python-smart-contract-python-ci.yaml @@ -53,8 +53,12 @@ jobs: - name: Scan TEAL files for issues run: algokit project run audit-teal --project-name 'production_python_smart_contract_python' - - name: Check output stability of the smart contracts - run: algokit project run ci-teal-diff --project-name 'production_python_smart_contract_python' + # # Uncomment to enable TEAL static analysis with snapshoting using Tealer package + # # Would first require running locally using audit-teal command and committing the snapshots into source control + # # Please note, tealer has a known bug that may result in large snapshot file sizes, track resolution here: + # # https://github.com/crytic/tealer/issues/101 + # - name: Check output stability of the smart contracts + # run: algokit project run ci-teal-diff --project-name 'production_python_smart_contract_python' - name: Run deployer against LocalNet run: algokit project deploy localnet --project-name 'production_python_smart_contract_python' diff --git a/examples/generators/production_python_smart_contract_python/.gitignore b/examples/generators/production_python_smart_contract_python/.gitignore index a858d63..070829c 100644 --- a/examples/generators/production_python_smart_contract_python/.gitignore +++ b/examples/generators/production_python_smart_contract_python/.gitignore @@ -176,5 +176,5 @@ node_modules # AlgoKit debug_traces/ -.algokit/static-analysis/tealer/ +.algokit/static-analysis/ # Replace with .algokit/static-analysis/tealer/ to enable snapshot checks in CI .algokit/sources diff --git a/examples/generators/production_python_smart_contract_python/.pre-commit-config.yaml b/examples/generators/production_python_smart_contract_python/.pre-commit-config.yaml index 69d8fdf..7e125ca 100644 --- a/examples/generators/production_python_smart_contract_python/.pre-commit-config.yaml +++ b/examples/generators/production_python_smart_contract_python/.pre-commit-config.yaml @@ -36,13 +36,14 @@ repos: minimum_pre_commit_version: '2.9.2' files: '^(src|tests)/' - - id: tealer - name: tealer - description: "Run AlgoKit `Tealer` for TEAL static analysis" - entry: algokit - language: system - args: [project, run, "audit-teal"] - require_serial: false - additional_dependencies: [] - minimum_pre_commit_version: "0" - files: '^.*\.teal$' + # # Uncomment to enable TEAL static analysis using Tealer package + # - id: tealer + # name: tealer + # description: "Run AlgoKit `Tealer` for TEAL static analysis" + # entry: algokit + # language: system + # args: [project, run, "audit-teal"] + # require_serial: false + # additional_dependencies: [] + # minimum_pre_commit_version: "0" + # files: '^.*\.teal$' diff --git a/examples/generators/production_python_smart_contract_python/pyproject.toml b/examples/generators/production_python_smart_contract_python/pyproject.toml index 99fda3c..64cf76d 100644 --- a/examples/generators/production_python_smart_contract_python/pyproject.toml +++ b/examples/generators/production_python_smart_contract_python/pyproject.toml @@ -4,7 +4,6 @@ version = "0.1.0" description = "Algorand smart contracts" authors = ["None "] readme = "README.md" -package-mode = false [tool.poetry.dependencies] python = "^3.12" @@ -17,7 +16,7 @@ algorand-python-testing = "^0.4.0" algokit-client-generator = "^1.1.3" black = {extras = ["d"], version = "*"} ruff = "^0.1.6" -mypy = "*" +mypy = "1.11.0" pytest = "*" pytest-cov = "*" pip-audit = "*" diff --git a/examples/generators/production_python_smart_contract_python/smart_contracts/_helpers/build.py b/examples/generators/production_python_smart_contract_python/smart_contracts/_helpers/build.py index 20770e8..0afee9c 100644 --- a/examples/generators/production_python_smart_contract_python/smart_contracts/_helpers/build.py +++ b/examples/generators/production_python_smart_contract_python/smart_contracts/_helpers/build.py @@ -41,12 +41,13 @@ def build(output_dir: Path, contract_path: Path) -> Path: raise Exception(f"Could not build contract:\n{build_result.stdout}") app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")] - + app_spec_file_name = None for app_spec_file_name in app_spec_file_names: if app_spec_file_name is None: - raise Exception( - "Could not generate typed client, .arc32.json file not found" + logger.warning( + "No '*.arc32.json' file found (likely a logic signature being compiled). Skipping client generation." ) + continue print(app_spec_file_name) generate_result = subprocess.run( [ @@ -72,4 +73,4 @@ def build(output_dir: Path, contract_path: Path) -> Path: f"Could not generate typed client:\n{generate_result.stdout}" ) - return output_dir / app_spec_file_name + return output_dir / app_spec_file_name if app_spec_file_name else output_dir diff --git a/examples/generators/production_python_smart_contract_typescript/.algokit.toml b/examples/generators/production_python_smart_contract_typescript/.algokit.toml index be94726..1719c4e 100644 --- a/examples/generators/production_python_smart_contract_typescript/.algokit.toml +++ b/examples/generators/production_python_smart_contract_typescript/.algokit.toml @@ -33,8 +33,7 @@ test = { commands = [ 'npm run test', ], description = 'Run smart contract tests using Jest' } audit = { commands = [ - 'poetry export --without=dev -o requirements.txt', - 'poetry run pip-audit -r requirements.txt', + 'poetry run pip-audit', ], description = 'Audit with pip-audit' } lint = { commands = [ 'poetry run black --check --diff .', diff --git a/examples/generators/production_python_smart_contract_typescript/.github/workflows/production-python-smart-contract-typescript-ci.yaml b/examples/generators/production_python_smart_contract_typescript/.github/workflows/production-python-smart-contract-typescript-ci.yaml index abda5f6..6d14b04 100644 --- a/examples/generators/production_python_smart_contract_typescript/.github/workflows/production-python-smart-contract-typescript-ci.yaml +++ b/examples/generators/production_python_smart_contract_typescript/.github/workflows/production-python-smart-contract-typescript-ci.yaml @@ -53,8 +53,12 @@ jobs: - name: Scan TEAL files for issues run: algokit project run audit-teal --project-name 'production_python_smart_contract_typescript' - - name: Check output stability of the smart contracts - run: algokit project run ci-teal-diff --project-name 'production_python_smart_contract_typescript' + # # Uncomment to enable TEAL static analysis with snapshoting using Tealer package + # # Would first require running locally using audit-teal command and committing the snapshots into source control + # # Please note, tealer has a known bug that may result in large snapshot file sizes, track resolution here: + # # https://github.com/crytic/tealer/issues/101 + # - name: Check output stability of the smart contracts + # run: algokit project run ci-teal-diff --project-name 'production_python_smart_contract_typescript' - name: Run deployer against LocalNet run: algokit project deploy localnet --project-name 'production_python_smart_contract_typescript' diff --git a/examples/generators/production_python_smart_contract_typescript/.gitignore b/examples/generators/production_python_smart_contract_typescript/.gitignore index a858d63..070829c 100644 --- a/examples/generators/production_python_smart_contract_typescript/.gitignore +++ b/examples/generators/production_python_smart_contract_typescript/.gitignore @@ -176,5 +176,5 @@ node_modules # AlgoKit debug_traces/ -.algokit/static-analysis/tealer/ +.algokit/static-analysis/ # Replace with .algokit/static-analysis/tealer/ to enable snapshot checks in CI .algokit/sources diff --git a/examples/generators/production_python_smart_contract_typescript/.pre-commit-config.yaml b/examples/generators/production_python_smart_contract_typescript/.pre-commit-config.yaml index 69d8fdf..7e125ca 100644 --- a/examples/generators/production_python_smart_contract_typescript/.pre-commit-config.yaml +++ b/examples/generators/production_python_smart_contract_typescript/.pre-commit-config.yaml @@ -36,13 +36,14 @@ repos: minimum_pre_commit_version: '2.9.2' files: '^(src|tests)/' - - id: tealer - name: tealer - description: "Run AlgoKit `Tealer` for TEAL static analysis" - entry: algokit - language: system - args: [project, run, "audit-teal"] - require_serial: false - additional_dependencies: [] - minimum_pre_commit_version: "0" - files: '^.*\.teal$' + # # Uncomment to enable TEAL static analysis using Tealer package + # - id: tealer + # name: tealer + # description: "Run AlgoKit `Tealer` for TEAL static analysis" + # entry: algokit + # language: system + # args: [project, run, "audit-teal"] + # require_serial: false + # additional_dependencies: [] + # minimum_pre_commit_version: "0" + # files: '^.*\.teal$' diff --git a/examples/generators/production_python_smart_contract_typescript/pyproject.toml b/examples/generators/production_python_smart_contract_typescript/pyproject.toml index b0e4ada..0db3c06 100644 --- a/examples/generators/production_python_smart_contract_typescript/pyproject.toml +++ b/examples/generators/production_python_smart_contract_typescript/pyproject.toml @@ -4,7 +4,6 @@ version = "0.1.0" description = "Algorand smart contracts" authors = ["None "] readme = "README.md" -package-mode = false [tool.poetry.dependencies] python = "^3.12" @@ -16,7 +15,7 @@ algorand-python-testing = "^0.4.0" [tool.poetry.group.dev.dependencies] black = {extras = ["d"], version = "*"} ruff = "^0.1.6" -mypy = "*" +mypy = "1.11.0" pip-audit = "*" pre-commit = "*" puyapy = "*" diff --git a/examples/generators/production_python_smart_contract_typescript/smart_contracts/_helpers/build.py b/examples/generators/production_python_smart_contract_typescript/smart_contracts/_helpers/build.py index ea0a8d5..2694825 100644 --- a/examples/generators/production_python_smart_contract_typescript/smart_contracts/_helpers/build.py +++ b/examples/generators/production_python_smart_contract_typescript/smart_contracts/_helpers/build.py @@ -41,12 +41,13 @@ def build(output_dir: Path, contract_path: Path) -> Path: raise Exception(f"Could not build contract:\n{build_result.stdout}") app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")] - + app_spec_file_name = None for app_spec_file_name in app_spec_file_names: if app_spec_file_name is None: - raise Exception( - "Could not generate typed client, .arc32.json file not found" + logger.warning( + "No '*.arc32.json' file found (likely a logic signature being compiled). Skipping client generation." ) + continue print(app_spec_file_name) generate_result = subprocess.run( [ @@ -72,4 +73,4 @@ def build(output_dir: Path, contract_path: Path) -> Path: f"Could not generate typed client:\n{generate_result.stdout}" ) - return output_dir / app_spec_file_name + return output_dir / app_spec_file_name if app_spec_file_name else output_dir diff --git a/examples/generators/starter_python_smart_contract_python/.gitignore b/examples/generators/starter_python_smart_contract_python/.gitignore index a858d63..070829c 100644 --- a/examples/generators/starter_python_smart_contract_python/.gitignore +++ b/examples/generators/starter_python_smart_contract_python/.gitignore @@ -176,5 +176,5 @@ node_modules # AlgoKit debug_traces/ -.algokit/static-analysis/tealer/ +.algokit/static-analysis/ # Replace with .algokit/static-analysis/tealer/ to enable snapshot checks in CI .algokit/sources diff --git a/examples/generators/starter_python_smart_contract_python/pyproject.toml b/examples/generators/starter_python_smart_contract_python/pyproject.toml index 8000ea4..26ee7c1 100644 --- a/examples/generators/starter_python_smart_contract_python/pyproject.toml +++ b/examples/generators/starter_python_smart_contract_python/pyproject.toml @@ -4,7 +4,6 @@ version = "0.1.0" description = "Algorand smart contracts" authors = ["None "] readme = "README.md" -package-mode = false [tool.poetry.dependencies] python = "^3.12" diff --git a/examples/generators/starter_python_smart_contract_python/smart_contracts/_helpers/build.py b/examples/generators/starter_python_smart_contract_python/smart_contracts/_helpers/build.py index 20770e8..0afee9c 100644 --- a/examples/generators/starter_python_smart_contract_python/smart_contracts/_helpers/build.py +++ b/examples/generators/starter_python_smart_contract_python/smart_contracts/_helpers/build.py @@ -41,12 +41,13 @@ def build(output_dir: Path, contract_path: Path) -> Path: raise Exception(f"Could not build contract:\n{build_result.stdout}") app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")] - + app_spec_file_name = None for app_spec_file_name in app_spec_file_names: if app_spec_file_name is None: - raise Exception( - "Could not generate typed client, .arc32.json file not found" + logger.warning( + "No '*.arc32.json' file found (likely a logic signature being compiled). Skipping client generation." ) + continue print(app_spec_file_name) generate_result = subprocess.run( [ @@ -72,4 +73,4 @@ def build(output_dir: Path, contract_path: Path) -> Path: f"Could not generate typed client:\n{generate_result.stdout}" ) - return output_dir / app_spec_file_name + return output_dir / app_spec_file_name if app_spec_file_name else output_dir diff --git a/examples/generators/starter_python_smart_contract_typescript/.gitignore b/examples/generators/starter_python_smart_contract_typescript/.gitignore index a858d63..070829c 100644 --- a/examples/generators/starter_python_smart_contract_typescript/.gitignore +++ b/examples/generators/starter_python_smart_contract_typescript/.gitignore @@ -176,5 +176,5 @@ node_modules # AlgoKit debug_traces/ -.algokit/static-analysis/tealer/ +.algokit/static-analysis/ # Replace with .algokit/static-analysis/tealer/ to enable snapshot checks in CI .algokit/sources diff --git a/examples/generators/starter_python_smart_contract_typescript/pyproject.toml b/examples/generators/starter_python_smart_contract_typescript/pyproject.toml index 7db2d1f..39ddab1 100644 --- a/examples/generators/starter_python_smart_contract_typescript/pyproject.toml +++ b/examples/generators/starter_python_smart_contract_typescript/pyproject.toml @@ -4,7 +4,6 @@ version = "0.1.0" description = "Algorand smart contracts" authors = ["None "] readme = "README.md" -package-mode = false [tool.poetry.dependencies] python = "^3.12" diff --git a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/_helpers/build.py b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/_helpers/build.py index ea0a8d5..2694825 100644 --- a/examples/generators/starter_python_smart_contract_typescript/smart_contracts/_helpers/build.py +++ b/examples/generators/starter_python_smart_contract_typescript/smart_contracts/_helpers/build.py @@ -41,12 +41,13 @@ def build(output_dir: Path, contract_path: Path) -> Path: raise Exception(f"Could not build contract:\n{build_result.stdout}") app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")] - + app_spec_file_name = None for app_spec_file_name in app_spec_file_names: if app_spec_file_name is None: - raise Exception( - "Could not generate typed client, .arc32.json file not found" + logger.warning( + "No '*.arc32.json' file found (likely a logic signature being compiled). Skipping client generation." ) + continue print(app_spec_file_name) generate_result = subprocess.run( [ @@ -72,4 +73,4 @@ def build(output_dir: Path, contract_path: Path) -> Path: f"Could not generate typed client:\n{generate_result.stdout}" ) - return output_dir / app_spec_file_name + return output_dir / app_spec_file_name if app_spec_file_name else output_dir diff --git a/examples/production_python/.algokit.toml b/examples/production_python/.algokit.toml index 6093afd..1f0b2c2 100644 --- a/examples/production_python/.algokit.toml +++ b/examples/production_python/.algokit.toml @@ -33,8 +33,7 @@ test = { commands = [ 'poetry run pytest', ], description = 'Run smart contract tests' } audit = { commands = [ - 'poetry export --without=dev -o requirements.txt', - 'poetry run pip-audit -r requirements.txt', + 'poetry run pip-audit', ], description = 'Audit with pip-audit' } lint = { commands = [ 'poetry run black --check --diff .', diff --git a/examples/production_python/.github/workflows/production-python-ci.yaml b/examples/production_python/.github/workflows/production-python-ci.yaml index 2019e01..06d1499 100644 --- a/examples/production_python/.github/workflows/production-python-ci.yaml +++ b/examples/production_python/.github/workflows/production-python-ci.yaml @@ -53,8 +53,12 @@ jobs: - name: Scan TEAL files for issues run: algokit project run audit-teal --project-name 'production_python' - - name: Check output stability of the smart contracts - run: algokit project run ci-teal-diff --project-name 'production_python' + # # Uncomment to enable TEAL static analysis with snapshoting using Tealer package + # # Would first require running locally using audit-teal command and committing the snapshots into source control + # # Please note, tealer has a known bug that may result in large snapshot file sizes, track resolution here: + # # https://github.com/crytic/tealer/issues/101 + # - name: Check output stability of the smart contracts + # run: algokit project run ci-teal-diff --project-name 'production_python' - name: Run deployer against LocalNet run: algokit project deploy localnet --project-name 'production_python' diff --git a/examples/production_python/.gitignore b/examples/production_python/.gitignore index a858d63..070829c 100644 --- a/examples/production_python/.gitignore +++ b/examples/production_python/.gitignore @@ -176,5 +176,5 @@ node_modules # AlgoKit debug_traces/ -.algokit/static-analysis/tealer/ +.algokit/static-analysis/ # Replace with .algokit/static-analysis/tealer/ to enable snapshot checks in CI .algokit/sources diff --git a/examples/production_python/.pre-commit-config.yaml b/examples/production_python/.pre-commit-config.yaml index 69d8fdf..7e125ca 100644 --- a/examples/production_python/.pre-commit-config.yaml +++ b/examples/production_python/.pre-commit-config.yaml @@ -36,13 +36,14 @@ repos: minimum_pre_commit_version: '2.9.2' files: '^(src|tests)/' - - id: tealer - name: tealer - description: "Run AlgoKit `Tealer` for TEAL static analysis" - entry: algokit - language: system - args: [project, run, "audit-teal"] - require_serial: false - additional_dependencies: [] - minimum_pre_commit_version: "0" - files: '^.*\.teal$' + # # Uncomment to enable TEAL static analysis using Tealer package + # - id: tealer + # name: tealer + # description: "Run AlgoKit `Tealer` for TEAL static analysis" + # entry: algokit + # language: system + # args: [project, run, "audit-teal"] + # require_serial: false + # additional_dependencies: [] + # minimum_pre_commit_version: "0" + # files: '^.*\.teal$' diff --git a/examples/production_python/pyproject.toml b/examples/production_python/pyproject.toml index d5d82aa..72e4923 100644 --- a/examples/production_python/pyproject.toml +++ b/examples/production_python/pyproject.toml @@ -4,7 +4,6 @@ version = "0.1.0" description = "Algorand smart contracts" authors = ["None "] readme = "README.md" -package-mode = false [tool.poetry.dependencies] python = "^3.12" @@ -17,7 +16,7 @@ algorand-python-testing = "^0.4.0" algokit-client-generator = "^1.1.3" black = {extras = ["d"], version = "*"} ruff = "^0.1.6" -mypy = "*" +mypy = "1.11.0" pytest = "*" pytest-cov = "*" pip-audit = "*" diff --git a/examples/production_python/smart_contracts/_helpers/build.py b/examples/production_python/smart_contracts/_helpers/build.py index 20770e8..0afee9c 100644 --- a/examples/production_python/smart_contracts/_helpers/build.py +++ b/examples/production_python/smart_contracts/_helpers/build.py @@ -41,12 +41,13 @@ def build(output_dir: Path, contract_path: Path) -> Path: raise Exception(f"Could not build contract:\n{build_result.stdout}") app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")] - + app_spec_file_name = None for app_spec_file_name in app_spec_file_names: if app_spec_file_name is None: - raise Exception( - "Could not generate typed client, .arc32.json file not found" + logger.warning( + "No '*.arc32.json' file found (likely a logic signature being compiled). Skipping client generation." ) + continue print(app_spec_file_name) generate_result = subprocess.run( [ @@ -72,4 +73,4 @@ def build(output_dir: Path, contract_path: Path) -> Path: f"Could not generate typed client:\n{generate_result.stdout}" ) - return output_dir / app_spec_file_name + return output_dir / app_spec_file_name if app_spec_file_name else output_dir diff --git a/examples/starter_python/.gitignore b/examples/starter_python/.gitignore index a858d63..070829c 100644 --- a/examples/starter_python/.gitignore +++ b/examples/starter_python/.gitignore @@ -176,5 +176,5 @@ node_modules # AlgoKit debug_traces/ -.algokit/static-analysis/tealer/ +.algokit/static-analysis/ # Replace with .algokit/static-analysis/tealer/ to enable snapshot checks in CI .algokit/sources diff --git a/examples/starter_python/pyproject.toml b/examples/starter_python/pyproject.toml index 054571a..bca9124 100644 --- a/examples/starter_python/pyproject.toml +++ b/examples/starter_python/pyproject.toml @@ -4,7 +4,6 @@ version = "0.1.0" description = "Algorand smart contracts" authors = ["None "] readme = "README.md" -package-mode = false [tool.poetry.dependencies] python = "^3.12" diff --git a/examples/starter_python/smart_contracts/_helpers/build.py b/examples/starter_python/smart_contracts/_helpers/build.py index 20770e8..0afee9c 100644 --- a/examples/starter_python/smart_contracts/_helpers/build.py +++ b/examples/starter_python/smart_contracts/_helpers/build.py @@ -41,12 +41,13 @@ def build(output_dir: Path, contract_path: Path) -> Path: raise Exception(f"Could not build contract:\n{build_result.stdout}") app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")] - + app_spec_file_name = None for app_spec_file_name in app_spec_file_names: if app_spec_file_name is None: - raise Exception( - "Could not generate typed client, .arc32.json file not found" + logger.warning( + "No '*.arc32.json' file found (likely a logic signature being compiled). Skipping client generation." ) + continue print(app_spec_file_name) generate_result = subprocess.run( [ @@ -72,4 +73,4 @@ def build(output_dir: Path, contract_path: Path) -> Path: f"Could not generate typed client:\n{generate_result.stdout}" ) - return output_dir / app_spec_file_name + return output_dir / app_spec_file_name if app_spec_file_name else output_dir diff --git a/template_content/.algokit.toml.jinja b/template_content/.algokit.toml.jinja index 45e4cac..ffb4f8c 100644 --- a/template_content/.algokit.toml.jinja +++ b/template_content/.algokit.toml.jinja @@ -46,8 +46,7 @@ test = { commands = [ {%- endif %} {%- if use_python_pip_audit %} audit = { commands = [ - 'poetry export --without=dev -o requirements.txt', - 'poetry run pip-audit -r requirements.txt', + 'poetry run pip-audit', ], description = 'Audit with pip-audit' } {%- endif %} lint = { commands = [ diff --git a/template_content/.gitignore.jinja b/template_content/.gitignore.jinja index a858d63..070829c 100644 --- a/template_content/.gitignore.jinja +++ b/template_content/.gitignore.jinja @@ -176,5 +176,5 @@ node_modules # AlgoKit debug_traces/ -.algokit/static-analysis/tealer/ +.algokit/static-analysis/ # Replace with .algokit/static-analysis/tealer/ to enable snapshot checks in CI .algokit/sources diff --git a/template_content/pyproject.toml.jinja b/template_content/pyproject.toml.jinja index a5e7eb7..889fb37 100644 --- a/template_content/pyproject.toml.jinja +++ b/template_content/pyproject.toml.jinja @@ -4,7 +4,6 @@ version = "0.1.0" description = "Algorand smart contracts" authors = ["{{ author_name }} <{{ author_email }}>"] readme = "README.md" -package-mode = false [tool.poetry.dependencies] python = "^3.12" @@ -26,7 +25,7 @@ ruff = "^0.1.6" flake8 = "*" {% endif -%} {% if use_python_mypy -%} -mypy = "*" +mypy = "1.11.0" {% endif -%} {% if use_python_pytest -%} pytest = "*" diff --git a/template_content/smart_contracts/_helpers/build.py.jinja b/template_content/smart_contracts/_helpers/build.py.jinja index dc679e0..a861b68 100644 --- a/template_content/smart_contracts/_helpers/build.py.jinja +++ b/template_content/smart_contracts/_helpers/build.py.jinja @@ -44,12 +44,13 @@ def build(output_dir: Path, contract_path: Path) -> Path: raise Exception(f"Could not build contract:\n{build_result.stdout}") app_spec_file_names = [file.name for file in output_dir.glob("*.arc32.json")] - + app_spec_file_name = None for app_spec_file_name in app_spec_file_names: if app_spec_file_name is None: - raise Exception( - "Could not generate typed client, .arc32.json file not found" + logger.warning( + "No '*.arc32.json' file found (likely a logic signature being compiled). Skipping client generation." ) + continue print(app_spec_file_name) generate_result = subprocess.run( [ @@ -75,4 +76,4 @@ def build(output_dir: Path, contract_path: Path) -> Path: f"Could not generate typed client:\n{generate_result.stdout}" ) - return output_dir / app_spec_file_name + return output_dir / app_spec_file_name if app_spec_file_name else output_dir diff --git a/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-ci.yaml.jinja b/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-ci.yaml.jinja index 8294d58..abac062 100644 --- a/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-ci.yaml.jinja +++ b/template_content/{% if use_github_actions %}.github{% endif %}/workflows/{% include pathjoin('includes', 'project_name_kebab.jinja') %}-ci.yaml.jinja @@ -56,8 +56,12 @@ jobs: - name: Scan TEAL files for issues run: algokit project run audit-teal --project-name '{{ project_name }}' - - name: Check output stability of the smart contracts - run: algokit project run ci-teal-diff --project-name '{{ project_name }}' + # # Uncomment to enable TEAL static analysis with snapshoting using Tealer package + # # Would first require running locally using audit-teal command and committing the snapshots into source control + # # Please note, tealer has a known bug that may result in large snapshot file sizes, track resolution here: + # # https://github.com/crytic/tealer/issues/101 + # - name: Check output stability of the smart contracts + # run: algokit project run ci-teal-diff --project-name '{{ project_name }}' - name: Run deployer against LocalNet run: algokit project deploy localnet --project-name '{{ project_name }}' diff --git a/template_content/{% if use_pre_commit %}.pre-commit-config.yaml{% endif %}.jinja b/template_content/{% if use_pre_commit %}.pre-commit-config.yaml{% endif %}.jinja index 47de4b7..1b2f2f4 100644 --- a/template_content/{% if use_pre_commit %}.pre-commit-config.yaml{% endif %}.jinja +++ b/template_content/{% if use_pre_commit %}.pre-commit-config.yaml{% endif %}.jinja @@ -36,13 +36,14 @@ repos: minimum_pre_commit_version: '2.9.2' files: '^(src|tests)/' {% endif %} - - id: tealer - name: tealer - description: "Run AlgoKit `Tealer` for TEAL static analysis" - entry: algokit - language: system - args: [project, run, "audit-teal"] - require_serial: false - additional_dependencies: [] - minimum_pre_commit_version: "0" - files: '^.*\.teal$' + # # Uncomment to enable TEAL static analysis using Tealer package + # - id: tealer + # name: tealer + # description: "Run AlgoKit `Tealer` for TEAL static analysis" + # entry: algokit + # language: system + # args: [project, run, "audit-teal"] + # require_serial: false + # additional_dependencies: [] + # minimum_pre_commit_version: "0" + # files: '^.*\.teal$'