diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8d6d989 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + + - name: Install Gno + run: make install_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..69cc9b9 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +.PHONY: all test lint fmt install_deps + +all: fmt test lint + +# Run the development node +dev: + gnodev + +# Run all tests +test: + gno test -v ./... + +# Run linter +lint: + gno lint -v . + +# Format the code +fmt: + gno fmt -w ./... + +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 eb03544..a08353e 100644 --- a/README.md +++ b/README.md @@ -1 +1,62 @@ -WIP, see https://github.com/gnolang/repo-template/issues/1 +# 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 commangids +- 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/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 diff --git a/r/example/main.gno b/r/example/main.gno new file mode 100644 index 0000000..8988a94 --- /dev/null +++ b/r/example/main.gno @@ -0,0 +1,11 @@ +package example + +// This function is called when the realm is deployed. +func init() { + // ... +} + +// This function is called when the realm is rendered through gnoweb. +func Render(path string) string { + return "Hello, Gno!" +}