Skip to content

Commit

Permalink
feat: orchestration support (#27)
Browse files Browse the repository at this point in the history
* feat: refinements to rely on algokit run in ci/cd workflows

* chore: regen examples

* chore: wip

* docs: refresh readme

* chore: refining readme

* chore: bumping min version

* chore: apply suggestions from code review

Co-authored-by: Neil Campbell <[email protected]>

* chore: regen samples

* chore: swapping to final prerelease branch

* chore: minor refinements

* chore: minor tweaks

* chore: bumping deps

* chore: bumping min version

BREAKING CHANGE: Support for algokit-cli v2.0

---------

Co-authored-by: Neil Campbell <[email protected]>
  • Loading branch information
aorumbayev and neilcampbell authored Mar 27, 2024
1 parent b2e56a8 commit 9cc2da1
Show file tree
Hide file tree
Showing 153 changed files with 761 additions and 3,604 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,3 @@ examples/**/poetry.lock

# playground folder for previewing templates
.playground/*
!.playground/.gitkeep
Empty file removed .playground/.gitkeep
Empty file.
8 changes: 4 additions & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"-v",
"init",
"--name",
"test_output",
".playground",
"--no-git",
"--UNSAFE-SECURITY-accept-template-url",
"--template-url",
Expand All @@ -18,13 +18,13 @@
"--no-bootstrap"
],
"type": "shell",
"dependsOn": ["Delete test_output folder"],
"dependsOn": ["Delete .playground folder"],
"problemMatcher": []
},
{
"label": "Delete test_output folder",
"label": "Delete .playground folder",
"command": "rm",
"args": ["-rf", "test_output"],
"args": ["-rf", ".playground"],
"type": "shell",
"windows": {
"command": "./.vscode/clear.ps1"
Expand Down
19 changes: 16 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,36 @@ This repository is a template for creating new AlgoKit projects. It includes a b
## Pre-requisites

`poetry install` - Install the dependencies for the project.
`pipx install algokit` - Ensure cli is installed.

## Testing

```bash
poetry run pytest
poetry run pytest -n auto
```

This will regenerate the tests for default `starter` and `production` presets as well as default tests for `generators` available on the template.
This will regenerate the tests for default `starter` and `production` presets.

## Development

### Manual

```bash
poetry run copier copy . .playground/{some_dummy_folder_name} --vcs-ref=HEAD --trust
poetry run copier copy . .playground --vcs-ref=HEAD --trust
```

To generate a dummy project into the `.playground` folder. This is useful for testing the template to quickly preview the output of the template before testing via `pytest`.

### Using VSCode Tasks

In VSCode IDE, you can find the tasks in the `.vscode/tasks.json` file. To run them:

1. Open the command palette (`Cmd+Shift+P` on macOS, `Ctrl+Shift+P` on Windows/Linux) and type `> Run Task`
2. Select the task you want to run
3. It will be generated for you under the .playground folder

To cleanup the .playground folder run dedicated cleanup task.

## Contributing

### Commits
Expand Down
8 changes: 7 additions & 1 deletion copier.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
_subdirectory: template_content
_templates_suffix: '.jinja'

# questions
use_workspace:
type: bool
when: false # never prompted to user explicitly, instead expect cli to auto fill (supported cli versions > v1.13.x)
help: Automatically filled by AlgoKit CLI (>1.13.x) - passes the --workspace/--no-workspace flag's value, can be used to reason whether this template is currently being instantiated as part of a workspace or not.
default: no

# project_name should never get prompted, AlgoKit should always pass it by convention
project_name:
type: str
Expand All @@ -18,6 +23,7 @@ author_email:
help: Package author email
placeholder: '[email protected]'

# Preset related questions
preset_name:
type: str
help: Name of the template preset to use.
Expand Down
Empty file removed examples/cloud_provider/.gitkeep
Empty file.
15 changes: 13 additions & 2 deletions examples/cloud_provider/production_react_netlify/.algokit.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
[algokit]
min_version = "v1.3.0b1"
min_version = "v2.0.0"

[generate.import_contract]
description = "Import a typed client from your smart contracts project"
path = ".algokit/generators/import_contract"

[project]
type = "frontend"
name = "production_react_netlify"
name = 'production_react_netlify'
artifacts = "src/contracts"

[project.run]
build = { commands = ['npm run build'], description = 'Build frontend' }
test = { commands = ['npm run test'], description = 'Run frontend tests' }
lint = { commands = ['npm run lint'], description = 'Lint frontend code' }
ci-deploy-netlify = { commands = [
'npm install --global netlify-cli@latest',
'netlify login',
'netlify deploy --build --prod'
], description = 'Deploy to Netlify' }

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release production_react_netlify

on:
workflow_call:
push:
branches:
- main
paths-ignore:
- "docs/**"
- "**.md"
- ".vscode/**"
- ".idea/**"

permissions:
contents: read
packages: read

jobs:
validate:
name: Validate production_react_netlify
uses: ./.github/workflows/production-react-netlify-ci.yaml
deploy:
runs-on: ubuntu-latest
name: Deploy to Netlify
environment: frontend-prod

needs:
- validate

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 algokit

- name: Bootstrap dependencies
run: algokit bootstrap all --project-name 'production_react_netlify'

- 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Validate production_react_netlify

on:

workflow_call:
pull_request:


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 algokit

- name: Install dependencies
run: algokit bootstrap all --project-name 'production_react_netlify'


- name: Run linters
run: algokit project run lint --project-name 'production_react_netlify'


- name: Run unit tests
run: algokit project run test --project-name 'production_react_netlify'


- name: Build
run: algokit project run build --project-name 'production_react_netlify'

This file was deleted.

3 changes: 3 additions & 0 deletions examples/cloud_provider/production_react_netlify/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ yarn-error.log*
!.idea/
.idea/*
!.idea/runConfigurations/

.vercel
.netlify
Loading

0 comments on commit 9cc2da1

Please sign in to comment.