From 9bedcb05a7f03f29351917238ae7ac11cc89e707 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Thu, 22 May 2025 11:42:59 +0200 Subject: [PATCH 1/3] feat: minimal repo-template Signed-off-by: moul <94029+moul@users.noreply.github.com> --- .github/workflows/ci.yml | 33 +++++++++++++++++++++ Makefile | 28 ++++++++++++++++++ README.md | 62 ++++++++++++++++++++++++++++++++++++++-- p/example/example.gno | 6 ++++ r/example/main.gno | 9 ++++++ 5 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 Makefile create mode 100644 p/example/example.gno create mode 100644 r/example/main.gno diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a65d400 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.21' + + - name: Install Gno + run: | + git clone https://github.com/gnolang/gno.git + cd gno + make install + + - name: Install dependencies + run: make deps + + - name: Run tests + run: make test + + - name: Run linter + run: make lint \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..30a8ded --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +.PHONY: all test lint clean + +all: test lint + +# Run all tests +test: + gno test ./... + +# Run linter +lint: + gno lint ./... + +# Clean build artifacts +clean: + rm -rf .gno/ + +# Install dependencies +deps: + go mod tidy + gno mod tidy + +# Run the development node +dev: + gnodev + +install_deps: + curl https://raw.githubusercontent.com/gnolang/gno/refs/heads/master/misc/install.sh | bash + \ No newline at end of file diff --git a/README.md b/README.md index e8f3ec0..061c313 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,60 @@ -# repo-template -Boilerplate for building real-world Gno apps with dev tools and structure. +# Gno Project Template + +This repository serves as a template for starting Gno projects with best practices and proper tooling baked in. It helps contributors or teams quickly scaffold a real-world Gno setup. + +## Features + +- Handles installing Go & Gno dependencies +- Runs gnodev with a minimal default realm +- Includes test and lint commands +- Integrated with GitHub Actions CI workflow +- Supports both p/ and r/ structure +- Configured for external dependencies +- Editor configurations included + +## Prerequisites + +- Go 1.21 or later +- Gno development environment + +## Getting Started + +1. Clone this repository: + ```bash + git clone https://github.com/gnolang/repo-template.git + cd repo-template + ``` + +2. Install dependencies: + ```bash + make deps + ``` + +3. Run tests: + ```bash + make test + ``` + +4. Start the development node: + ```bash + make dev + ``` + +## Project Structure + +- `p/` - Contains packages that can be imported by other Gno code +- `r/` - Contains realms (smart contracts) +- `.github/workflows/` - CI/CD configuration +- `Makefile` - Common development commands + +## Development + +- `make test` - Run all tests +- `make lint` - Run linter +- `make clean` - Clean build artifacts +- `make deps` - Install dependencies +- `make dev` - Run development node + +## License + +MIT diff --git a/p/example/example.gno b/p/example/example.gno new file mode 100644 index 0000000..ad1a432 --- /dev/null +++ b/p/example/example.gno @@ -0,0 +1,6 @@ +package example + +// Add adds two integers and returns their sum +func Add(a, b int) int { + return a + b +} diff --git a/r/example/main.gno b/r/example/main.gno new file mode 100644 index 0000000..3ccf186 --- /dev/null +++ b/r/example/main.gno @@ -0,0 +1,9 @@ +package example + +func Render(path string) string { + return "Hello, Gno!" +} + +func OnCall() { + // This function is called when the realm is deployed +} From 0fd0060064cdee40c90bc2de168ec637519817b1 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Thu, 22 May 2025 12:08:37 +0200 Subject: [PATCH 2/3] chore: fixup --- .github/workflows/ci.yml | 13 ++----------- Makefile | 26 ++++++++++---------------- p/example/gno.mod | 1 + r/example/gno.mod | 1 + 4 files changed, 14 insertions(+), 27 deletions(-) create mode 100644 p/example/gno.mod create mode 100644 r/example/gno.mod diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a65d400..8d6d989 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,19 +12,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.21' + - uses: actions/setup-go@v5 - name: Install Gno - run: | - git clone https://github.com/gnolang/gno.git - cd gno - make install - - - name: Install dependencies - run: make deps + run: make install_deps - name: Run tests run: make test diff --git a/Makefile b/Makefile index 30a8ded..ca3c4c7 100644 --- a/Makefile +++ b/Makefile @@ -1,27 +1,21 @@ -.PHONY: all test lint clean +.PHONY: all test lint fmt install_deps -all: test lint +all: fmt test lint + +# Run the development node +dev: + gnodev # Run all tests test: - gno test ./... + gno test -v ./... # Run linter lint: - gno lint ./... - -# Clean build artifacts -clean: - rm -rf .gno/ + gno lint -v . -# Install dependencies -deps: - go mod tidy - gno mod tidy - -# Run the development node -dev: - gnodev +fmt: + gno fmt -w ./... install_deps: curl https://raw.githubusercontent.com/gnolang/gno/refs/heads/master/misc/install.sh | bash diff --git a/p/example/gno.mod b/p/example/gno.mod new file mode 100644 index 0000000..530f485 --- /dev/null +++ b/p/example/gno.mod @@ -0,0 +1 @@ +module gno.land/p/username/example \ No newline at end of file diff --git a/r/example/gno.mod b/r/example/gno.mod new file mode 100644 index 0000000..89612d9 --- /dev/null +++ b/r/example/gno.mod @@ -0,0 +1 @@ +module gno.land/r/username/example \ No newline at end of file From 31ab96b9442158cf61ef56e44a04408c2f8a192e Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Thu, 22 May 2025 12:12:21 +0200 Subject: [PATCH 3/3] chore: fixup --- Makefile | 1 + README.md | 10 ++++++++-- r/example/main.gno | 10 ++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index ca3c4c7..69cc9b9 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ test: lint: gno lint -v . +# Format the code fmt: gno fmt -w ./... diff --git a/README.md b/README.md index afcaa96..a08353e 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ # Gno Project Template -This repository serves as a template for starting Gno projects with best practices and proper tooling baked in. It helps contributors or teams quickly scaffold a real-world Gno setup. +This repository serves as a template for starting Gno projects with best +practices and proper tooling baked in. It helps contributors or teams quickly +scaffold a real-world Gno setup. ## Features - Handles installing Go & Gno dependencies - Runs gnodev with a minimal default realm -- Includes test and lint commands +- Includes test and lint commangids - Integrated with GitHub Actions CI workflow - Supports both p/ and r/ structure - Configured for external dependencies @@ -54,3 +56,7 @@ This repository serves as a template for starting Gno projects with best practic - `make clean` - Clean build artifacts - `make deps` - Install dependencies - `make dev` - Run development node + +## License + +MIT diff --git a/r/example/main.gno b/r/example/main.gno index 3ccf186..8988a94 100644 --- a/r/example/main.gno +++ b/r/example/main.gno @@ -1,9 +1,11 @@ package example -func Render(path string) string { - return "Hello, Gno!" +// This function is called when the realm is deployed. +func init() { + // ... } -func OnCall() { - // This function is called when the realm is deployed +// This function is called when the realm is rendered through gnoweb. +func Render(path string) string { + return "Hello, Gno!" }