Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gnovm): add gno fmt command #2156

Merged
merged 79 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
8ab2991
feat: gnoimports
gfanton May 17, 2024
6b0ec9d
fix: apply gnoimports on examples folder
gfanton May 20, 2024
34663f9
chore: lint
gfanton May 21, 2024
7db6ae7
feat: add error parsing
gfanton May 21, 2024
aa85436
chore: add docs
gfanton May 21, 2024
3786be0
chore: tidy
gfanton May 21, 2024
2a14d15
Merge branch 'master' into feat/dev/gnoimport
gfanton May 21, 2024
f6bfb7f
feat: add ci
gfanton May 21, 2024
e983eb0
fix: outfmt
gfanton May 21, 2024
f19d049
chore: update contribs makefile
gfanton May 21, 2024
bb216f1
feat: move to gno package
gfanton May 21, 2024
3d6a5e7
feat: move gnoimports into `gno fmt`
gfanton May 22, 2024
316029c
chore: format ex folders
gfanton May 24, 2024
ed8c16b
chore: cleanup
gfanton May 24, 2024
6473143
fix: name import
gfanton May 24, 2024
12babf7
chore: update gno files
gfanton May 24, 2024
d3d6464
chore: cleanup gnoimports
gfanton May 24, 2024
bacbf5d
chore: lint
gfanton May 24, 2024
543f84f
fix: mod tidy
gfanton May 24, 2024
f020bc1
Merge branch 'master' into feat/dev/gnoimport
gfanton May 24, 2024
8678f7f
Merge branch 'master' into feat/dev/gnoimport
gfanton May 25, 2024
08b9efd
chore: use gno fmt on CI
gfanton May 26, 2024
977594a
chore: remove imports rule from examples/Makefile
gfanton May 26, 2024
2a8a4aa
chore: cleanup useless doc
gfanton May 26, 2024
a785357
fix: protect against injected method parsing
gfanton May 26, 2024
98c70f2
feat: add `diff` flag for debug purpose
gfanton May 26, 2024
3ee77d0
fix: simplify import processor
gfanton May 26, 2024
8f80d64
chore: apply `gno fmt`
gfanton May 26, 2024
65b6810
fix: cleanup
gfanton May 26, 2024
03a7ac7
chore: typo
gfanton May 27, 2024
6746ab2
Merge branch 'master' into feat/dev/gnoimport
gfanton Jun 3, 2024
e625a32
Merge remote-tracking branch 'origin/master' into feat/dev/gnoimport
gfanton Jun 5, 2024
63ef738
fix: add cmd unit test
gfanton Jun 5, 2024
4b49fa8
feat: add resolver
gfanton Jun 5, 2024
f9b0759
chore: run fmt
gfanton Jun 5, 2024
23f2d3e
chore: format & lint
gfanton Jun 5, 2024
5aa6c2d
Merge remote-tracking branch 'origin/master' into feat/dev/gnoimport
gfanton Jun 7, 2024
708cdac
fix: resolver
gfanton Jun 7, 2024
682389b
feat(test): add txtar `write` test
gfanton Jun 11, 2024
3ce9d9e
chore: make some adjustment
gfanton Jun 12, 2024
9fdfda7
feat: improve resolver with strict mode
gfanton Jun 12, 2024
877d1d7
fix: move lint & fmt txtar tests
gfanton Jun 13, 2024
ca76a63
chore: rename `test_test` to `testdata_test` to avoid confusion
gfanton Jun 13, 2024
3fd5a53
fix: resolve order
gfanton Jun 13, 2024
b552a2e
fix: add some tests
gfanton Jun 17, 2024
b34e068
fix: typo and package parsing
gfanton Jun 17, 2024
a739f6b
fix: improve resolving, add test
gfanton Jun 17, 2024
86f37d8
feat: fmt stdlibs
gfanton Jun 17, 2024
5950b2b
Merge branch 'master' into feat/dev/gnoimport
gfanton Jun 17, 2024
ce1a703
fix: gnovm yaml
gfanton Jun 17, 2024
267b5be
fix: fmt & lint
gfanton Jun 17, 2024
ad0841b
chore: lint yaml
gfanton Jun 17, 2024
e69e075
feat: add mock resolver
gfanton Jun 17, 2024
45f06ef
feat: do not use use fs inside processor
gfanton Jun 17, 2024
0be5356
fix: typo
gfanton Jun 17, 2024
7094871
chore: lint
gfanton Jun 17, 2024
e2a2d96
chore: remove strict flag
gfanton Jun 24, 2024
2a24dd4
chore: use parallel testing
gfanton Jun 24, 2024
a49d00d
chore: unexpose mock resolver/package
gfanton Jun 24, 2024
c275208
chore: cleanup useless return
gfanton Jun 24, 2024
dd27958
fix: use pkg handler
gfanton Jun 24, 2024
15fbea7
chore: use commands.Exit
gfanton Jun 24, 2024
281c9cc
chore: use continue in gno process files utility methods
gfanton Jun 24, 2024
a8cebe9
Merge remote-tracking branch 'origin/master' into feat/dev/gnoimport
gfanton Jun 24, 2024
9b15600
fix: failing test
gfanton Jun 24, 2024
f79cab0
fix: walkdir method
gfanton Jun 24, 2024
017dd5b
fix: dir wrong path
gfanton Jun 24, 2024
6820b00
chore: lint
gfanton Jun 24, 2024
8725d9a
chore: remove default options instance
gfanton Jun 24, 2024
1d1be06
fix: fmt tests
gfanton Jun 24, 2024
545d5f8
Merge remote-tracking branch 'origin/master' into feat/dev/gnoimport
gfanton Jul 1, 2024
a676881
Merge remote-tracking branch 'origin/master' into feat/dev/gnoimport
gfanton Jul 1, 2024
6282c84
fix: update fmt
gfanton Jul 1, 2024
3395cbe
fix: update bin gen
gfanton Jul 1, 2024
fc31c3d
Merge branch 'master' into feat/dev/gnoimport
moul Jul 2, 2024
58426fa
chore: rename gnoimports -> gnofmt
gfanton Jul 2, 2024
1dbdd96
Merge branch 'master' into feat/dev/gnoimport
gfanton Jul 2, 2024
4a40e2b
fix: process invalid package name
gfanton Jul 2, 2024
0386979
chore: run gno fmt
gfanton Jul 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ jobs:
- run: make lint -C ./examples
# TODO: consider running lint on every other directories, maybe in "warning" mode?
# TODO: track coverage
fmt:
strategy:
fail-fast: false
matrix:
goversion: [ "1.22.x" ]
zivkovicmilos marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.goversion }}
- run: |
make fmt -C ./examples
# Check if there are changes after running make fmt
git diff --exit-code || (echo "Some gno files are not formatted, please run 'make fmt'." && exit 1)
mod-tidy:
strategy:
fail-fast: false
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/gnofmt_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
workflow_call:
inputs:
path:
required: true
type: string
go-version:
required: true
type: string

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}
- name: Checkout code
uses: actions/checkout@v4
- name: Fmt
env:
GNOFMT_PATH: ${{ inputs.path }}
run: go run ./gnovm/cmd/gno fmt -v -diff $GNOFMT_PATH
6 changes: 6 additions & 0 deletions .github/workflows/gnovm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ jobs:
modulepath: "gnovm"
secrets:
codecov-token: ${{ secrets.CODECOV_TOKEN }}
fmt:
name: Run Gno Fmt
uses: ./.github/workflows/gnofmt_template.yml
with:
path: "gnovm/stdlibs/..."
go-version: "1.22.x"
9 changes: 2 additions & 7 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,9 @@ clean:
find . \( -name "*.gno.gen.go" -or -name ".*.gno.gen_test.go" \) -delete

