diff --git a/.github/.fossa.yml b/.github/.fossa.yml deleted file mode 100644 index d639b393e98..00000000000 --- a/.github/.fossa.yml +++ /dev/null @@ -1,15 +0,0 @@ -version: 3 - -# https://github.com/fossas/fossa-cli/blob/master/docs/references/files/fossa-yml.md - -project: - id: github.com/gnolang/gno - name: gno - -targets: - only: - - type: gomod - -paths: - exclude: - - ./misc/ diff --git a/.github/codecov.yml b/.github/codecov.yml deleted file mode 100644 index d1ecba7ade3..00000000000 --- a/.github/codecov.yml +++ /dev/null @@ -1,46 +0,0 @@ -codecov: - require_ci_to_pass: true - notify: - wait_for_ci: true - -comment: - require_changes: false - -coverage: - round: down - precision: 2 - status: - project: - default: - target: auto - threshold: 10 # Let's decrease this later. - base: parent - if_no_uploads: error - if_not_found: success - if_ci_failed: error - only_pulls: false - patch: - default: - target: auto - threshold: 10 # Let's decrease this later. - base: auto - if_no_uploads: error - if_not_found: success - if_ci_failed: error - only_pulls: false - -flag_management: - default_rules: - carryforward: true - statuses: - - type: project - target: auto - threshold: 10 # Let's decrease this later. - - type: patch - target: auto # Let's decrease this later. - threshold: 10 - -ignore: - - "gnovm/stdlibs/generated.go" - - "gnovm/tests/stdlibs/generated.go" - - "**/*.pb.go" diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 6a2a2966370..00000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,35 +0,0 @@ -version: 2 -updates: - - # Maintain dependencies for GitHub Actions - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" - labels: - - "github_actions" - groups: - actions: - patterns: - - "*" - - # Maintain dependencies for top level Go modules - - package-ecosystem: gomod - directory: / - target-branch: "master" - schedule: - interval: weekly - labels: - - "dependencies" - groups: - golang-x: - patterns: - - "golang.org/x/*" - everything-else: - patterns: - - "*" - open-pull-requests-limit: 10 - pull-request-branch-name: - separator: "-" - reviewers: - - "moul" diff --git a/.github/golangci.yml b/.github/golangci.yml deleted file mode 100644 index b8bd5537135..00000000000 --- a/.github/golangci.yml +++ /dev/null @@ -1,85 +0,0 @@ -run: - concurrency: 8 - timeout: 10m - issue-exit-code: 1 - tests: true - skip-dirs-use-default: true - modules-download-mode: readonly - allow-parallel-runners: false - go: "" - -output: - uniq-by-line: false - path-prefix: "" - sort-results: true - -linters: - fast: false - disable-all: true - enable: - - whitespace # Tool for detection of leading and trailing whitespace - - unconvert # Unnecessary type conversions - - tparallel # Detects inappropriate usage of t.Parallel() method in your Go test codes - - thelper # Detects golang test helpers without t.Helper() call and checks the consistency of test helpers - - stylecheck # Stylecheck is a replacement for golint - - prealloc # Finds slice declarations that could potentially be pre-allocated - - predeclared # Finds code that shadows one of Go's predeclared identifiers - - nolintlint # Ill-formed or insufficient nolint directives - - misspell # Misspelled English words in comments - - makezero # Finds slice declarations with non-zero initial length - - importas # Enforces consistent import aliases - - govet # same as 'go vet' - - gosec # Security problems - - gofmt # Whether the code was gofmt-ed - - goimports # Unused imports - - goconst # Repeated strings that could be replaced by a constant - - dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f()) - - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error - - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13 - - gofumpt # Stricter gofmt - - unused # Checks Go code for unused constants, variables, functions and types - - gomodguard # Enforces an allow and block list for direct Go module dependencies - - forbidigo # Forbids some custom-set identifiers, like regexp.MatchString - -linters-settings: - gofmt: - simplify: true - goconst: - min-len: 3 - min-occurrences: 3 - gosec: - excludes: - - G204 # Subprocess launched with a potential tainted input or cmd arguments - - G306 # Expect WriteFile permissions to be 0600 or less - - G115 # Integer overflow conversion, no solution to check the overflow in time of convert, so linter shouldn't check the overflow. - stylecheck: - checks: [ "all", "-ST1022", "-ST1003" ] - errorlint: - asserts: false - gocritic: - enabled-tags: - - diagnostic - - experimental - - opinionated - - performance - - style - forbidigo: - forbid: - - p: '^regexp\.(Match|MatchString)$' - msg: it will re-compile the regexp for each execution; compile the regexp with regexp.Compile and store it as a singleton - -issues: - whole-files: true - max-issues-per-linter: 0 - max-same-issues: 0 - new: false - fix: false - exclude-rules: - - path: _test\.go - linters: - - gosec # Disabled linting of weak number generators - - makezero # Disabled linting of intentional slice appends - - goconst # Disabled linting of common mnemonics and test case strings - - path: _\.gno - linters: - - errorlint # Disabled linting of error comparisons, because of lacking std lib support diff --git a/.github/goreleaser.yaml b/.github/goreleaser.yaml deleted file mode 100644 index 71a8ba98745..00000000000 --- a/.github/goreleaser.yaml +++ /dev/null @@ -1,753 +0,0 @@ -# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json -project_name: gno -version: 2 - -env: - - TAG_VERSION={{ if index .Env "TAG_VERSION" }}{{ .Env.TAG_VERSION }}{{ else }}latest{{ end }} - # supported in next versions -> https://github.com/goreleaser/goreleaser/issues/5059 - # - TAG_VERSION="{{ envOrDefault "TAG_VERSION" "latest" }}" - -before: - hooks: - - go mod tidy - -builds: - - id: gno - main: ./gnovm/cmd/gno - binary: gno - env: - - CGO_ENABLED=0 - goos: - - linux - - darwin - goarch: - - amd64 - - arm64 - - arm - goarm: - - "6" - - "7" - - id: gnoland - main: ./gno.land/cmd/gnoland - binary: gnoland - env: - - CGO_ENABLED=0 - goos: - - linux - - darwin - goarch: - - amd64 - - arm64 - - arm - goarm: - - "6" - - "7" - - id: gnokey - main: ./gno.land/cmd/gnokey - binary: gnokey - env: - - CGO_ENABLED=0 - goos: - - linux - - darwin - goarch: - - amd64 - - arm64 - - arm - goarm: - - "6" - - "7" - - id: gnoweb - main: ./gno.land/cmd/gnoweb - binary: gnoweb - env: - - CGO_ENABLED=0 - goos: - - linux - - darwin - goarch: - - amd64 - - arm64 - - arm - goarm: - - "6" - - "7" - - id: gnofaucet - dir: ./contribs/gnofaucet - binary: gnofaucet - env: - - CGO_ENABLED=0 - goos: - - linux - - darwin - goarch: - - amd64 - - arm64 - - arm - goarm: - - "6" - - "7" - # Gno Contribs - # NOTE: Contribs binary will be added in a single docker image below: gnocontribs - - id: gnobro - dir: ./contribs/gnodev/cmd/gnobro - binary: gnobro - env: - - CGO_ENABLED=0 - goos: - - linux - - darwin - goarch: - - amd64 - - arm64 - - arm - goarm: - - "6" - - "7" - - id: gnogenesis - dir: ./contribs/gnogenesis - binary: gnogenesis - env: - - CGO_ENABLED=0 - goos: - - linux - - darwin - goarch: - - amd64 - - arm64 - - arm - goarm: - - "6" - - "7" - -gomod: - proxy: true - -archives: - # https://goreleaser.com/customization/archive/ - - files: - # Standard Release Files - - LICENSE.md - - README.md - -signs: - - cmd: cosign - env: - - COSIGN_EXPERIMENTAL=1 - certificate: "${artifact}.pem" - args: - - sign-blob - - "--output-certificate=${certificate}" - - "--output-signature=${signature}" - - "${artifact}" - - "--yes" # needed on cosign 2.0.0+ - artifacts: checksum - output: true - -dockers: - # https://goreleaser.com/customization/docker/ - - # gno - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: amd64 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-amd64" - - "ghcr.io/gnolang/{{ .ProjectName }}:{{ .Env.TAG_VERSION }}-amd64" - build_flag_templates: - - "--target=gno" - - "--platform=linux/amd64" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gno - extra_files: - - examples - - gnovm/stdlibs - - gnovm/tests/stdlibs - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm64 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-arm64v8" - - "ghcr.io/gnolang/{{ .ProjectName }}:{{ .Env.TAG_VERSION }}-arm64v8" - build_flag_templates: - - "--target=gno" - - "--platform=linux/arm64/v8" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gno - extra_files: - - examples - - gnovm/stdlibs - - gnovm/tests/stdlibs - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm - goarm: 6 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-armv6" - - "ghcr.io/gnolang/{{ .ProjectName }}:{{ .Env.TAG_VERSION }}-armv6" - build_flag_templates: - - "--target=gno" - - "--platform=linux/arm/v6" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gno - extra_files: - - examples - - gnovm/stdlibs - - gnovm/tests/stdlibs - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm - goarm: 7 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-armv7" - - "ghcr.io/gnolang/{{ .ProjectName }}:{{ .Env.TAG_VERSION }}-armv7" - build_flag_templates: - - "--target=gno" - - "--platform=linux/arm/v7" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gno - extra_files: - - examples - - gnovm/stdlibs - - gnovm/tests/stdlibs - - # gnoland - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: amd64 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Version }}-amd64" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Env.TAG_VERSION }}-amd64" - build_flag_templates: - - "--target=gnoland" - - "--platform=linux/amd64" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnoland" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnoland - extra_files: - - gno.land/genesis/genesis_balances.txt - - gno.land/genesis/genesis_txs.jsonl - - examples - - gnovm/stdlibs - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm64 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Version }}-arm64v8" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Env.TAG_VERSION }}-arm64v8" - build_flag_templates: - - "--target=gnoland" - - "--platform=linux/arm64/v8" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnoland" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnoland - extra_files: - - gno.land/genesis/genesis_balances.txt - - gno.land/genesis/genesis_txs.jsonl - - examples - - gnovm/stdlibs - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm - goarm: 6 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Version }}-armv6" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Env.TAG_VERSION }}-armv6" - build_flag_templates: - - "--target=gnoland" - - "--platform=linux/arm/v6" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnoland" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnoland - extra_files: - - gno.land/genesis/genesis_balances.txt - - gno.land/genesis/genesis_txs.jsonl - - examples - - gnovm/stdlibs - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm - goarm: 7 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Version }}-armv7" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Env.TAG_VERSION }}-armv7" - build_flag_templates: - - "--target=gnoland" - - "--platform=linux/arm/v7" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnoland" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnoland - extra_files: - - gno.land/genesis/genesis_balances.txt - - gno.land/genesis/genesis_txs.jsonl - - examples - - gnovm/stdlibs - - # gnokey - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: amd64 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Version }}-amd64" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Env.TAG_VERSION }}-amd64" - build_flag_templates: - - "--target=gnokey" - - "--platform=linux/amd64" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnokey" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnokey - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm64 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Version }}-arm64v8" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Env.TAG_VERSION }}-arm64v8" - build_flag_templates: - - "--target=gnokey" - - "--platform=linux/arm64/v8" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnokey" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnokey - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm - goarm: 6 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Version }}-armv6" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Env.TAG_VERSION }}-armv6" - build_flag_templates: - - "--target=gnokey" - - "--platform=linux/arm/v6" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnokey" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnokey - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm - goarm: 7 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Version }}-armv7" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Env.TAG_VERSION }}-armv7" - build_flag_templates: - - "--target=gnokey" - - "--platform=linux/arm/v7" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnokey" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnokey - - # gnoweb - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: amd64 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Version }}-amd64" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Env.TAG_VERSION }}-amd64" - build_flag_templates: - - "--target=gnoweb" - - "--platform=linux/amd64" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnoweb" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnoweb - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm64 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Version }}-arm64v8" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Env.TAG_VERSION }}-arm64v8" - build_flag_templates: - - "--target=gnoweb" - - "--platform=linux/arm64/v8" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnoweb" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnoweb - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm - goarm: 6 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Version }}-armv6" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Env.TAG_VERSION }}-armv6" - build_flag_templates: - - "--target=gnoweb" - - "--platform=linux/arm/v6" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnoweb" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnoweb - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm - goarm: 7 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Version }}-armv7" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Env.TAG_VERSION }}-armv7" - build_flag_templates: - - "--target=gnoweb" - - "--platform=linux/arm/v7" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnoweb" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnoweb - - # gnofaucet - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: amd64 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Version }}-amd64" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Env.TAG_VERSION }}-amd64" - build_flag_templates: - - "--target=gnofaucet" - - "--platform=linux/amd64" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnofaucet" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnofaucet - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm64 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Version }}-arm64v8" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Env.TAG_VERSION }}-arm64v8" - build_flag_templates: - - "--target=gnofaucet" - - "--platform=linux/arm64/v8" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnofaucet" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnofaucet - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm - goarm: 6 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Version }}-armv6" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Env.TAG_VERSION }}-armv6" - build_flag_templates: - - "--target=gnofaucet" - - "--platform=linux/arm/v6" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnofaucet" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnofaucet - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm - goarm: 7 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Version }}-armv7" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Env.TAG_VERSION }}-armv7" - build_flag_templates: - - "--target=gnofaucet" - - "--platform=linux/arm/v7" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnofaucet" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnofaucet - - # gnocontribs - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: amd64 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Version }}-amd64" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Env.TAG_VERSION }}-amd64" - build_flag_templates: - - "--target=gnocontribs" - - "--platform=linux/amd64" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnocontribs" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnobro - - gnogenesis - extra_files: - - gno.land/genesis/genesis_balances.txt - - gno.land/genesis/genesis_txs.jsonl - - examples - - gnovm/stdlibs - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm64 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Version }}-arm64v8" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Env.TAG_VERSION }}-arm64v8" - build_flag_templates: - - "--target=gnocontribs" - - "--platform=linux/arm64/v8" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnocontribs" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnobro - - gnogenesis - extra_files: - - gno.land/genesis/genesis_balances.txt - - gno.land/genesis/genesis_txs.jsonl - - examples - - gnovm/stdlibs - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm - goarm: 6 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Version }}-armv6" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Env.TAG_VERSION }}-armv6" - build_flag_templates: - - "--target=gnocontribs" - - "--platform=linux/arm/v6" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnocontribs" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnobro - - gnogenesis - extra_files: - - gno.land/genesis/genesis_balances.txt - - gno.land/genesis/genesis_txs.jsonl - - examples - - gnovm/stdlibs - - use: buildx - dockerfile: Dockerfile.release - goos: linux - goarch: arm - goarm: 7 - image_templates: - - "ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Version }}-armv7" - - "ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Env.TAG_VERSION }}-armv7" - build_flag_templates: - - "--target=gnocontribs" - - "--platform=linux/arm/v7" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}/gnocontribs" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - ids: - - gnobro - - gnogenesis - extra_files: - - gno.land/genesis/genesis_balances.txt - - gno.land/genesis/genesis_txs.jsonl - - examples - - gnovm/stdlibs - -docker_manifests: - # https://goreleaser.com/customization/docker_manifest/ - - # gno - - name_template: ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }} - image_templates: - - ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-amd64 - - ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-arm64v8 - - ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-armv6 - - ghcr.io/gnolang/{{ .ProjectName }}:{{ .Version }}-armv7 - - name_template: ghcr.io/gnolang/{{ .ProjectName }}:{{ .Env.TAG_VERSION }} - image_templates: - - ghcr.io/gnolang/{{ .ProjectName }}:{{ .Env.TAG_VERSION }}-amd64 - - ghcr.io/gnolang/{{ .ProjectName }}:{{ .Env.TAG_VERSION }}-arm64v8 - - ghcr.io/gnolang/{{ .ProjectName }}:{{ .Env.TAG_VERSION }}-armv6 - - ghcr.io/gnolang/{{ .ProjectName }}:{{ .Env.TAG_VERSION }}-armv7 - - # gnoland - - name_template: ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Version }} - image_templates: - - ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Version }}-amd64 - - ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Version }}-arm64v8 - - ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Version }}-armv6 - - ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Version }}-armv7 - - name_template: ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Env.TAG_VERSION }} - image_templates: - - ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Env.TAG_VERSION }}-amd64 - - ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Env.TAG_VERSION }}-arm64v8 - - ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Env.TAG_VERSION }}-armv6 - - ghcr.io/gnolang/{{ .ProjectName }}/gnoland:{{ .Env.TAG_VERSION }}-armv7 - - # gnokey - - name_template: ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Version }} - image_templates: - - ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Version }}-amd64 - - ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Version }}-arm64v8 - - ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Version }}-armv6 - - ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Version }}-armv7 - - name_template: ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Env.TAG_VERSION }} - image_templates: - - ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Env.TAG_VERSION }}-amd64 - - ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Env.TAG_VERSION }}-arm64v8 - - ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Env.TAG_VERSION }}-armv6 - - ghcr.io/gnolang/{{ .ProjectName }}/gnokey:{{ .Env.TAG_VERSION }}-armv7 - - # gnoweb - - name_template: ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Version }} - image_templates: - - ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Version }}-amd64 - - ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Version }}-arm64v8 - - ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Version }}-armv6 - - ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Version }}-armv7 - - name_template: ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Env.TAG_VERSION }} - image_templates: - - ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Env.TAG_VERSION }}-amd64 - - ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Env.TAG_VERSION }}-arm64v8 - - ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Env.TAG_VERSION }}-armv6 - - ghcr.io/gnolang/{{ .ProjectName }}/gnoweb:{{ .Env.TAG_VERSION }}-armv7 - - # gnofaucet - - name_template: ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Version }} - image_templates: - - ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Version }}-amd64 - - ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Version }}-arm64v8 - - ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Version }}-armv6 - - ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Version }}-armv7 - - name_template: ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Env.TAG_VERSION }} - image_templates: - - ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Env.TAG_VERSION }}-amd64 - - ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Env.TAG_VERSION }}-arm64v8 - - ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Env.TAG_VERSION }}-armv6 - - ghcr.io/gnolang/{{ .ProjectName }}/gnofaucet:{{ .Env.TAG_VERSION }}-armv7 - - # gnocontribs - - name_template: ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Version }} - image_templates: - - ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Version }}-amd64 - - ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Version }}-arm64v8 - - ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Version }}-armv6 - - ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Version }}-armv7 - - name_template: ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Env.TAG_VERSION }} - image_templates: - - ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Env.TAG_VERSION }}-amd64 - - ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Env.TAG_VERSION }}-arm64v8 - - ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Env.TAG_VERSION }}-armv6 - - ghcr.io/gnolang/{{ .ProjectName }}/gnocontribs:{{ .Env.TAG_VERSION }}-armv7 - -docker_signs: - - cmd: cosign - env: - - COSIGN_EXPERIMENTAL=1 - artifacts: images - output: true - args: - - "sign" - - "${artifact}" - - "--yes" # needed on cosign 2.0.0+ - -checksum: - name_template: "checksums.txt" - -changelog: - sort: asc - -source: - enabled: true - -sboms: - - artifacts: archive - - id: source # Two different sbom configurations need two different IDs - artifacts: source - -release: - disable: '{{ if eq .Env.TAG_VERSION "master" }}true{{ else }}false{{ end }}' - skip_upload: '{{ if eq .Env.TAG_VERSION "master" }}true{{ else }}false{{ end }}' - draft: true - replace_existing_draft: true - prerelease: auto - mode: append - footer: | - ### Container Images - - You can find all docker images at: - - https://github.com/orgs/gnolang/packages?repo_name={{ .ProjectName }} - -# Only valid for nightly build -nightly: - tag_name: nightly - publish_release: true - keep_single_release: true - version_template: "{{ incpatch .Version }}-{{ .ShortCommit }}-{{ .Env.TAG_VERSION }}" - -git: - ignore_tag_prefixes: - - "chain/" diff --git a/.github/labeler.yml b/.github/labeler.yml deleted file mode 100644 index 64075fd1860..00000000000 --- a/.github/labeler.yml +++ /dev/null @@ -1,24 +0,0 @@ -":receipt: package/realm": -- changed-files: - - any-glob-to-any-file: - - examples/**/* - -":package: :robot: gnovm": -- changed-files: - - any-glob-to-any-file: - - gnovm/**/* - -":package: :globe_with_meridians: tendermint v2": -- changed-files: - - any-glob-to-any-file: - - tm2/**/* - -":package: :mountain: gno.land": -- changed-files: - - any-glob-to-any-file: - - "gno.land/**/*" - -":book: documentation": -- changed-files: - - any-glob-to-any-file: - - docs/**/*" diff --git a/.github/workflows/auto-author-assign.yml b/.github/workflows/auto-author-assign.yml deleted file mode 100644 index 06dfb4ab903..00000000000 --- a/.github/workflows/auto-author-assign.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: auto-author-assign - -on: - pull_request_target: - types: [ opened, reopened ] - -permissions: - pull-requests: write - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - assign-author: - runs-on: ubuntu-latest - steps: - - uses: toshimaru/auto-author-assign@v2.1.1 diff --git a/.github/workflows/autocounterd.yml b/.github/workflows/autocounterd.yml deleted file mode 100644 index 9217fe2eef2..00000000000 --- a/.github/workflows/autocounterd.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: autocounterd - -on: - pull_request: - branches: - - master - push: - paths: - - misc/autocounterd - - misc/loop - - .github/workflows/autocounterd.yml - branches: - - "master" - - "misc/autocounterd" - tags: - - "v*" - -permissions: - contents: read - packages: write - -jobs: - autocounterd: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Docker metadata autocounterd - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository }}/autocounterd - tags: | - type=raw,value=latest - type=semver,pattern=v{{version}} - - - name: Build and push - uses: docker/build-push-action@v6 - with: - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/benchmark-master-push.yml b/.github/workflows/benchmark-master-push.yml deleted file mode 100644 index 622baefc0de..00000000000 --- a/.github/workflows/benchmark-master-push.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: run benchmarks when pushing on main branch - -on: - push: - branches: - - master - paths: - - contribs/** - - gno.land/** - - gnovm/** - - tm2/** - -permissions: - # deployments permission to deploy GitHub pages website - deployments: write - # contents permission to update benchmark contents in gh-pages branch - contents: write - -env: - CGO_ENABLED: 0 - -jobs: - benchmarks: - if: ${{ github.repository == 'gnolang/gno' }} - runs-on: [self-hosted, Linux, X64, benchmarks] - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - - name: Run benchmark - # add more benchmarks by adding additional lines for different packages; - # or modify the -bench regexp. - run: | - set -xeuo pipefail && ( - go test ./gnovm/pkg/gnolang -bench='BenchmarkBenchdata' -benchmem -run='^$' -v -cpu=1,2 - ) | tee benchmarks.txt - - - name: Download previous benchmark data - uses: actions/cache@v4 - with: - path: ./cache - key: ${{ runner.os }}-benchmark - - - name: Store benchmark results into `gh-benchmarks` branch - uses: benchmark-action/github-action-benchmark@v1 - # see https://github.com/benchmark-action/github-action-benchmark?tab=readme-ov-file#action-inputs - with: - name: Go Benchmarks - tool: "go" - output-file-path: benchmarks.txt - max-items-in-chart: 100 - # Show alert with commit comment on detecting possible performance regression - alert-threshold: "120%" - fail-on-alert: false - comment-on-alert: true - alert-comment-cc-users: "@ajnavarro,@thehowl,@zivkovicmilos" - # Enable Job Summary for PRs - summary-always: true - github-token: ${{ secrets.GITHUB_TOKEN }} - # NOTE you need to use a separate GITHUB PAT token that has a write access to the specified repository. - # gh-repository: 'github.com/gnolang/benchmarks' # on gh-pages branch - gh-pages-branch: gh-benchmarks - benchmark-data-dir-path: . - auto-push: true diff --git a/.github/workflows/bot.yml b/.github/workflows/bot.yml deleted file mode 100644 index 300a5928e25..00000000000 --- a/.github/workflows/bot.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: GitHub Bot - -on: - # Watch for changes on PR state, assignees, labels, head branch and draft/ready status - pull_request_target: - types: - - assigned - - unassigned - - labeled - - unlabeled - - opened - - reopened - - synchronize # PR head updated - - converted_to_draft - - ready_for_review - - # Watch for changes on PR reviews - pull_request_review: - types: [submitted, edited, dismissed] - - # Watch for changes on PR comment - issue_comment: - types: [created, edited, deleted] - - # Manual run from GitHub Actions interface - workflow_dispatch: - inputs: - pull-request-list: - description: "PR(s) to process: specify 'all' or a comma separated list of PR numbers, e.g. '42,1337,7890'" - required: true - default: all - type: string - -jobs: - # This job creates a matrix of PR numbers based on the inputs from the various - # events that can trigger this workflow so that the process-pr job below can - # handle the parallel processing of the pull-requests - define-prs-matrix: - name: Define PRs matrix - # Prevent bot from retriggering itself and ignore event emitted by codecov - if: ${{ github.actor != vars.GH_BOT_LOGIN && github.actor != 'codecov[bot]' }} - runs-on: ubuntu-latest - permissions: - pull-requests: read - outputs: - pr-numbers: ${{ steps.pr-numbers.outputs.pr-numbers }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version-file: contribs/github-bot/go.mod - - - name: Generate matrix from event - id: pr-numbers - working-directory: contribs/github-bot - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: go run . matrix -matrix-key 'pr-numbers' -verbose - - # This job processes each pull request in the matrix individually while ensuring - # that a same PR cannot be processed concurrently by mutliple runners - process-pr: - name: Process PR - needs: define-prs-matrix - # Just skip this job if PR numbers matrix is empty (prevent failed state) - if: ${{ needs.define-prs-matrix.outputs.pr-numbers != '[]' && needs.define-prs-matrix.outputs.pr-numbers != '' }} - runs-on: ubuntu-latest - strategy: - matrix: - # Run one job for each PR to process - pr-number: ${{ fromJSON(needs.define-prs-matrix.outputs.pr-numbers) }} - concurrency: - # Prevent running concurrent jobs for a given PR number - group: ${{ matrix.pr-number }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version-file: contribs/github-bot/go.mod - - - name: Run GitHub Bot - working-directory: contribs/github-bot - env: - GITHUB_TOKEN: ${{ secrets.GH_BOT_PAT }} - run: go run . check -pr-numbers '${{ matrix.pr-number }}' -verbose diff --git a/.github/workflows/build_template.yml b/.github/workflows/build_template.yml deleted file mode 100644 index a2c96f2d37e..00000000000 --- a/.github/workflows/build_template.yml +++ /dev/null @@ -1,31 +0,0 @@ -on: - workflow_call: - inputs: - modulepath: - required: true - type: string - go-version: - required: true - type: string - -jobs: - generated: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ inputs.go-version }} - - - name: Check generated files are up to date - working-directory: ${{ inputs.modulepath }} - run: | - go generate -x ./... - if [ "$(git status -s)" != "" ]; then - echo "command 'go generate' creates file that differ from git tree, please run 'go generate' and commit:" - git status -s - exit 1 - fi diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index d2eef9d7445..00000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,89 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ "master", "chain/*" ] - pull_request: - branches: [ "master", "chain/*" ] - schedule: - - cron: '22 17 * * 3' - -jobs: - analyze: - name: Analyze (${{ matrix.language }}) - # Runner size impacts CodeQL analysis time. To learn more, please see: - # - https://gh.io/recommended-hardware-resources-for-running-codeql - # - https://gh.io/supported-runners-and-hardware-resources - # - https://gh.io/using-larger-runners (GitHub.com only) - # Consider using larger runners or machines with greater resources for possible analysis time improvements. - runs-on: ubuntu-latest - timeout-minutes: 360 - permissions: - # required for all workflows - security-events: write - - # only required for workflows in private repositories - actions: read - contents: read - - strategy: - fail-fast: false - matrix: - include: - - language: go - build-mode: autobuild - # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' - # Use `c-cpp` to analyze code written in C, C++ or both - # Use 'java-kotlin' to analyze code written in Java, Kotlin or both - # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both - # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, - # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. - # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how - # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - build-mode: ${{ matrix.build-mode }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - # If the analyze step fails for one of the languages you are analyzing with - # "We were unable to automatically build your code", modify the matrix above - # to set the build mode to "manual" for that language. Then modify this step - # to build your code. - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - if: matrix.build-mode == 'manual' - run: | - echo 'If you are using a "manual" build mode for one or more of the' \ - 'languages you are analyzing, replace this with the commands to build' \ - 'your code, for example:' - echo ' make bootstrap' - echo ' make release' - exit 1 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{matrix.language}}" diff --git a/.github/workflows/contribs.yml b/.github/workflows/contribs.yml deleted file mode 100644 index 3739339f7be..00000000000 --- a/.github/workflows/contribs.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: contribs - -on: - push: - branches: - - master - workflow_dispatch: - pull_request: - -jobs: - setup: - runs-on: ubuntu-latest - outputs: - programs: ${{ steps.set-matrix.outputs.programs }} - steps: - - uses: actions/checkout@v4 - - id: set-matrix - run: echo "::set-output name=programs::$(ls -d contribs/*/ | cut -d/ -f2 | jq -R -s -c 'split("\n")[:-1]')" - main: - needs: setup - strategy: - fail-fast: false - matrix: - program: ${{ fromJson(needs.setup.outputs.programs) }} - name: Run Main - uses: ./.github/workflows/main_template.yml - with: - modulepath: contribs/${{ matrix.program }} - secrets: - codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/dependabot-tidy.yml b/.github/workflows/dependabot-tidy.yml deleted file mode 100644 index 39fed8b0172..00000000000 --- a/.github/workflows/dependabot-tidy.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Dependabot Tidy Go Mods - -on: - pull_request: - paths: - - '.github/workflows/**' - - '**/go.mod' - - '**/go.sum' - -jobs: - tidy_go_mods: - runs-on: ubuntu-latest - if: ${{ github.actor == 'dependabot[bot]' }} - permissions: - contents: write - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - - name: Tidy all Go mods - env: - VERIFY_MOD_SUMS: false - run: | - # Ensure Make is installed - make --version - - # Run the tidy target - make tidy - - - name: Commit changes, if any - uses: stefanzweifel/git-auto-commit-action@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - skip_dirty_check: false # Enable dirty check, and skip unnecessary committing - commit_message: "Run 'go mod tidy' via GitHub Actions" diff --git a/.github/workflows/dependabot-validate.yml b/.github/workflows/dependabot-validate.yml deleted file mode 100644 index b1387dc0bb2..00000000000 --- a/.github/workflows/dependabot-validate.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: dependabot validate - -on: - pull_request: - paths: - - '.github/dependabot.yml' - - '.github/workflows/dependabot-validate.yml' -jobs: - validate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: marocchino/validate-dependabot@v3 diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml deleted file mode 100644 index d800147a498..00000000000 --- a/.github/workflows/deploy-docs.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: deploy docs on gnolang/docs.gno.land repository -on: - push: - branches: - - master - paths: - - "docs/**" - -jobs: - trigger-netlify-docs-deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.DOCS_DEPLOY_PAT }} - script: | - await github.rest.actions.createWorkflowDispatch({ - owner: 'gnolang', - repo: 'docs.gno.land', - workflow_id: 'netlify.yml', - ref: 'main' - }) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index c9d9af0fb6f..00000000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: "docs / lint" - -on: - push: - paths: - - master - pull_request: - paths: - - "docs/**" - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - - name: Install dependencies - run: go mod download - - - name: Build docs - run: make -C docs/ build - - - name: Check diff - run: git diff --exit-code || (echo "Some docs files are not formatted, please run 'make build'." && exit 1) - - - name: Run linter - run: make -C docs/ lint diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 41d579c4567..00000000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,103 +0,0 @@ -name: examples - -on: - pull_request: - push: - branches: ["master"] - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - gno2go: - strategy: - fail-fast: false - matrix: - goversion: - - "1.22.x" - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.goversion }} - - run: go install -v ./gnovm/cmd/gno - - run: go run ./gnovm/cmd/gno transpile -v --gobuild ./examples - test: - strategy: - fail-fast: false - matrix: - goversion: - - "1.22.x" - # unittests: TODO: matrix with contracts - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.goversion }} - - name: Set environment variables for debug mode - if: env.ACTIONS_STEP_DEBUG == 'true' - run: | - export LOG_PATH_DIR=${{ runner.temp }}/logs - mkdir -p $LOG_PATH_DIR - 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 -v -print-runtime-metrics -print-events ./examples/... - lint: - strategy: - fail-fast: false - matrix: - goversion: - - "1.22.x" - # unittests: TODO: matrix with contracts - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.goversion }} - # testing official directories, basically examples/ minus examples/.../x/. - - 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"] - 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 - matrix: - go-version: ["1.22.x"] - # unittests: TODO: matrix with contracts - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - uses: actions/checkout@v4 - - run: | - GNO_CMD="$(pwd)/gnovm/cmd/gno" - # Find all directories containing gno.mod file - find ./examples -name "gno.mod" -execdir go run "$GNO_CMD" mod tidy \; - # Check if there are changes after running gno mod tidy - git diff --exit-code || (echo "Some gno.mod files are not tidy, please run 'make tidy'." && exit 1) diff --git a/.github/workflows/fossa.yml b/.github/workflows/fossa.yml deleted file mode 100644 index 41d9a2cba94..00000000000 --- a/.github/workflows/fossa.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Dependency License Scanning - -on: - workflow_dispatch: - -permissions: - contents: read - -jobs: - fossa: - name: Fossa - runs-on: ubuntu-latest - if: github.repository == 'gnolang/gno' - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - # we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves - fetch-depth: 0 - - - name: Move .fossa.yml to root dir - run: mv .github/.fossa.yml . - - - name: Cache Coursier cache - uses: coursier/cache-action@v6.4.6 - - - name: Set up JDK 17 - uses: coursier/setup-action@v1.3.9 - with: - jvm: temurin:1.17 - - - name: Set up fossa CLI - run: "curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash" - - - name: FOSSA analyze - run: fossa analyze - env: - FOSSA_API_KEY: "${{secrets.FOSSA_API_KEY}}" - - - name: FOSSA test - run: fossa test - env: - FOSSA_API_KEY: "${{secrets.FOSSA_API_KEY}}" diff --git a/.github/workflows/genesis-verify.yml b/.github/workflows/genesis-verify.yml deleted file mode 100644 index 1288d588100..00000000000 --- a/.github/workflows/genesis-verify.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: genesis-verify - -on: - pull_request: - branches: - - master - paths: - - "misc/deployments/**/genesis.json" - - ".github/workflows/genesis-verify.yml" - -jobs: - verify: - strategy: - fail-fast: false - matrix: - testnet: ["test5.gno.land"] - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v45 - with: - files: "misc/deployments/${{ matrix.testnet }}/genesis.json" - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: contribs/gnogenesis/go.mod - - - name: Build gnogenesis - run: make -C contribs/gnogenesis - - - name: Verify each genesis file - run: | - for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - echo "Verifying $file" - gnogenesis verify -genesis-path $file - done - - - name: Build gnoland - run: make -C gno.land install.gnoland - - - name: Running latest gnoland with each genesis file - run: | - for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - echo "Running gnoland with $file" - timeout 60s gnoland start -lazy --genesis $file || exit_code=$? - if [ $exit_code -eq 124 ]; then - echo "Gnoland genesis state generated successfully" - else - echo "Gnoland failed to start with $file" - exit 1 - fi - done diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 1b955b52cd0..8573ef89c8c 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -2,7 +2,7 @@ name: gh-pages on: - push: + pull_request: branches: [ "master" ] workflow_dispatch: @@ -25,11 +25,16 @@ jobs: with: go-version-file: go.mod - run: "cd misc/gendocs && make install gen" + - run: "cd misc/stdlib_diff && make install gen" + -run | # Combine files into a single directory for deployment + mkdir -p output/combined + cp -r ./misc/gendocs/godoc/* output/combined/ + cp -r ./misc/stdlib_diff/gnoreport/* output/combined/gnoreport - uses: actions/configure-pages@v5 id: pages - uses: actions/upload-pages-artifact@v3 with: - path: ./misc/gendocs/godoc + path: ./output/combined deploy: if: ${{ github.repository == 'gnolang/gno' }} # Alternatively, validate based on provided tokens and permissions. diff --git a/.github/workflows/gnofmt_template.yml b/.github/workflows/gnofmt_template.yml deleted file mode 100644 index 1ba66d0fbe3..00000000000 --- a/.github/workflows/gnofmt_template.yml +++ /dev/null @@ -1,24 +0,0 @@ -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 diff --git a/.github/workflows/gnoland.yml b/.github/workflows/gnoland.yml deleted file mode 100644 index 4817e2db0e3..00000000000 --- a/.github/workflows/gnoland.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: gno.land - -on: - push: - branches: - - master - workflow_dispatch: - pull_request: - -jobs: - main: - name: Run Main - uses: ./.github/workflows/main_template.yml - with: - modulepath: "gno.land" - tests-extra-args: "-coverpkg=github.com/gnolang/gno/gno.land/..." - secrets: - codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/gnovm.yml b/.github/workflows/gnovm.yml deleted file mode 100644 index 7e7586b23d9..00000000000 --- a/.github/workflows/gnovm.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: gnovm - -on: - push: - branches: - - master - workflow_dispatch: - pull_request: - -jobs: - main: - name: Run Main - uses: ./.github/workflows/main_template.yml - with: - 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" diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml deleted file mode 100644 index 06b2daa1d3d..00000000000 --- a/.github/workflows/labeler.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: "Pull Request Labeler" -on: -- pull_request_target - -jobs: - triage: - permissions: - contents: read - pull-requests: write - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/labeler@v5 diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml deleted file mode 100644 index 631f764c37f..00000000000 --- a/.github/workflows/lint-pr-title.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: "lint-pr-title" - -on: - pull_request_target: - types: - - opened - - edited - - synchronize - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - pr-title: - runs-on: ubuntu-latest - steps: - - uses: amannn/action-semantic-pull-request@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint_template.yml b/.github/workflows/lint_template.yml deleted file mode 100644 index b7568d19c41..00000000000 --- a/.github/workflows/lint_template.yml +++ /dev/null @@ -1,28 +0,0 @@ -on: - workflow_call: - inputs: - modulepath: - required: true - type: string - go-version: - required: true - type: string - - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ inputs.go-version }} - - name: Lint - uses: golangci/golangci-lint-action@v6 - with: - working-directory: ${{ inputs.modulepath }} - args: - --config=${{ github.workspace }}/.github/golangci.yml - version: v1.62 # sync with misc/devdeps diff --git a/.github/workflows/main_template.yml b/.github/workflows/main_template.yml deleted file mode 100644 index 5b3437b54a1..00000000000 --- a/.github/workflows/main_template.yml +++ /dev/null @@ -1,41 +0,0 @@ -on: - workflow_call: - inputs: - modulepath: - required: true - type: string - tests-extra-args: - required: false - type: string - secrets: - codecov-token: - required: true - -# TODO: environment variables cannot be sent to reusable workflows: https://docs.github.com/en/actions/using-workflows/reusing-workflows#limitations -# env: -# GO_VERSION: "1.22.x" - -jobs: - lint: - name: Go Linter - uses: ./.github/workflows/lint_template.yml - with: - modulepath: ${{ inputs.modulepath }} - go-version: "1.22.x" - build: - name: Go Build - uses: ./.github/workflows/build_template.yml - with: - modulepath: ${{ inputs.modulepath }} - go-version: "1.22.x" - test: - name: Go Test - uses: ./.github/workflows/test_template.yml - with: - modulepath: ${{ inputs.modulepath }} - tests-timeout: "30m" - go-version: "1.22.x" - tests-extra-args: ${{ inputs.tests-extra-args }} - secrets: - codecov-token: ${{ secrets.codecov-token }} - diff --git a/.github/workflows/misc.yml b/.github/workflows/misc.yml deleted file mode 100644 index ad2c886e2ac..00000000000 --- a/.github/workflows/misc.yml +++ /dev/null @@ -1,29 +0,0 @@ -# tests the "misc" directory & tools -# (not meant for miscellaneous workflows) -name: misc - -on: - push: - branches: - - master - workflow_dispatch: - pull_request: - -jobs: - main: - strategy: - fail-fast: false - matrix: - # fixed list because we have some non go programs on that misc folder - program: - - autocounterd - - genproto - - genstd - - goscan - - loop - name: Run Main - uses: ./.github/workflows/main_template.yml - with: - modulepath: misc/${{ matrix.program }} - secrets: - codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/mod-tidy.yml b/.github/workflows/mod-tidy.yml deleted file mode 100644 index 24eab553d19..00000000000 --- a/.github/workflows/mod-tidy.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Ensure go.mods are tidied - -on: - push: - branches: - - master - workflow_dispatch: - pull_request: - -jobs: - main: - name: Ensure go.mods are tidied - 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: Check go.mod files are up to date - working-directory: ${{ inputs.modulepath }} - run: | - make tidy VERIFY_MOD_SUMS=true diff --git a/.github/workflows/portal-loop.yml b/.github/workflows/portal-loop.yml deleted file mode 100644 index b898a149e9d..00000000000 --- a/.github/workflows/portal-loop.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: portal-loop - -on: - pull_request: - branches: - - master - push: - paths: - - "misc/loop/**" - - ".github/workflows/portal-loop.yml" - branches: - - "master" - # NOTE(albttx): branch name to simplify tests for this workflow - - "ci/portal-loop" - tags: - - "v*" - -permissions: - contents: read - packages: write - -jobs: - portal-loop: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Docker metadata portalloopd - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/${{ github.repository }}/portalloopd - tags: | - type=raw,value=latest - type=semver,pattern=v{{version}} - - - name: Build and push - uses: docker/build-push-action@v6 - with: - target: portalloopd - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - test-portal-loop-docker-compose: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - name: "Checkout" - uses: actions/checkout@v4 - - - name: "Setup The portal loop docker compose" - run: | - cd misc/loop - echo "Making docker compose happy" - touch .env - make docker.ci - - - name: "Test1 - Portal loop start gnoland" - run: | - while - block_height=$(curl -s localhost:26657/status | jq -r '.result.sync_info.latest_block_height') - echo "Current block height: $block_height" - [[ "$block_height" -lt 10 ]] - do - sleep 1 - done - - curl -s localhost:26657/status | jq - - - name: "Buid new gnolang/gno image" - run: | - docker build -t ghcr.io/gnolang/gno/gnoland:master -f Dockerfile --target gnoland . - - - name: "Wait for new docker image" - run: | - ip_addr=$(cat misc/loop/traefik/gno.yml | grep -o "http://.*:26657") - while - new_ip_addr=$(cat misc/loop/traefik/gno.yml | grep -o "http://.*:26657") - echo "${ip_addr} -> ${new_ip_addr}" - [[ "${ip_addr}" == ${new_ip_addr} ]] - do - sleep 5 - done - - - name: "Test2 - Wait portal-loop start new image" - run: | - while - block_height=$(curl -s localhost:26657/status | jq -r '.result.sync_info.latest_block_height') - echo "Current block height: $block_height" - [[ "$block_height" -lt 10 ]] - do - sleep 5 - done - docker ps -a - curl -s localhost:26657/status | jq diff --git a/.github/workflows/releaser-master.yml b/.github/workflows/releaser-master.yml deleted file mode 100644 index 3d194e2cb4c..00000000000 --- a/.github/workflows/releaser-master.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Trigger master build - -on: - push: - branches: - - "master" - workflow_dispatch: - -permissions: - contents: write # needed to write releases - id-token: write # needed for keyless signing - packages: write # needed for ghcr access - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Create a dummy tag to avoid goreleaser failure - run: git tag v0.0.0 master - - - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - cache: true - - - uses: sigstore/cosign-installer@v3.7.0 - - uses: anchore/sbom-action/download-syft@v0.17.8 - - - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - uses: goreleaser/goreleaser-action@v6 - with: - distribution: goreleaser-pro - version: ~> v2 - args: release --clean --nightly --config ./.github/goreleaser.yaml - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} - TAG_VERSION: master diff --git a/.github/workflows/releaser-nightly.yml b/.github/workflows/releaser-nightly.yml deleted file mode 100644 index 4308f1c4a7d..00000000000 --- a/.github/workflows/releaser-nightly.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Trigger nightly build - -on: - schedule: - - cron: "0 0 * * 2-6" - workflow_dispatch: - -permissions: - contents: write # needed to write releases - id-token: write # needed for keyless signing - packages: write # needed for ghcr access - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - cache: true - - - uses: sigstore/cosign-installer@v3.7.0 - - uses: anchore/sbom-action/download-syft@v0.17.8 - - - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - uses: goreleaser/goreleaser-action@v6 - with: - distribution: goreleaser-pro - version: ~> v2 - args: release --clean --nightly --snapshot --config ./.github/goreleaser.yaml - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} - TAG_VERSION: nightly diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml deleted file mode 100644 index 309664bdcce..00000000000 --- a/.github/workflows/releaser.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Go Releaser - -on: - push: - tags: - - "v*" - -permissions: - contents: write # needed to write releases - id-token: write # needed for keyless signing - packages: write # needed for ghcr access - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - cache: true - - - uses: sigstore/cosign-installer@v3.7.0 - - uses: anchore/sbom-action/download-syft@v0.17.8 - - - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - uses: goreleaser/goreleaser-action@v6 - with: - distribution: goreleaser-pro - version: ~> v2 - args: release --clean --config ./.github/goreleaser.yaml - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} diff --git a/.github/workflows/stale-bot.yml b/.github/workflows/stale-bot.yml deleted file mode 100644 index 55a17ac60a8..00000000000 --- a/.github/workflows/stale-bot.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: "Close stale PRs" -on: - schedule: - - cron: "30 1 * * *" -permissions: - pull-requests: write - issues: write - -jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v9 - with: - exempt-all-milestones: true - stale-pr-message: "This PR is stale because it has been open 3 months with no activity. Remove stale label or comment or this will be closed in 3 months." - close-pr-message: "This PR was closed because it has been stalled for 3 months with no activity." - days-before-pr-stale: 90 - days-before-pr-close: 90 - stale-issue-message: "This issue is stale because it has been open 6 months with no activity. Remove stale label or comment or this will be closed in 3 months." - close-issue-message: "This issue was closed because it has been stalled for 3 months with no activity." - days-before-issue-stale: 180 - days-before-issue-close: 90 diff --git a/.github/workflows/test_template.yml b/.github/workflows/test_template.yml deleted file mode 100644 index c7956b4caf4..00000000000 --- a/.github/workflows/test_template.yml +++ /dev/null @@ -1,84 +0,0 @@ -on: - workflow_call: - inputs: - modulepath: - required: true - type: string - tests-timeout: - required: true - type: string - go-version: - required: true - type: string - tests-extra-args: - required: false - type: string - secrets: - codecov-token: - required: true - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ inputs.go-version }} - - name: Go test - working-directory: ${{ inputs.modulepath }} - env: - TXTARCOVERDIR: /tmp/txtarcoverdir # txtar cover output - GOCOVERDIR: /tmp/gocoverdir # go cover output - COVERDIR: /tmp/coverdir # final output - run: | - set -x # print commands - - mkdir -p "$GOCOVERDIR" "$TXTARCOVERDIR" "$COVERDIR" - - # Craft a filter flag based on the module path to avoid expanding coverage on unrelated tags. - export filter="-pkg=github.com/gnolang/gno/${{ inputs.modulepath }}/..." - - # codecov only supports "boolean" coverage (whether a line is - # covered or not); so using -covermode=count or atomic would be - # pointless here. - # XXX: Simplify coverage of txtar - the current setup is a bit - # confusing and meticulous. There will be some improvements in Go - # 1.23 regarding coverage, so we can use this as a workaround until - # then. - go test -covermode=set -timeout ${{ inputs.tests-timeout }} ${{ inputs.tests-extra-args }} ./... -test.gocoverdir=$GOCOVERDIR - - # Print results - (set +x; echo 'go coverage results:') - go tool covdata percent $filter -i=$GOCOVERDIR - (set +x; echo 'txtar coverage results:') - go tool covdata percent $filter -i=$TXTARCOVERDIR - - # Generate final coverage output - go tool covdata textfmt -v 1 $filter -i=$GOCOVERDIR,$TXTARCOVERDIR -o gocoverage.out - - - name: Upload go coverage to Codecov - uses: codecov/codecov-action@v5 - with: - disable_search: true - fail_ci_if_error: true - files: ${{ inputs.modulepath }}/gocoverage.out - flags: ${{ inputs.modulepath }} - token: ${{ secrets.codecov-token }} - verbose: true # keep this enable as it help debugging when coverage fail randomly on the CI - - # TODO: We have to fix race conditions before running this job - # test-with-race: - # 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: Go race test - # run: go test -race -timeout ${{ inputs.tests-timeout }} ./... - # working-directory: ${{ inputs.modulepath }} diff --git a/.github/workflows/tm2.yml b/.github/workflows/tm2.yml deleted file mode 100644 index 57e84793c94..00000000000 --- a/.github/workflows/tm2.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: tm2 - -on: - push: - branches: - - master - workflow_dispatch: - pull_request: - -jobs: - main: - name: Run Main - uses: ./.github/workflows/main_template.yml - with: - modulepath: "tm2" - secrets: - codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/examples/gno.land/r/demo/users/z_13_filetest.gno b/examples/gno.land/r/demo/users/z_13_filetest.gno new file mode 100644 index 00000000000..b7f5caeffea --- /dev/null +++ b/examples/gno.land/r/demo/users/z_13_filetest.gno @@ -0,0 +1,23 @@ +package main + +// SEND: 200000000ugnot + +import ( + "strconv" + + "gno.land/r/demo/users" +) + +func main() { + { + // Verify pre-registered test1 user + names := users.ListUsersByPrefix("test1", 1) + println("# names: " + strconv.Itoa(len(names))) + println("name: " + names[0]) + } +} + +// Output: +// # names: 1 +// name: test1 + diff --git a/misc/stdlib_diff/README.md b/misc/stdlib_diff/README.md new file mode 100644 index 00000000000..32c3cbcd93d --- /dev/null +++ b/misc/stdlib_diff/README.md @@ -0,0 +1,30 @@ +# stdlibs_diff + +stdlibs_diff is a tool that generates an html report indicating differences between gno standard libraries and go standrad libraries + +## Usage + +Compare the `go` standard libraries the `gno` standard libraries + +```shell +./stdlibs_diff -src -dst -out +``` + +Compare the `gno` standard libraries the `go` standard libraries + +```shell +./stdlibs_diff -src -dst -out +``` + + +## Parameters + +| Flag | Description | Default value | +| ---------- | ------------------------------------------------------------------ | ------------- | +| src | Directory containing packages that will be compared to destination | None | +| dst | Directory containing packages; used to compare src packages | None | +| out | Directory where the report will be created | None | + +## Tips + +An index.html is generated at the root of the report location. Utilize it to navigate easily through the report. \ No newline at end of file diff --git a/misc/stdlib_diff/diffstatus.go b/misc/stdlib_diff/diffstatus.go new file mode 100644 index 00000000000..23829619f64 --- /dev/null +++ b/misc/stdlib_diff/diffstatus.go @@ -0,0 +1,25 @@ +package main + +type diffStatus uint + +const ( + missingInSrc diffStatus = iota + missingInDst + hasDiff + noDiff +) + +func (status diffStatus) String() string { + switch status { + case missingInSrc: + return "missing in src" + case missingInDst: + return "missing in dst" + case hasDiff: + return "files differ" + case noDiff: + return "files are equal" + default: + return "Unknown" + } +} diff --git a/misc/stdlib_diff/filediff.go b/misc/stdlib_diff/filediff.go new file mode 100644 index 00000000000..a097c9afcc9 --- /dev/null +++ b/misc/stdlib_diff/filediff.go @@ -0,0 +1,196 @@ +package main + +import ( + "fmt" + "os" + "strings" + + "github.com/hexops/gotextdiff" + "github.com/hexops/gotextdiff/myers" + "github.com/hexops/gotextdiff/span" +) + +// DiffChecker is a struct for comparing differences between two files. +type DiffChecker struct { + Src string // Name of the source file. + Dst string // Name of the destination file. + srcContent string // Content of the source file. + dstContent string // Content of the destination file. + srcLines []string // Lines of the source file. + dstLines []string // Lines of the destination file. +} + +// LineDifferrence represents a difference in a line during file comparison. +type LineDifferrence struct { + SrcLine string // The line on Src. + DestLine string // The line on Src. + SrcOperation operation // The operation performed on the line (e.g., "add", "delete", "equal"). + DestOperation operation + SrcNumber int + DestNumber int +} +type Diff struct { + Diffs []LineDifferrence + MissingSrc bool + MissingDst bool +} + +// NewDiffChecker creates a new DiffChecker instance for comparing differences between +// the specified source and destination files. It initializes the source and +// destination file lines . +func NewDiffChecker(srcPath, dstPath string) (*DiffChecker, error) { + src, err := getFileContent(srcPath) + if err != nil { + return nil, fmt.Errorf("can't read src file: %w", err) + } + + dst, err := getFileContent(dstPath) + if err != nil { + return nil, fmt.Errorf("can't read dst file: %w", err) + } + + return &DiffChecker{ + srcContent: src, + dstContent: dst, + srcLines: strings.Split(src, "\n"), + dstLines: strings.Split(dst, "\n"), + Src: srcPath, + Dst: dstPath, + }, nil +} + +// Differences returns the differences in lines between the source and +// destination files using the configured diff algorithm. +func (f *DiffChecker) Differences() *Diff { + var ( + srcIndex, dstIndex int + insertCount, deleteCount int + diff []LineDifferrence + ) + + if len(f.dstContent) == 0 { + return f.destEmpty() + } + + if len(f.srcContent) == 0 { + return f.srcEmpty() + } + + /* printUntil prints all the lines than do not appear on the computed edits from gotextdiff + so we need to add them manually looping always from the current value of + srcIndex until the line before the start of the hunk computed diff, hunk.FromLine-1 + + We need to print all the lines before each hunk and then ensure the end of the file is printed too + */ + printUntil := func(until int) { + for i := srcIndex; i < until; i++ { + diff = append(diff, LineDifferrence{ + SrcLine: f.srcLines[srcIndex], + DestLine: f.srcLines[srcIndex], + DestOperation: equal, + SrcOperation: equal, + SrcNumber: srcIndex + 1, + DestNumber: dstIndex + 1, + }) + + srcIndex++ + dstIndex++ + } + } + + edits := myers.ComputeEdits(span.URIFromPath(f.Src), f.srcContent, f.dstContent) + unified := gotextdiff.ToUnified(f.Src, f.Dst, f.srcContent, edits) + for _, hunk := range unified.Hunks { + printUntil(hunk.FromLine - 1) + + currentLine := LineDifferrence{} + for _, line := range hunk.Lines { + switch line.Kind { + case gotextdiff.Insert: + if currentLine.DestLine != "" { + diff = append(diff, currentLine) + currentLine = LineDifferrence{} + } + + insertCount++ + dstIndex++ + + currentLine.DestLine = line.Content + currentLine.DestOperation = insert + currentLine.DestNumber = dstIndex + + case gotextdiff.Equal: + if currentLine.DestLine != "" || currentLine.SrcLine != "" { + diff = append(diff, currentLine) + currentLine = LineDifferrence{} + } + + srcIndex++ + dstIndex++ + + currentLine = LineDifferrence{ + SrcLine: line.Content, + DestLine: line.Content, + DestOperation: equal, + SrcOperation: equal, + SrcNumber: srcIndex, + DestNumber: dstIndex, + } + + case gotextdiff.Delete: + if currentLine.SrcLine != "" { + diff = append(diff, currentLine) + currentLine = LineDifferrence{} + } + srcIndex++ + deleteCount++ + currentLine.SrcLine = line.Content + currentLine.SrcOperation = delete + currentLine.SrcNumber = srcIndex + } + } + diff = append(diff, currentLine) + } + + printUntil(len(f.srcLines)) + + return &Diff{ + Diffs: diff, + } +} + +func (f *DiffChecker) destEmpty() *Diff { + diffs := []LineDifferrence{} + for index, line := range f.srcLines { + diffs = append(diffs, LineDifferrence{SrcLine: line, SrcOperation: delete, SrcNumber: index + 1}) + } + + return &Diff{ + Diffs: diffs, + MissingDst: true, + } +} + +func (f *DiffChecker) srcEmpty() *Diff { + diffs := []LineDifferrence{} + for index, line := range f.dstLines { + diffs = append(diffs, LineDifferrence{DestLine: line, DestOperation: insert, DestNumber: index + 1}) + } + + return &Diff{ + Diffs: diffs, + MissingSrc: true, + } +} + +// getFileContent reads and returns the lines of a file given its path. +func getFileContent(p string) (string, error) { + data, err := os.ReadFile(p) + if err != nil { + if os.IsNotExist(err) { + return "", nil + } + return "", err + } + return strings.ReplaceAll(string(data), "\t", " "), nil +} diff --git a/misc/stdlib_diff/go.mod b/misc/stdlib_diff/go.mod new file mode 100644 index 00000000000..4e200f56ebb --- /dev/null +++ b/misc/stdlib_diff/go.mod @@ -0,0 +1,5 @@ +module github.com/gnolang/gno/misc/stdlib_diff + +go 1.21.0 + +require github.com/hexops/gotextdiff v1.0.3 diff --git a/misc/stdlib_diff/go.sum b/misc/stdlib_diff/go.sum new file mode 100644 index 00000000000..e71200ae5ce --- /dev/null +++ b/misc/stdlib_diff/go.sum @@ -0,0 +1,2 @@ +github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= +github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= diff --git a/misc/stdlib_diff/main.go b/misc/stdlib_diff/main.go new file mode 100644 index 00000000000..0b29abd18fd --- /dev/null +++ b/misc/stdlib_diff/main.go @@ -0,0 +1,28 @@ +package main + +import ( + "flag" + "log" +) + +func main() { + var srcPath string + var dstPath string + var outDirectory string + + flag.StringVar(&srcPath, "src", "", "Directory containing packages that will be compared to destination") + flag.StringVar(&dstPath, "dst", "", "Directory containing packages; used to compare src packages") + flag.StringVar(&outDirectory, "out", "", "Directory where the report will be created") + flag.Parse() + + reportBuilder, err := NewReportBuilder(srcPath, dstPath, outDirectory) + if err != nil { + log.Fatal("can't build report builder: ", err.Error()) + } + + log.Println("Building report...") + if err := reportBuilder.Build(); err != nil { + log.Fatalln("can't build report: ", err.Error()) + } + log.Println("Report generation done!") +} diff --git a/misc/stdlib_diff/operation.go b/misc/stdlib_diff/operation.go new file mode 100644 index 00000000000..5ebc632a90e --- /dev/null +++ b/misc/stdlib_diff/operation.go @@ -0,0 +1,28 @@ +package main + +// operation is an enumeration type representing different types of operations. Used in diff algorithm +// to indicates differences between files. +type operation uint + +const ( + // insert represents an insertion operation. + insert operation = iota + 1 + // delete represents a deletion operation. + delete + // equal represents an equal operation. + equal +) + +// String returns a string representation of the operation. +func (op operation) String() string { + switch op { + case insert: + return "INS" + case delete: + return "DEL" + case equal: + return "EQ" + default: + return "UNKNOWN" + } +} diff --git a/misc/stdlib_diff/packagediff.go b/misc/stdlib_diff/packagediff.go new file mode 100644 index 00000000000..f99578874b5 --- /dev/null +++ b/misc/stdlib_diff/packagediff.go @@ -0,0 +1,177 @@ +package main + +import ( + "os" + "path/filepath" + "strings" +) + +// PackageDiffChecker is a struct for comparing and identifying differences +// between files in two directories. +type PackageDiffChecker struct { + SrcFiles []string // List of source files. + SrcPath string // Source directory path. + DstFiles []string // List of destination files. + DstPath string // Destination directory path. +} + +// Differences represents the differences between source and destination packages. +type Differences struct { + SameNumberOfFiles bool // Indicates whether the source and destination have the same number of files. + FilesDifferences []FileDifference // Differences in individual files. +} + +// FileDifference represents the differences between source and destination files. +type FileDifference struct { + Status string // Diff status of the processed files. + SourceName string // Name of the source file. + DestinationName string // Name of the destination file. + LineDiffferrences []LineDifferrence // Differences in source file lines. +} + +// NewPackageDiffChecker creates a new PackageDiffChecker instance with the specified +// source and destination paths. It initializes the SrcFiles and DstFiles fields by +// listing files in the corresponding directories. +func NewPackageDiffChecker(srcPath, dstPath string) (*PackageDiffChecker, error) { + srcFiles, err := listDirFiles(srcPath) + if err != nil { + return nil, err + } + + dstFiles, err := listDirFiles(dstPath) + if err != nil { + return nil, err + } + + return &PackageDiffChecker{ + SrcFiles: srcFiles, + SrcPath: srcPath, + DstFiles: dstFiles, + DstPath: dstPath, + }, nil +} + +// Differences calculates and returns the differences between source and destination +// packages. It compares files line by line using the Myers algorithm. +func (p *PackageDiffChecker) Differences() (*Differences, error) { + d := &Differences{ + SameNumberOfFiles: p.hasSameNumberOfFiles(), + FilesDifferences: make([]FileDifference, 0), + } + + srcFilesExt, dstFileExt := p.inferFileExtensions() + allFiles := p.listAllPossibleFiles() + + for _, trimmedFileName := range allFiles { + srcFileName := trimmedFileName + srcFilesExt + srcFilePath := p.SrcPath + "/" + srcFileName + dstFileName := trimmedFileName + dstFileExt + dstFilePath := p.DstPath + "/" + dstFileName + + diffChecker, err := NewDiffChecker(srcFilePath, dstFilePath) + if err != nil { + return nil, err + } + + diff := diffChecker.Differences() + + d.FilesDifferences = append(d.FilesDifferences, FileDifference{ + Status: p.getStatus(diff).String(), + SourceName: srcFileName, + DestinationName: dstFileName, + LineDiffferrences: diff.Diffs, + }) + } + + return d, nil +} + +// listAllPossibleFiles returns a list of unique file names without extensions +// from both source and destination directories. +func (p *PackageDiffChecker) listAllPossibleFiles() []string { + files := p.SrcFiles + files = append(files, p.DstFiles...) + + for i := 0; i < len(files); i++ { + files[i] = strings.TrimSuffix(files[i], ".go") + files[i] = strings.TrimSuffix(files[i], ".gno") + } + + unique := make(map[string]bool, len(files)) + uniqueFiles := make([]string, len(unique)) + for _, file := range files { + if len(file) != 0 { + if !unique[file] { + uniqueFiles = append(uniqueFiles, file) + unique[file] = true + } + } + } + + return uniqueFiles +} + +// inferFileExtensions by returning the src and dst files extensions. +func (p *PackageDiffChecker) inferFileExtensions() (string, string) { + var goFiles, gnoFiles int + for _, file := range p.SrcFiles { + switch filepath.Ext(file) { + case ".go": + goFiles++ + case ".gno": + gnoFiles++ + } + } + if goFiles > gnoFiles { + return ".go", ".gno" + } + + return ".gno", ".go" +} + +// getStatus determines the diff status based on the differences in source and destination. +// It returns a diffStatus indicating whether there is no difference, missing in source, missing in destination, or differences exist. +func (p *PackageDiffChecker) getStatus(diff *Diff) diffStatus { + if diff.MissingSrc { + return missingInSrc + } + + if diff.MissingDst { + return missingInDst + } + + for _, diff := range diff.Diffs { + if diff.SrcOperation == delete || diff.DestOperation == insert { + return hasDiff + } + } + + return noDiff +} + +// hasSameNumberOfFiles checks if the source and destination have the same number of files. +func (p *PackageDiffChecker) hasSameNumberOfFiles() bool { + return len(p.SrcFiles) == len(p.DstFiles) +} + +// listDirFiles returns a list of file names in the specified directory. +func listDirFiles(dirPath string) ([]string, error) { + fileNames := make([]string, 0) + dirEntries, err := os.ReadDir(dirPath) + if err != nil && !os.IsNotExist(err) { + return nil, err + } + + for _, dirEntry := range dirEntries { + if dirEntry.IsDir() { + continue + } + // Only list .go and .gno files + if !strings.Contains(dirEntry.Name(), ".go") && !strings.Contains(dirEntry.Name(), ".gno") { + continue + } + fileNames = append(fileNames, dirEntry.Name()) + } + + return fileNames, nil +} diff --git a/misc/stdlib_diff/report.go b/misc/stdlib_diff/report.go new file mode 100644 index 00000000000..6ad9d002d53 --- /dev/null +++ b/misc/stdlib_diff/report.go @@ -0,0 +1,314 @@ +package main + +import ( + "bytes" + _ "embed" + "errors" + "fmt" + "html/template" + "io/fs" + "os" + "path/filepath" + "slices" + "strings" +) + +var ( + //go:embed templates/package_diff_template.html + packageDiffTemplate string + //go:embed templates/index_template.html + indexTemplate string +) + +// ReportBuilder is a struct for building reports based on the differences +// between source and destination directories. +type ReportBuilder struct { + SrcPath string // Source directory path. + DstPath string // Destination directory path. + OutDir string // Output directory path for the reports. + packageTemplate *template.Template // Template for generating reports. + indexTemplate *template.Template // Template for generating index file of the reports. +} + +// PackageDiffTemplateData represents the template data structure for a package's +// differences between source and destination directories. +type PackageDiffTemplateData struct { + PackageName string // Package name. + SrcFilesCount int // Number of files in the source package. + SrcPackageLocation string // Location of source files in the source directory. + DstFileCount int // Number of destination files in the package. + DstPackageLocation string // Location of destination files in the destination directory. + FilesDifferences []FileDifference // Differences in individual files. +} + +type IndexTemplate struct { + Reports []LinkToReport +} + +type LinkToReport struct { + PathToReport string + PackageName string + MissingGo bool + MissingGno bool + Subdirectories []LinkToReport +} + +// NewReportBuilder creates a new ReportBuilder instance with the specified +// source path, destination path, and output directory. It also initializes +// the packageTemplate using the provided HTML template file. +func NewReportBuilder(srcPath, dstPath, outDir string) (*ReportBuilder, error) { + packageTemplate, err := template.New("").Parse(packageDiffTemplate) + if err != nil { + return nil, err + } + + indexTemplate, err := template.New("").Parse(indexTemplate) + if err != nil { + return nil, err + } + + //filepath.EvalSymlinks will return the original path if there are no simlinks associated to the given path + realSrcPath, err := filepath.EvalSymlinks(srcPath) + if err != nil { + return nil, err + } + + realDstPath, err := filepath.EvalSymlinks(dstPath) + if err != nil { + return nil, err + } + + realOutPath, err := filepath.EvalSymlinks(outDir) + if err != nil { + if !errors.Is(err, fs.ErrNotExist) { + return nil, err + } + // Create output if not exist + err = os.MkdirAll(outDir, 0777) + if err != nil { + return nil, err + } + realOutPath = outDir + } + return &ReportBuilder{ + // Trim suffix / in order to standardize paths accept path with or without `/` + SrcPath: strings.TrimSuffix(realSrcPath, `/`), + DstPath: strings.TrimSuffix(realDstPath, `/`), + OutDir: strings.TrimSuffix(realOutPath, `/`), + packageTemplate: packageTemplate, + indexTemplate: indexTemplate, + }, nil +} + +// Build generates reports for differences between packages in the source and +// destination directories. It iterates through each directory, calculates +// differences using PackageDiffChecker, and generates reports using the +// packageTemplate. +func (builder *ReportBuilder) Build() error { + directories, err := builder.listDirectories() + if err != nil { + return err + } + + indexTemplateData := &IndexTemplate{ + Reports: make([]LinkToReport, 0), + } + + for _, directory := range directories { + if err := builder.ExecuteDiffTemplate(directory); err != nil { + return err + } + report := LinkToReport{ + PathToReport: "./" + directory.Path + "/report.html", + PackageName: directory.Path, + MissingGno: !directory.FoundInDest, + MissingGo: !directory.FoundInSrc, + Subdirectories: make([]LinkToReport, 0), + } + for _, subDirectory := range directory.Children { + if err := builder.ExecuteDiffTemplate(subDirectory); err != nil { + return err + } + report.Subdirectories = append(report.Subdirectories, LinkToReport{ + PathToReport: "./" + subDirectory.Path + "/report.html", + PackageName: subDirectory.Path, + MissingGno: !subDirectory.FoundInDest, + MissingGo: !subDirectory.FoundInSrc, + }) + + } + indexTemplateData.Reports = append(indexTemplateData.Reports, report) + + } + + if err := builder.writeIndexTemplate(indexTemplateData); err != nil { + return err + } + + return nil +} + +func (builder *ReportBuilder) ExecuteDiffTemplate(directory *Directory) error { + if !directory.FoundInDest { + return nil + } + + srcPackagePath := builder.SrcPath + "/" + directory.Path + dstPackagePath := builder.DstPath + "/" + directory.Path + packageChecker, err := NewPackageDiffChecker(srcPackagePath, dstPackagePath) + if err != nil { + return fmt.Errorf("can't create new PackageDiffChecker: %w", err) + } + + differences, err := packageChecker.Differences() + if err != nil { + return fmt.Errorf("can't compute differences: %w", err) + } + + data := &PackageDiffTemplateData{ + PackageName: directory.Path, + SrcFilesCount: len(packageChecker.SrcFiles), + SrcPackageLocation: srcPackagePath, + DstFileCount: len(packageChecker.DstFiles), + DstPackageLocation: dstPackagePath, + FilesDifferences: differences.FilesDifferences, + } + + return builder.writePackageTemplate(data, directory.Path) +} + +type Directory struct { + Path string + FoundInDest bool + FoundInSrc bool + Children []*Directory +} + +// listDirectories retrieves a list of directories in the source path. +func (builder *ReportBuilder) listDirectories() ([]*Directory, error) { + allSubdirectories, srcDirectories, destDirectories, err := builder.findDirectories() + + if err != nil { + return nil, err + } + + notfound := []string{} + directories := make(map[string]*Directory) + res := make([]*Directory, 0) + + for _, folderName := range allSubdirectories { + if slices.ContainsFunc(notfound, func(s string) bool { + return strings.HasPrefix(folderName, s) + }) { + // this directory is not found in either source or destination skipping subsdirectories + continue + } + + newDir := &Directory{ + Path: folderName, + FoundInDest: destDirectories[folderName], + FoundInSrc: srcDirectories[folderName], + Children: make([]*Directory, 0), + } + + if isRootFolder(folderName) { + directories[folderName] = newDir + res = append(res, newDir) + } else { + directory := directories[getRootFolder(folderName)] + directory.Children = append(directory.Children, newDir) + directories[getRootFolder(folderName)] = directory + } + + if !newDir.FoundInDest && !newDir.FoundInSrc { + notfound = append(notfound, folderName) + } + } + + return res, err +} +func isRootFolder(path string) bool { + return !strings.Contains(path, "/") +} +func getRootFolder(path string) string { + return strings.Split(path, "/")[0] +} +func (builder *ReportBuilder) getAllSubdirectories(rootPath string) ([]string, error) { + directories := make([]string, 0) + err := filepath.WalkDir(rootPath, func(path string, dirEntry fs.DirEntry, err error) error { + if path == rootPath { + return nil + } + + if dirEntry.IsDir() { + folderName := strings.TrimPrefix(path, rootPath+"/") + directories = append(directories, folderName) + } + return nil + }) + return directories, err +} + +// writeIndexTemplate generates and writes the index template with the given output paths. +func (builder *ReportBuilder) writeIndexTemplate(data *IndexTemplate) error { + resolvedTemplate := new(bytes.Buffer) + if err := builder.indexTemplate.Execute(resolvedTemplate, data); err != nil { + return err + } + + if err := os.WriteFile(builder.OutDir+"/index.html", resolvedTemplate.Bytes(), 0644); err != nil { + return err + } + + return nil +} + +// writePackageTemplate executes the template with the provided data and +// writes the generated report to the output directory. +func (builder *ReportBuilder) writePackageTemplate(templateData any, packageName string) error { + resolvedTemplate := new(bytes.Buffer) + if err := builder.packageTemplate.Execute(resolvedTemplate, templateData); err != nil { + return err + } + + if err := os.MkdirAll(builder.OutDir+"/"+packageName, 0777); err != nil { + return err + } + + if err := os.WriteFile(builder.OutDir+"/"+packageName+"/report.html", resolvedTemplate.Bytes(), 0644); err != nil { + return err + } + + return nil +} + +func (builder *ReportBuilder) findDirectories() ([]string, map[string]bool, map[string]bool, error) { + destDirectories, err := builder.getAllSubdirectories(builder.DstPath) + if err != nil { + return nil, nil, nil, err + } + + srcDirectories, err := builder.getAllSubdirectories(builder.SrcPath) + if err != nil { + return nil, nil, nil, err + } + + res := make([]string, 0, len(srcDirectories)+len(destDirectories)) + srcMap := make(map[string]bool) + dstMap := make(map[string]bool) + for _, path := range srcDirectories { + res = append(res, path) + srcMap[path] = true + } + + for _, path := range destDirectories { + dstMap[path] = true + if !srcMap[path] { + res = append(res, path) + } + } + + slices.Sort(res) + + return res, srcMap, dstMap, nil +} diff --git a/misc/stdlib_diff/templates/index_template.html b/misc/stdlib_diff/templates/index_template.html new file mode 100644 index 00000000000..9d7d687b5ab --- /dev/null +++ b/misc/stdlib_diff/templates/index_template.html @@ -0,0 +1,83 @@ + + + + + + Index + + + +

