diff --git a/examples/production_puya_react/.algokit.toml b/examples/production_puya_react/.algokit.toml index 378317e..cafa822 100644 --- a/examples/production_puya_react/.algokit.toml +++ b/examples/production_puya_react/.algokit.toml @@ -4,3 +4,6 @@ min_version = "v1.12.0" [project] type = 'workspace' projects_root_path = 'projects' + +[project.run] +build = ['production_puya_react-contracts', 'production_puya_react-frontend'] diff --git a/examples/production_puya_react/.copier-answers.yml b/examples/production_puya_react/.copier-answers.yml index 58cc024..e60ba05 100644 --- a/examples/production_puya_react/.copier-answers.yml +++ b/examples/production_puya_react/.copier-answers.yml @@ -3,6 +3,7 @@ _commit: _src_path: author_email: None author_name: None +cloud_provider: netlify contract_name: hello_world deployment_language: python preset_name: production diff --git a/examples/production_puya_react/.github/workflows/frontend-cd.yaml b/examples/production_puya_react/.github/workflows/frontend-cd.yaml deleted file mode 100644 index 4d8383c..0000000 --- a/examples/production_puya_react/.github/workflows/frontend-cd.yaml +++ /dev/null @@ -1,60 +0,0 @@ -name: Frontend CD - -on: - workflow_call: - -permissions: - contents: read - packages: read - -jobs: - lint-and-build: - name: CI dApp - uses: ./.github/workflows/frontend-ci.yaml - with: - run-build: true - - - deploy: - runs-on: ubuntu-latest - name: Deploy to Netlify - environment: Prod - concurrency: "${{ github.workflow }}-prod" - needs: - - lint-and-build - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Download build artifacts - uses: actions/download-artifact@v3 - with: - name: dist - path: frontend/dist - - - name: Replace template vars - uses: makerxstudio/shared-config/.github/actions/placeholder-transforms@main - with: - app-artifact-path: ./projects/{{ project_name }}-app/dist - static-site-transforms: |- - VITE_ALGOD_TOKEN:${{ secrets.VITE_ALGOD_TOKEN }} - VITE_ALGOD_SERVER:${{ vars.VITE_ALGOD_SERVER }} - VITE_ALGOD_PORT:${{ vars.VITE_ALGOD_PORT }} - VITE_ALGOD_NETWORK:${{ vars.VITE_ALGOD_NETWORK }} - VITE_INDEXER_SERVER:${{ vars.VITE_INDEXER_SERVER }} - VITE_INDEXER_PORT:${{ vars.VITE_INDEXER_PORT }} - VITE_INDEXER_TOKEN:${{ secrets.VITE_INDEXER_TOKEN }} - VITE_ENVIRONMENT:${{ vars.VITE_ENVIRONMENT }} - - - name: Install netlify cli - working-directory: ./projects/{{ project_name }}-app - run: npm i netlify-cli - - - name: Publish to netlify - working-directory: ./projects/{{ project_name }}-app - run: netlify deploy --prod --dir "dist" - env: - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - # Set your vercel project env variables on your github repository (see README in frontend folder for more info) - diff --git a/examples/production_puya_react/.github/workflows/frontend-ci.yaml b/examples/production_puya_react/.github/workflows/frontend-ci.yaml deleted file mode 100644 index 9139e03..0000000 --- a/examples/production_puya_react/.github/workflows/frontend-ci.yaml +++ /dev/null @@ -1,63 +0,0 @@ -name: Frontend CI - -on: - workflow_call: - inputs: - run-build: - required: false - type: boolean - default: false - -jobs: - checks: - runs-on: 'ubuntu-latest' - steps: - - name: Check out repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 18 - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - - name: Install algokit - run: pipx install algokit - - - name: Install dependencies - working-directory: ./projects/production_puya_react-app - run: npm ci - - - name: Run linters - working-directory: ./projects/production_puya_react-app - run: npm run lint - - - name: Run unit tests - working-directory: ./projects/production_puya_react-app - run: npm run test - - - name: Create placeholder .env file - if: ${{ inputs.run-build }} - uses: makerxstudio/shared-config/.github/actions/env-to-placeholders@main - with: - env-output-path: ./projects/production_puya_react-app/.env - env-template-path: ./projects/production_puya_react-app/.env.template - env-variable-prefix: VITE_ - - - name: Build - if: ${{ inputs.run-build }} - working-directory: ./projects/production_puya_react-app - run: npm run build - - - name: Archive - if: ${{ inputs.run-build }} - uses: actions/upload-artifact@v3 - with: - name: dist - path: frontend/dist/ diff --git a/examples/production_puya_react/.github/workflows/pr.yaml b/examples/production_puya_react/.github/workflows/pr.yaml deleted file mode 100644 index 898434f..0000000 --- a/examples/production_puya_react/.github/workflows/pr.yaml +++ /dev/null @@ -1,12 +0,0 @@ -name: Pull Request validation - -on: [pull_request] - -jobs: - smart-contracts-ci: - name: Smart Contracts CI - uses: ./.github/workflows/smart-contracts-ci.yaml - - frontend-ci: - name: Frontend CI - uses: ./.github/workflows/frontend-ci.yaml diff --git a/examples/production_puya_react/.github/workflows/smart-contracts-cd.yaml b/examples/production_puya_react/.github/workflows/production-puya-react-contracts-cd.yaml similarity index 60% rename from examples/production_puya_react/.github/workflows/smart-contracts-cd.yaml rename to examples/production_puya_react/.github/workflows/production-puya-react-contracts-cd.yaml index a617bfd..10b07e3 100644 --- a/examples/production_puya_react/.github/workflows/smart-contracts-cd.yaml +++ b/examples/production_puya_react/.github/workflows/production-puya-react-contracts-cd.yaml @@ -1,19 +1,13 @@ -name: Backend CD +name: Release production_puya_react-contracts on: workflow_call: -concurrency: release - jobs: - ci-check: - name: Perform smart contract checks - uses: ./.github/workflows/smart-contracts-ci.yaml - deploy-testnet: - runs-on: 'ubuntu-latest' - needs: ci-check - environment: Test + runs-on: "ubuntu-latest" + + environment: contract-testnet steps: - name: Checkout source code uses: actions/checkout@v4 @@ -24,26 +18,23 @@ jobs: - name: Set up Python 3.12 uses: actions/setup-python@v5 with: - python-version: '3.12' - cache: 'poetry' + python-version: "3.12" + cache: "poetry" - name: Install algokit - run: pipx install algokit + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking - name: Bootstrap dependencies - working-directory: ./projects/production_puya_react-contracts - run: algokit bootstrap all + run: algokit bootstrap all --project-name 'production_puya_react-contracts' - name: Configure git shell: bash - working-directory: ./projects/production_puya_react-contracts run: | # set git user and email as test invoke git git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - name: Deploy to testnet - working-directory: ./projects/production_puya_react-contracts - run: algokit deploy testnet + run: algokit deploy testnet --project-name 'production_puya_react-contracts' env: # This is the account that becomes the creator of the contract DEPLOYER_MNEMONIC: ${{ secrets.DEPLOYER_MNEMONIC }} diff --git a/examples/production_puya_react/.github/workflows/production-puya-react-contracts-ci.yaml b/examples/production_puya_react/.github/workflows/production-puya-react-contracts-ci.yaml new file mode 100644 index 0000000..33e7891 --- /dev/null +++ b/examples/production_puya_react/.github/workflows/production-puya-react-contracts-ci.yaml @@ -0,0 +1,59 @@ +name: Validate production_puya_react-contracts + +on: + workflow_call: + +jobs: + validate: + runs-on: "ubuntu-latest" + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Install poetry + run: pipx install poetry + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "poetry" + + - name: Install algokit + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + + - name: Start LocalNet + run: algokit localnet start + + - name: Bootstrap dependencies + run: algokit bootstrap all --project-name 'production_puya_react-contracts' + + - name: Configure git + shell: bash + run: | + # set git user and email as test invoke git + git config --global user.email "actions@github.com" && git config --global user.name "github-actions" + + - name: Audit python dependencies + run: algokit project run audit --project-name 'production_puya_react-contracts' + + - name: Lint and format python dependencies + run: algokit project run lint --project-name 'production_puya_react-contracts' + + - name: Run tests + shell: bash + run: | + set -o pipefail + algokit project run test --project-name 'production_puya_react-contracts' + + - name: Build smart contracts + run: algokit project run build --project-name 'production_puya_react-contracts' + + - name: Scan TEAL files for issues + run: algokit project run audit-teal --project-name 'production_puya_react-contracts' + + - name: Check output stability of the smart contracts + run: algokit project run ci-teal-diff --project-name 'production_puya_react-contracts' + + - name: Run deployer against LocalNet + run: algokit project deploy localnet --project-name 'production_puya_react-contracts' diff --git a/examples/production_puya_react/.github/workflows/production-puya-react-frontend-cd.yaml b/examples/production_puya_react/.github/workflows/production-puya-react-frontend-cd.yaml new file mode 100644 index 0000000..32da007 --- /dev/null +++ b/examples/production_puya_react/.github/workflows/production-puya-react-frontend-cd.yaml @@ -0,0 +1,39 @@ +name: Release production_puya_react-frontend + +on: + workflow_call: +permissions: + contents: read + packages: read + +jobs: + + deploy: + runs-on: ubuntu-latest + name: Deploy to Netlify + environment: frontend-prod + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Install algokit + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + + - name: Bootstrap dependencies + run: algokit bootstrap all --project-name 'production_puya_react-frontend' + + - name: Publish to Netlify + env: + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + run: | + npm install --global netlify-cli@latest + netlify login + netlify deploy --build --prod + \ No newline at end of file diff --git a/examples/production_puya_react/.github/workflows/production-puya-react-frontend-ci.yaml b/examples/production_puya_react/.github/workflows/production-puya-react-frontend-ci.yaml new file mode 100644 index 0000000..9bb6f8e --- /dev/null +++ b/examples/production_puya_react/.github/workflows/production-puya-react-frontend-ci.yaml @@ -0,0 +1,47 @@ +name: Validate production_puya_react-frontend + +on: + + workflow_call: + + +jobs: + validate: + runs-on: 'ubuntu-latest' + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Install poetry + run: pipx install poetry + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "poetry" + + - name: Install algokit + run: pipx install git+https://github.com/algorandfoundation/algokit-cli@feat/orchestration-linking + + - name: Install dependencies + run: algokit bootstrap all --project-name 'production_puya_react-frontend' + + + - name: Run linters + run: algokit project run lint --project-name 'production_puya_react-frontend' + + + - name: Run unit tests + run: algokit project run test --project-name 'production_puya_react-frontend' + + + - name: Build + run: algokit project run build --project-name 'production_puya_react-frontend' diff --git a/examples/production_puya_react/.github/workflows/release.yaml b/examples/production_puya_react/.github/workflows/release.yaml index 58494c1..e40bd29 100644 --- a/examples/production_puya_react/.github/workflows/release.yaml +++ b/examples/production_puya_react/.github/workflows/release.yaml @@ -1,27 +1,38 @@ name: Release on: - push: - branches: - - main - paths-ignore: - - "docs/**" - - "**.md" - - ".vscode/**" - - ".idea/**" + push: + branches: + - main + paths-ignore: + - 'docs/**' + - '**.md' + - '.vscode/**' + - '.idea/**' permissions: contents: read packages: read jobs: - backend-release: - name: Backend Release - secrets: inherit - uses: ./.github/workflows/smart-contracts-cd.yaml + production_puya_react-contracts-validate: + name: Run production_puya_react-contracts release + secrets: inherit + uses: ./.github/workflows/production_puya_react-contracts-ci.yaml - frontend-release: - name: Frontend Release - secrets: inherit - uses: ./.github/workflows/frontend-cd.yaml - needs: backend-release + production_puya_react-contracts-release: + name: Run production_puya_react-contracts release + secrets: inherit + uses: ./.github/workflows/production_puya_react-contracts-cd.yaml + needs: production_puya_react-contracts-validate + + production_puya_react-frontend-validate: + name: Run production_puya_react-frontend release + secrets: inherit + uses: ./.github/workflows/production_puya_react-frontend-ci.yaml + + production_puya_react-frontend-release: + name: Run production_puya_react-frontend release + secrets: inherit + uses: ./.github/workflows/production_puya_react-frontend-cd.yaml + needs: production_puya_react-frontend-validate diff --git a/examples/production_puya_react/.github/workflows/smart-contracts-ci.yaml b/examples/production_puya_react/.github/workflows/smart-contracts-ci.yaml deleted file mode 100644 index b07cecd..0000000 --- a/examples/production_puya_react/.github/workflows/smart-contracts-ci.yaml +++ /dev/null @@ -1,85 +0,0 @@ -name: Backend CI - -on: - workflow_call: - -jobs: - checks: - runs-on: 'ubuntu-latest' - steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - name: Install poetry - run: pipx install poetry - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'poetry' - - - name: Install algokit - run: pipx install algokit - - - name: Start LocalNet - run: algokit localnet start - - - name: Bootstrap dependencies - run: algokit bootstrap all - working-directory: ./projects/production_puya_react-contracts - - - name: Configure git - shell: bash - working-directory: ./projects/production_puya_react-contracts - run: | - # set git user and email as test invoke git - git config --global user.email "actions@github.com" && git config --global user.name "github-actions" - - - name: Audit with pip-audit - working-directory: ./projects/production_puya_react-contracts - 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 Black - working-directory: ./projects/production_puya_react-contracts - run: | - # stop the build if there are files that don't meet formatting requirements - poetry run black --check . - - - name: Check linting with Ruff - working-directory: ./projects/production_puya_react-contracts - run: | - # stop the build if there are Python syntax errors or undefined names - poetry run ruff . - - - name: Check types with mypy - working-directory: ./projects/production_puya_react-contracts - run: poetry run mypy - - - name: Run tests - working-directory: ./projects/production_puya_react-contracts - shell: bash - run: | - set -o pipefail - poetry run pytest --junitxml=pytest-junit.xml - - - name: Build smart contracts - working-directory: ./projects/production_puya_react-contracts - run: poetry run python -m smart_contracts build - - - name: Check output stability of the smart contracts - shell: bash - working-directory: ./projects/production_puya_react-contracts - run: | - # Add untracked files as empty so they come up in diff - git add -N ./smart_contracts/artifacts - # Error out if there are any changes in teal after generating output - git diff --exit-code --minimal ./smart_contracts/artifacts || (echo "::error ::Smart contract artifacts have changed, ensure committed artifacts are up to date" && exit 1); diff --git a/examples/production_puya_react/.github/workflows/validate.yaml b/examples/production_puya_react/.github/workflows/validate.yaml new file mode 100644 index 0000000..579a8b5 --- /dev/null +++ b/examples/production_puya_react/.github/workflows/validate.yaml @@ -0,0 +1,14 @@ +name: Pull Request validation + +on: [pull_request] + + +jobs: + production_puya_react-contracts-ci: + name: Run production_puya_react-contracts validation + uses: ./.github/workflows/production_puya_react-contracts-ci.yaml + + production_puya_react-frontend-ci: + name: Run production_puya_react-frontend validation + uses: ./.github/workflows/production_puya_react-frontend-ci.yaml + diff --git a/examples/production_puya_react/README.md b/examples/production_puya_react/README.md index e77fea3..6909f81 100644 --- a/examples/production_puya_react/README.md +++ b/examples/production_puya_react/README.md @@ -16,7 +16,7 @@ This starter full stack project has been generated using AlgoKit. See below for - Run `algokit localnet start` to start a local Algorand network in Docker. If you are using VS Code launch configurations provided by the template, this will be done automatically for you. 3. Open the project and start debugging / developing on: - [production_puya_react-contracts](projects/production_puya_react-contracts/README.md) - Refer to the README for more information on how to work with smart contracts. - - [production_puya_react-app](projects/production_puya_react-app/README.md) - Refer to the README for more information on how to work with the frontend application. + - [production_puya_react-frontend](projects/production_puya_react-frontend/README.md) - Refer to the README for more information on how to work with the frontend application. ### Subsequently @@ -48,10 +48,10 @@ It has also been configured to have a productive dev experience out of the box i ## Integrating with smart contracts and application clients -Refer to the [production_puya_react-contracts](projects/production_puya_react-contracts/README.md) folder for overview of working with smart contracts, [projects/production_puya_react-app](projects/production_puya_react-app/README.md) for overview of the React project and the [projects/production_puya_react-app/contracts](projects/production_puya_react-app/src/contracts/README.md) folder for README on adding new smart contracts from backend as application clients on your frontend. The templates provided in these folders will help you get started. -When you compile and generate smart contract artifacts, your frontend component will automatically generate typescript application clients from smart contract artifacts and move them to `frontend/src/contracts` folder, see [`generate:app-clients` in package.json](projects/production_puya_react-app/package.json). Afterwards, you are free to import and use them in your frontend application. +Refer to the [production_puya_react-contracts](projects/production_puya_react-contracts/README.md) folder for overview of working with smart contracts, [projects/production_puya_react-frontend](projects/production_puya_react-frontend/README.md) for overview of the React project and the [projects/production_puya_react-frontend/contracts](projects/production_puya_react-frontend/src/contracts/README.md) folder for README on adding new smart contracts from backend as application clients on your frontend. The templates provided in these folders will help you get started. +When you compile and generate smart contract artifacts, your frontend component will automatically generate typescript application clients from smart contract artifacts and move them to `frontend/src/contracts` folder, see [`generate:app-clients` in package.json](projects/production_puya_react-frontend/package.json). Afterwards, you are free to import and use them in your frontend application. -The frontend starter also provides an example of interactions with your HelloWorldClient in [`AppCalls.tsx`](projects/production_puya_react-app/src/components/AppCalls.tsx) component by default. +The frontend starter also provides an example of interactions with your HelloWorldClient in [`AppCalls.tsx`](projects/production_puya_react-frontend/src/components/AppCalls.tsx) component by default. ## Next Steps diff --git a/examples/production_puya_react/production_puya_react.code-workspace b/examples/production_puya_react/production_puya_react.code-workspace index e5575f2..6e69c2f 100644 --- a/examples/production_puya_react/production_puya_react.code-workspace +++ b/examples/production_puya_react/production_puya_react.code-workspace @@ -8,7 +8,7 @@ "path": "./projects/production_puya_react-contracts" }, { - "path": "./projects/production_puya_react-app" + "path": "./projects/production_puya_react-frontend" } ], "settings": { @@ -61,7 +61,7 @@ "name": "Deploy contracts", "folder": "production_puya_react-contracts" }, - { "name": "Run dApp", "folder": "production_puya_react-app" } + { "name": "Run dApp", "folder": "production_puya_react-frontend" } ], "presentation": { "hidden": false, diff --git a/examples/production_puya_react/projects/production_puya_react-app/.algokit.toml b/examples/production_puya_react/projects/production_puya_react-app/.algokit.toml deleted file mode 100644 index 13e4b36..0000000 --- a/examples/production_puya_react/projects/production_puya_react-app/.algokit.toml +++ /dev/null @@ -1,10 +0,0 @@ -[algokit] -min_version = "v1.3.0b1" - -[generate.import_contract] -description = "Import a typed client from your smart contracts project" -path = ".algokit/generators/import_contract" - -[project] -type = "frontend" -name = "production_puya_react-app" diff --git a/examples/production_puya_react/projects/production_puya_react-app/.idea/runConfigurations/Run_Chrome.xml b/examples/production_puya_react/projects/production_puya_react-app/.idea/runConfigurations/Run_Chrome.xml deleted file mode 100644 index 9dfeeca..0000000 --- a/examples/production_puya_react/projects/production_puya_react-app/.idea/runConfigurations/Run_Chrome.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/examples/production_puya_react/projects/production_puya_react-app/.idea/runConfigurations/Run_dApp.xml b/examples/production_puya_react/projects/production_puya_react-app/.idea/runConfigurations/Run_dApp.xml deleted file mode 100644 index 1cf2273..0000000 --- a/examples/production_puya_react/projects/production_puya_react-app/.idea/runConfigurations/Run_dApp.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - -