Skip to content

Commit

Permalink
Merge branch 'master' into feat/txtar-unescape
Browse files Browse the repository at this point in the history
  • Loading branch information
gfanton authored Mar 11, 2024
2 parents d0faef0 + 45c8f90 commit 7eb86e7
Show file tree
Hide file tree
Showing 66 changed files with 618 additions and 351 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
with:
go-version: ${{ matrix.goversion }}
- run: go install -v ./gnovm/cmd/gno
- run: go run ./gnovm/cmd/gno transpile --verbose --gobuild ./examples
- run: go run ./gnovm/cmd/gno transpile -v --gobuild ./examples
test:
strategy:
fail-fast: false
Expand All @@ -57,7 +57,7 @@ jobs:
echo "LOG_LEVEL=debug" >> $GITHUB_ENV
echo "LOG_PATH_DIR=$LOG_PATH_DIR" >> $GITHUB_ENV
- run: go install -v ./gnovm/cmd/gno
- run: go run ./gnovm/cmd/gno test --verbose ./examples/...
- run: go run ./gnovm/cmd/gno test -v ./examples/...
lint:
strategy:
fail-fast: false
Expand All @@ -75,10 +75,10 @@ jobs:
go-version: ${{ matrix.goversion }}
- run: go install -v ./gnovm/cmd/gno
# testing official directories, basically examples/ minus examples/.../x/.
- run: go run ./gnovm/cmd/gno lint --verbose ./examples/gno.land/p
- run: go run ./gnovm/cmd/gno lint --verbose ./examples/gno.land/r/demo
- run: go run ./gnovm/cmd/gno lint --verbose ./examples/gno.land/r/gnoland
- run: go run ./gnovm/cmd/gno lint --verbose ./examples/gno.land/r/system
- run: go run ./gnovm/cmd/gno lint -v ./examples/gno.land/p
- run: go run ./gnovm/cmd/gno lint -v ./examples/gno.land/r/demo
- run: go run ./gnovm/cmd/gno lint -v ./examples/gno.land/r/gnoland
- run: go run ./gnovm/cmd/gno lint -v ./examples/gno.land/r/system
# TODO: track coverage
mod-tidy:
strategy:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ If you wish to test a `.gno` Realm or Package, you can utilize the `gno` tool.

2. Now, you can point to the directory containing the `*_test.gno` files:

gno test <path-to-dir> --verbose
gno test <path-to-dir> -v


To learn more about how `gno` can help you when developing gno code, you can look into the available
Expand Down
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,31 @@ help:
@echo "Available make commands:"
@cat Makefile | grep '^[a-z][^:]*:' | grep -v 'install_' | cut -d: -f1 | sort | sed 's/^/ /'

# command to run dependency utilities, like goimports.
rundep=go run -modfile misc/devdeps/go.mod

########################################
# Environment variables
# You can overwrite any of the following by passing a different value on the
# command line, ie. `CGO_ENABLED=1 make test`.
# NOTE: these are not very useful in this makefile, but they serve as
# documentation for sub-makefiles.

# disable cgo by default. cgo requires some additional dependencies in some
# cases, and is not strictly required by any tm2 code.
CGO_ENABLED ?= 0
export CGO_ENABLED
# flags for `make fmt`. -w will write the result to the destination files.
GOFMT_FLAGS ?= -w
# flags for `make imports`.
GOIMPORTS_FLAGS ?= $(GOFMT_FLAGS)
# test suite flags.
GOTEST_FLAGS ?= -v -p 1 -timeout=30m
# when running `make tidy`, use it to check that the go.mods are up-to-date.
VERIFY_MOD_SUMS ?= false

########################################
# Dev tools
.PHONY: install
install: install.gnokey install.gno
@if ! command -v gnodev > /dev/null; then \
Expand Down
24 changes: 21 additions & 3 deletions contribs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@ help:
@echo "Available make commands:"
@cat Makefile | grep '^[a-z][^:]*:' | cut -d: -f1 | sort | sed 's/^/ /'

# command to run dependency utilities, like goimports.
rundep=go run -modfile ../misc/devdeps/go.mod

########################################
# Environment variables
# You can overwrite any of the following by passing a different value on the
# command line, ie. `CGO_ENABLED=1 make test`.