List of packages processed

+
    + {{- range .Reports}} + {{- if .MissingGno}} +
  • {{.PackageName}}

    : missing in gno + {{- else if .MissingGo}} +
  • {{.PackageName}}

    : missing in go + {{- else}} + {{if .Subdirectories}} +
    + {{.PackageName}} + + {{- range .Subdirectories}} + {{- if .MissingGno}} +
      +
    • {{.PackageName}}

      : missing in gno
    • +
    + {{- else if .MissingGo}} +
      +
    • {{.PackageName}}

      : missing in go
    • +
    + {{- else}} + + {{- end}} + {{- end}} +
    + {{- else}} + {{.PackageName}}
    + {{- end}} + {{- end}} +
  • + {{- end}} +
+ + \ No newline at end of file diff --git a/misc/stdlib_diff/templates/package_diff_template.html b/misc/stdlib_diff/templates/package_diff_template.html new file mode 100644 index 00000000000..f7b0d90a03b --- /dev/null +++ b/misc/stdlib_diff/templates/package_diff_template.html @@ -0,0 +1,132 @@ +{{define "file-viewer" }} +{{if ne .Status "missing in src"}} +
+
+ {{- range .LineDiffferrences}} + {{- if eq .SrcOperation 2}} +
+ {{.SrcNumber}}