.PHONY: fmt
GOFMT_FLAGS ?= -w
GNOFMT_FLAGS ?= -w
fmt:
go run -modfile ../misc/devdeps/go.mod mvdan.cc/gofumpt $(GOFMT_FLAGS) `find . -name "*.gno"`

.PHONY: imports
GOIMPORTS_FLAGS ?= -w
imports:
$(rundep) golang.org/x/tools/cmd/goimports $(GOIMPORTS_FLAGS) .
go run ../gnovm/cmd/gno fmt $(GNOFMT_FLAGS) ./...

.PHONY: tidy
tidy:
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/avl/tree_test.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package avl

import (
"testing"
)
import "testing"

func TestNewTree(t *testing.T) {
tree := NewTree()
Expand Down
5 changes: 1 addition & 4 deletions examples/gno.land/p/demo/bf/bf_test.gno
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package bf

import (
"bytes"
"testing"
)
import "testing"

func TestExecuteBrainfuck(t *testing.T) {
testCases := []struct {
Expand Down
1 change: 0 additions & 1 deletion examples/gno.land/p/demo/cford32/cford32_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"io"
"math"
"strconv"
"strings"
"testing"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"std"
"time"

"gno.land/p/demo/grc/exts/vault"
"gno.land/p/demo/grc/grc20"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package grc1155

import (
"fmt"
"std"
"testing"

"gno.land/p/demo/users"
)

const dummyURI = "ipfs://xyz"
Expand Down
1 change: 0 additions & 1 deletion examples/gno.land/p/demo/grc/grc1155/gno.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ module gno.land/p/demo/grc/grc1155
require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/users v0.0.0-latest
)
3 changes: 0 additions & 3 deletions examples/gno.land/p/demo/grc/grc721/basic_nft_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package grc721
import (
"std"
"testing"

"gno.land/p/demo/testutils"
"gno.land/p/demo/users"
)

var (
Expand Down
1 change: 0 additions & 1 deletion examples/gno.land/p/demo/grc/grc721/gno.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/users v0.0.0-latest
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"testing"

"gno.land/p/demo/testutils"
"gno.land/p/demo/users"
)

func TestSetMetadata(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/grc/grc721/grc721_royalty_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"testing"

"gno.land/p/demo/testutils"
"gno.land/p/demo/ufmt"
"gno.land/p/demo/users"
)

func TestSetTokenRoyalty(t *testing.T) {
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/grc/grc721/igrc721_royalty.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package grc721

import (
"std"
)
import "std"

// IGRC2981 follows the Ethereum standard
type IGRC2981 interface {
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/groups/groups.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package groups

import (
"gno.land/r/demo/boards"
)
import "gno.land/r/demo/boards"

// TODO implement something and test.
type Group struct {
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/int256/absolute.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package int256

import (
"gno.land/p/demo/uint256"
)
import "gno.land/p/demo/uint256"

// Abs returns |z|
func (z *Int) Abs() *uint256.Uint {
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/int256/arithmetic.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package int256

import (
"gno.land/p/demo/uint256"
)
import "gno.land/p/demo/uint256"

func (z *Int) Add(x, y *Int) *Int {
z.initiateAbs()
Expand Down
6 changes: 2 additions & 4 deletions examples/gno.land/p/demo/int256/bitwise_test.gno
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package int256

import (
"gno.land/p/demo/uint256"
)

import (
"testing"

"gno.land/p/demo/uint256"
)

func TestOr(t *testing.T) {
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/int256/cmp_test.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package int256

import (
"testing"
)
import "testing"

func TestEq(t *testing.T) {
tests := []struct {
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/int256/conversion.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package int256

import (
"gno.land/p/demo/uint256"
)
import "gno.land/p/demo/uint256"

// SetInt64 sets z to x and returns z.
func (z *Int) SetInt64(x int64) *Int {
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/int256/int256_test.gno
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// ported from github.com/mempooler/int256
package int256

import (
"testing"
)
import "testing"

func TestSign(t *testing.T) {
tests := []struct {
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/json/buffer_test.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package json

import (
"testing"
)
import "testing"

func TestBufferCurrent(t *testing.T) {
tests := []struct {
Expand Down
1 change: 0 additions & 1 deletion examples/gno.land/p/demo/json/decode_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package json

import (
"bytes"
"encoding/json"
"testing"
)

Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/json/encode_test.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package json

import (
"testing"
)
import "testing"

func TestMarshal_Primitive(t *testing.T) {
tests := []struct {
Expand Down
5 changes: 1 addition & 4 deletions examples/gno.land/p/demo/json/parser_test.gno
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package json

import (
"strconv"
"testing"
)
import "testing"

func TestParseStringLiteral(t *testing.T) {
tests := []struct {
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/json/path_test.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package json

import (
"testing"
)
import "testing"

func TestParseJSONPath(t *testing.T) {
tests := []struct {
Expand Down
7 changes: 1 addition & 6 deletions examples/gno.land/p/demo/math_eval/int32/int32_test.gno
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package int32

import (
"std"
"testing"

"gno.land/p/demo/ufmt"
)
import "testing"

func TestOne(t *testing.T) {
ttt := []struct {
Expand Down
1 change: 0 additions & 1 deletion examples/gno.land/p/demo/merkle/merkle_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package merkle
import (
"fmt"
"testing"
"time"
)

type testData struct {
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/mux/response.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package mux

import (
"strings"
)
import "strings"

// ResponseWriter represents the response writer.
type ResponseWriter struct {
Expand Down
5 changes: 1 addition & 4 deletions examples/gno.land/p/demo/mux/router_test.gno
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package mux

import (
"strings"
"testing"
)
import "testing"

func TestRouter_Render(t *testing.T) {
// Define handlers and route configuration
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/stack/stack_test.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package stack

import (
"testing"
)
import "testing"

func TestStack(t *testing.T) {
s := New() // Empty stack
Expand Down
1 change: 0 additions & 1 deletion examples/gno.land/p/demo/tamagotchi/z0_filetest.gno
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"std"
"time"

"internal/os_test"
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/uint256/bitwise_test.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package uint256

import (
"testing"
)
import "testing"

type logicOpTest struct {
name string
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/p/demo/uint256/conversion_test.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package uint256

import (
"testing"
)
import "testing"

func TestIsUint64(t *testing.T) {
tests := []struct {
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/r/demo/art/millipede/millipede_test.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package millipede

import (
"testing"
)
import "testing"

func TestRender(t *testing.T) {
cases := []struct {
Expand Down
4 changes: 1 addition & 3 deletions examples/gno.land/r/demo/echo/echo_test.gno
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package echo

import (
"testing"
)
import "testing"

func Test(t *testing.T) {
if Render("aa") != "aa" {
Expand Down
Loading
Loading