# disable cgo by default. cgo requires some additional dependencies in some
# cases, and is not strictly required by any tm2 code.
CGO_ENABLED ?= 0
export CGO_ENABLED
# flags for `make fmt`. -w will write the result to the destination files.
GOFMT_FLAGS ?= -w
# flags for `make imports`.
GOIMPORTS_FLAGS ?= $(GOFMT_FLAGS)
# test suite flags.
GOTEST_FLAGS ?= -v -p 1 -timeout=30m

########################################
# Dev tools
.PHONY: install
install: install.gnomd install.gnodev

Expand All @@ -18,7 +39,6 @@ clean:
rundep=go run -modfile ../misc/devdeps/go.mod

.PHONY: fmt
GOFMT_FLAGS ?= -w
fmt:
$(rundep) mvdan.cc/gofumpt $(GOFMT_FLAGS) .

Expand All @@ -33,8 +53,6 @@ tidy:

########################################
# Test suite
GOTEST_FLAGS ?= -v -p 1 -timeout=30m

.PHONY: test
test:
@echo "nothing to do."
8 changes: 8 additions & 0 deletions docs/concepts/concepts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
id: concepts
---

# Concepts

Welcome to the **Concepts** section for Gno. This section outlines the most important
concepts related to Gno & Gno.land.
8 changes: 8 additions & 0 deletions docs/getting-started/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
id: getting-started
---

# Getting started

Welcome to the **Getting Started** section for Gno. This section outlines how to
get started with Gno by setting up a local development environment, get funds, etc.
7 changes: 7 additions & 0 deletions docs/getting-started/local-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ and validate that they are correctly configured to run on your machine.
- **Git**
- **`make` (for running Makefiles)**
- **Go 19+**
- **Go Environment Setup**:
- Make sure `$GOPATH` is well-defined, and `$GOPATH/bin` is added to your `$PATH` variable.
- To do this, you can add the following line to your `.bashrc`, `.zshrc` or other config file:
```
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$PATH
```

## 1. Cloning the repository

Expand Down
5 changes: 2 additions & 3 deletions docs/gno-tooling/cli/gno.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ gno {SUB_COMMAND}

| Name | Type | Description |
| ------------ | ------------- | ------------------------------------------------------------------ |
| `verbose` | Boolean | Displays extended information. |
| `v` | Boolean | Displays verbose output. |
| `root-dir` | String | Clones location of github.com/gnolang/gno (gno tries to guess it). |
| `run` | String | Test name filtering pattern. |
| `timeout` | time.Duration | The maximum execution time in ns. |
Expand All @@ -40,7 +40,7 @@ gno {SUB_COMMAND}

| Name | Type | Description |
| ----------- | ------- | --------------------------------------------------------------- |
| `verbose` | Boolean | Displays extended information. |
| `v` | Boolean | Displays verbose output. |
| `skip-fmt` | Boolean | Skips the syntax checking of generated `.go` files. |
| `gobuild` | Boolean | Run `go build` on generated `.go` files, ignoring test files. |
| `go-binary` | String | The go binary to use for building (default: `go`). |
Expand All @@ -53,5 +53,4 @@ gno {SUB_COMMAND}

| Name | Type | Description |
| ---------- | ------- | ------------------------------------------------------------------ |
| `verbose` | Boolean | Displays extended information. |
| `root-dir` | String | Clones location of github.com/gnolang/gno (gno tries to guess it). |
2 changes: 1 addition & 1 deletion docs/gno-tooling/cli/gnoland.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ gnoland
| `chainid` | String | The id of the chain (default: `dev`). |
| `genesis-balances-file` | String | The initial GNOT distribution file (default: `./gnoland/genesis/genesis_balances.txt`). |
| `genesis-remote` | String | Replacement '%%REMOTE%%' in genesis (default: `"localhost:26657"`). |
| `genesis-txs-file` | String | Initial txs to be executed (default: `"./gnoland/genesis/genesis_txs.txt"`). |
| `genesis-txs-file` | String | Initial txs to be executed (default: `"./gnoland/genesis/genesis_txs.jsonl"`). |
| `root-dir` | String | directory for config and data (default: `testdir`). |
| `skip-failing-genesis-txs` | Boolean | Skips transactions that fail from the `genesis-txs-file` |
| `skip-start` | Boolean | Quits after initialization without starting the node. |
8 changes: 8 additions & 0 deletions docs/gno-tooling/gno-tooling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
id: gno-tooling
---

# Gno Tooling

