From 99633b9b05787c655bdf720e2f18cd112ba3a246 Mon Sep 17 00:00:00 2001 From: Manfred Touron <94029+moul@users.noreply.github.com> Date: Wed, 14 Jun 2023 18:47:00 +0200 Subject: [PATCH 1/2] feat(docs): script to gen godoc and publish on gh-pages (#884) --- .github/workflows/gh-pages.yml | 40 ++++++++++++++++++++++++++++++++++ misc/devdeps/Makefile | 1 + misc/devdeps/deps.go | 3 +++ misc/devdeps/go.mod | 1 + misc/devdeps/go.sum | 2 ++ misc/gendocs/.gitignore | 1 + misc/gendocs/Makefile | 10 +++++++++ misc/gendocs/gendocs.sh | 35 +++++++++++++++++++++++++++++ 8 files changed, 93 insertions(+) create mode 100644 .github/workflows/gh-pages.yml create mode 100644 misc/gendocs/.gitignore create mode 100644 misc/gendocs/Makefile create mode 100755 misc/gendocs/gendocs.sh diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml new file mode 100644 index 00000000000..8586c6548b3 --- /dev/null +++ b/.github/workflows/gh-pages.yml @@ -0,0 +1,40 @@ +# generate docs and publish on gh-pages branch +name: gh-pages + +on: + push: + branches: [$default-branch] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: "cd misc/devdeps && make install" + - run: "cd misc/gendocs && make gen" + - run: "find docs/ -type f -ls" + - uses: actions/configure-pages@v3 + id: pages + - uses: actions/upload-pages-artifact@v1 + with: + path: ./misc/gendocs/godoc + + deploy: + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + needs: build + steps: + - uses: actions/deploy-pages@v2 + id: deployment diff --git a/misc/devdeps/Makefile b/misc/devdeps/Makefile index 54df62cc031..99aea512ed0 100644 --- a/misc/devdeps/Makefile +++ b/misc/devdeps/Makefile @@ -1,3 +1,4 @@ install: go install mvdan.cc/gofumpt go install google.golang.org/protobuf/cmd/protoc-gen-go + go install golang.org/x/tools/cmd/godoc diff --git a/misc/devdeps/deps.go b/misc/devdeps/deps.go index ec5061b4770..cbc3f8252c8 100644 --- a/misc/devdeps/deps.go +++ b/misc/devdeps/deps.go @@ -17,4 +17,7 @@ import ( // protoc, genproto _ "google.golang.org/protobuf/cmd/protoc-gen-go" + + // gen docs + _ "golang.org/x/tools/cmd/godoc" ) diff --git a/misc/devdeps/go.mod b/misc/devdeps/go.mod index 3b70c0143be..97805e98a3c 100644 --- a/misc/devdeps/go.mod +++ b/misc/devdeps/go.mod @@ -15,6 +15,7 @@ require ( github.com/peterbourgon/ff/v3 v3.3.0 // indirect github.com/sergi/go-diff v1.2.0 // indirect github.com/stretchr/testify v1.7.1 // indirect + github.com/yuin/goldmark v1.4.13 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.8.0 // indirect golang.org/x/exp v0.0.0-20221026153819-32f3d567a233 // indirect diff --git a/misc/devdeps/go.sum b/misc/devdeps/go.sum index 40b8a4b900b..449328ee8a0 100644 --- a/misc/devdeps/go.sum +++ b/misc/devdeps/go.sum @@ -72,6 +72,8 @@ github.com/tailscale/depaware v0.0.0-20210622194025-720c4b409502/go.mod h1:p9lPs github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= diff --git a/misc/gendocs/.gitignore b/misc/gendocs/.gitignore new file mode 100644 index 00000000000..6df74eaa426 --- /dev/null +++ b/misc/gendocs/.gitignore @@ -0,0 +1 @@ +godoc/ \ No newline at end of file diff --git a/misc/gendocs/Makefile b/misc/gendocs/Makefile new file mode 100644 index 00000000000..8a4f3ba2de5 --- /dev/null +++ b/misc/gendocs/Makefile @@ -0,0 +1,10 @@ +all: clean gen + +gen: + ./gendocs.sh + +clean: + rm -rf godoc + +kill_zombies: + kill -9 `lsof -t -i tcp:6060 -s TCP:LISTEN` || true diff --git a/misc/gendocs/gendocs.sh b/misc/gendocs/gendocs.sh new file mode 100755 index 00000000000..d7621acd5a0 --- /dev/null +++ b/misc/gendocs/gendocs.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +GODOC_PORT=${GODOC_PORT:-6060} +GO_MODULE=${GO_MODULE:-github.com/gnolang/gno} +GODOC_OUT=${GODOC_OUT:-godoc} +URL=http://localhost:${GODOC_PORT}/pkg/github.com/gnolang/gno/ + +echo "[+] Starting godoc server..." +go run \ + -modfile ../devdeps/go.mod \ + golang.org/x/tools/cmd/godoc \ + -http="localhost:${GODOC_PORT}" & +PID=$! +# Waiting for godoc server +while ! curl --fail --silent "$URL" > /dev/null 2>&1; do + sleep 0.1 +done + +echo "[+] Downloading godoc pages..." +wget \ + --recursive \ + --no-verbose \ + --convert-links \ + --page-requisites \ + --adjust-extension \ + --execute=robots=off \ + --include-directories="/lib,/pkg/$GO_MODULE,/src/$GO_MODULE" \ + --exclude-directories="*" \ + --directory-prefix="${GODOC_OUT}" \ + --no-host-directories \ + "$URL?m=all" + +echo "[+] Killing godoc server..." +kill -9 "$PID" + From 232754d93b945074e0bce915b1af07a13957c782 Mon Sep 17 00:00:00 2001 From: Morgan Date: Thu, 15 Jun 2023 18:12:58 +0200 Subject: [PATCH 2/2] fix(gnovm): zero-in Ops and Values correctly in (*Machine).Release (#894) --- gnovm/pkg/gnolang/machine.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index 0da2874afd3..0ad52550684 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -158,8 +158,8 @@ func (m *Machine) Release() { m.NumOps = 0 m.NumValues = 0 // this is the fastest way to zero-in a slice in Go - copy(m.Ops, opZeroed[:0]) - copy(m.Values, valueZeroed[:0]) + copy(m.Ops, opZeroed[:]) + copy(m.Values, valueZeroed[:]) machinePool.Put(m) }