Skip to content

Commit 9b7b9e2

Browse files
authored
feat: repo-template v1 (#2)
* feat: minimal repo-template Signed-off-by: moul <94029+moul@users.noreply.github.com> * chore: fixup * chore: fixup --------- Signed-off-by: moul <94029+moul@users.noreply.github.com>
1 parent 10a8b04 commit 9b7b9e2

File tree

7 files changed

+128
-1
lines changed

7 files changed

+128
-1
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: actions/setup-go@v5
16+
17+
- name: Install Gno
18+
run: make install_deps
19+
20+
- name: Run tests
21+
run: make test
22+
23+
- name: Run linter
24+
run: make lint

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.PHONY: all test lint fmt install_deps
2+
3+
all: fmt test lint
4+
5+
# Run the development node
6+
dev:
7+
gnodev
8+
9+
# Run all tests
10+
test:
11+
gno test -v ./...
12+
13+
# Run linter
14+
lint:
15+
gno lint -v .
16+
17+
# Format the code
18+
fmt:
19+
gno fmt -w ./...
20+
21+
install_deps:
22+
curl https://raw.githubusercontent.com/gnolang/gno/refs/heads/master/misc/install.sh | bash
23+

README.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,62 @@
1-
WIP, see https://github.com/gnolang/repo-template/issues/1
1+
# Gno Project Template
2+
3+
This repository serves as a template for starting Gno projects with best
4+
practices and proper tooling baked in. It helps contributors or teams quickly
5+
scaffold a real-world Gno setup.
6+
7+
## Features
8+
9+
- Handles installing Go & Gno dependencies
10+
- Runs gnodev with a minimal default realm
11+
- Includes test and lint commangids
12+
- Integrated with GitHub Actions CI workflow
13+
- Supports both p/ and r/ structure
14+
- Configured for external dependencies
15+
- Editor configurations included
16+
17+
## Prerequisites
18+
19+
- Go 1.21 or later
20+
- Gno development environment
21+
22+
## Getting Started
23+
24+
1. Clone this repository:
25+
```bash
26+
git clone https://github.com/gnolang/repo-template.git
27+
cd repo-template
28+
```
29+
30+
2. Install dependencies:
31+
```bash
32+
make deps
33+
```
34+
35+
3. Run tests:
36+
```bash
37+
make test
38+
```
39+
40+
4. Start the development node:
41+
```bash
42+
make dev
43+
```
44+
45+
## Project Structure
46+
47+
- `p/` - Contains packages that can be imported by other Gno code
48+
- `r/` - Contains realms (smart contracts)
49+
- `.github/workflows/` - CI/CD configuration
50+
- `Makefile` - Common development commands
51+
52+
## Development
53+
54+
- `make test` - Run all tests
55+
- `make lint` - Run linter
56+
- `make clean` - Clean build artifacts
57+
- `make deps` - Install dependencies
58+
- `make dev` - Run development node
59+
60+
## License
61+
62+
MIT

p/example/example.gno

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package example
2+
3+
// Add adds two integers and returns their sum
4+
func Add(a, b int) int {
5+
return a + b
6+
}

p/example/gno.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module gno.land/p/username/example

r/example/gno.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module gno.land/r/username/example

r/example/main.gno

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package example
2+
3+
// This function is called when the realm is deployed.
4+
func init() {
5+
// ...
6+
}
7+
8+
// This function is called when the realm is rendered through gnoweb.
9+
func Render(path string) string {
10+
return "Hello, Gno!"
11+
}

0 commit comments

Comments
 (0)