Welcome to the **Gno Tooling** section for Gno. This section outlines programs & tools
that are commonly used when developing applications with Gno.
9 changes: 9 additions & 0 deletions docs/how-to-guides/how-to-guides.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
id: how-to-guides
---

# How-to Guides

Welcome to the **How-to Guides** section for Gno. This section outlines how to
complete specific tasks related to Gno, such as writing a realm & package, deploying
code to the chain, creating a GRC20 or GRC721 token, etc.
4 changes: 2 additions & 2 deletions docs/how-to-guides/testing-gno.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ Simply point it to the location containing our testing source code, and the test
For example, we can run the following command from the `counter-app/r/counter` directory:

```bash
gno test -verbose .
gno test -v .
```

Let's look into the different parts of this command:

- `-verbose` enables the verbose output.
- `-v` enables the verbose output.
- `-root-dir` specifies the root directory to our cloned `gno` GitHub repository
- `.` specifies the location containing our test files. Since we are already located in that directory, we specify
a `.`.
Expand Down
8 changes: 8 additions & 0 deletions docs/reference/reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
id: reference
---

# Reference

Welcome to the **Reference** section for Gno. This section outlines common APIs,
network configurations, client usages, etc.
41 changes: 31 additions & 10 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,54 @@
# Official packages: more reliable and tested modules, distinct from the experimentation area.
OFFICIAL_PACKAGES = ./gno.land/p
OFFICIAL_PACKAGES += ./gno.land/r/demo
OFFICIAL_PACKAGES += ./gno.land/r/gnoland
OFFICIAL_PACKAGES += ./gno.land/r/system

.PHONY: help
help:
@echo "Available make commands:"
@cat Makefile | grep '^[a-z][^:]*:' | cut -d: -f1 | sort | sed 's/^/ /'

# command to run dependency utilities, like goimports.
rundep=go run -modfile ../misc/devdeps/go.mod

########################################
# Environment variables
# You can overwrite any of the following by passing a different value on the
# command line, ie. `CGO_ENABLED=1 make test`.

# disable cgo by default. cgo requires some additional dependencies in some
# cases, and is not strictly required by any tm2 code.
CGO_ENABLED ?= 0
export CGO_ENABLED
# flags for `make fmt`. -w will write the result to the destination files.
GOFMT_FLAGS ?= -w
# flags for `make imports`.
GOIMPORTS_FLAGS ?= $(GOFMT_FLAGS)
# test suite flags.
GOTEST_FLAGS ?= -v -p 1 -timeout=30m

# Official packages (non-overridable): more reliable and tested modules, distinct from the experimentation area.
OFFICIAL_PACKAGES = ./gno.land/p
OFFICIAL_PACKAGES += ./gno.land/r/demo
OFFICIAL_PACKAGES += ./gno.land/r/gnoland
OFFICIAL_PACKAGES += ./gno.land/r/system

########################################
# Dev tools
.PHONY: transpile
transpile:
go run ../gnovm/cmd/gno transpile --verbose .
go run ../gnovm/cmd/gno transpile -v .

.PHONY: build
build:
go run ../gnovm/cmd/gno transpile --verbose --gobuild .
go run ../gnovm/cmd/gno transpile -v --gobuild .

.PHONY: test
test:
go run ../gnovm/cmd/gno test --verbose ./...
go run ../gnovm/cmd/gno test -v ./...

.PHONY: lint
lint:
go run ../gnovm/cmd/gno lint $(OFFICIAL_PACKAGES)

.PHONY: test.sync
test.sync:
go run ../gnovm/cmd/gno test --verbose --update-golden-tests ./...
go run ../gnovm/cmd/gno test -v --update-golden-tests ./...

.PHONY: clean
clean:
Expand Down
6 changes: 5 additions & 1 deletion examples/gno.land/p/demo/blog/blog.gno
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ type Blog struct {
}

func (b Blog) RenderLastPostsWidget(limit int) string {
if b.PostsPublished.Size() == 0 {
return "No posts."
}

output := ""
i := 0
b.Posts.Iterate("", "", func(key string, value interface{}) bool {
b.PostsPublished.ReverseIterate("", "", func(key string, value interface{}) bool {
p := value.(*Post)
output += ufmt.Sprintf("- [%s](%s)\n", p.Title, p.URL())
i++
Expand Down
Loading

0 comments on commit 7eb86e7

Please sign in to comment.