{{.SrcLine}}

+
+ + {{- else if eq .SrcOperation 3}} +
+ {{.SrcNumber}} +

{{.SrcLine}}

+
+ {{- else}} +
+

+
+ {{- end}} + {{- end}} +
+
+{{end}} + {{if ne .Status "missing in dst"}} +
+
+ {{- range .LineDiffferrences}} + {{- if eq .DestOperation 1}} +
+ {{.DestNumber}}

{{.DestLine}}

+
+ {{- else if eq .DestOperation 3}} +
+ {{.DestNumber}} +

{{.DestLine}}

+
+ {{- else}} +

+ {{- end}} + {{- end}} +
+
+ {{end}} +{{end}} + + + + + + + {{ .PackageName }} + + + + +

{{ .PackageName }} package differences

+ +

Package information

+ +

Sources location

+
    +
  • SRC: {{.SrcPackageLocation}}
  • +
  • DST: {{.DstPackageLocation}}
  • +
+ +

Number of files

+
    +
  • SRC: {{.SrcFilesCount}}
  • +
  • DST: {{.DstFileCount}}
  • +
+ + {{- range .FilesDifferences}} + {{- if eq .Status "files differ"}} +
+ {{.SourceName}} ({{.Status}}) + {{- else if eq .Status "missing in dst"}} +
+ {{.SourceName}} ({{.Status}}) ➖ + {{- else if eq .Status "missing in src"}} +
+ {{.SourceName}} ({{.Status}}) ➕ + {{- else}} +
+ {{.SourceName}} ({{.Status}}) + {{- end}} +
+ {{template "file-viewer" .}} +
+
+ {{- end}} + + \ No newline at end of file