feat: add CI/CD workflows for improved automation

This commit is contained in:
Prad Nukala 2025-01-06 14:28:43 -05:00
parent 609198b86c
commit 567d38190f
28 changed files with 763 additions and 118 deletions

238
.github/scopes.json vendored Normal file
View File

@ -0,0 +1,238 @@
{
"scopes": ["controller", "frontend", "ci-cd", "dev-ops"],
"next-milestone": "1",
"docs": [
{
"keywords": ["github", "actions", "workflows", "syntax"],
"url": "https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions"
},
{
"keywords": ["cosmos", "tooling", "cosmovisor"],
"url": "https://docs.cosmos.network/v0.50/build/tooling/cosmovisor"
},
{
"keywords": ["process-compose", "configuration"],
"url": "https://f1bonacc1.github.io/process-compose/configuration/"
},
{
"keywords": ["taskfile", "cli", "reference"],
"url": "https://taskfile.dev/reference/cli"
},
{
"keywords": [],
"url": "https://taskfile.dev/reference/schema"
},
{
"keywords": ["taskfile", "templating", "reference"],
"url": "https://taskfile.dev/reference/templating/"
},
{
"keywords": ["mkdocs", "material", "reference"],
"url": "https://squidfunk.github.io/mkdocs-material/reference/"
},
{
"keywords": ["pkl", "language", "reference"],
"url": "https://pkl-lang.org/main/current/language-reference/index.html"
},
{
"keywords": ["pwa", "service-workers", "web"],
"url": "https://web.dev/learn/pwa/service-workers/"
},
{
"keywords": ["service-workers", "web", "api"],
"url": "https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API"
},
{
"keywords": ["web-authentication", "web", "api"],
"url": "https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API"
},
{
"keywords": ["sdk", "modules", "cosmos", "manager"],
"url": "https://docs.cosmos.network/v0.50/build/building-modules/module-manager"
},
{
"keywords": ["sdk", "modules", "cosmos", "messages", "queries"],
"url": "https://docs.cosmos.network/v0.50/build/building-modules/messages-and-queries"
},
{
"keywords": ["sdk", "modules", "messages", "service", "cosmos"],
"url": "https://docs.cosmos.network/v0.50/build/building-modules/msg-services"
},
{
"keywords": ["sdk", "modules", "services", "cosmos", "query"],
"url": "https://docs.cosmos.network/v0.50/build/building-modules/query-services"
},
{
"keywords": ["cosmos", "depinject", "modules", "sdk"],
"url": "https://docs.cosmos.network/v0.50/build/building-modules/depinject"
},
{
"keywords": ["ibc", "apps", "sdk", "interchain-accounts"],
"url": "https://ibc.cosmos.network/v8/apps/interchain-accounts/overview/"
},
{
"keywords": ["ibc", "apps", "sdk", "transfer"],
"url": "https://ibc.cosmos.network/v8/apps/transfer/overview/"
},
{
"keywords": ["osmosis", "modules", "ibc", "assets"],
"url": "https://docs.osmosis.zone/osmosis-core/asset-info/"
},
{
"keywords": ["ibc", "osmosis", "tokenfactory", "modules", "assets"],
"url": "https://docs.osmosis.zone/osmosis-core/modules/tokenfactory"
},
{
"keywords": ["ibc", "mint", "cctp", "noble", "assets"],
"url": "https://docs.noble.xyz/cctp/mint"
},
{
"keywords": ["ibc", "relayer", "nomic", "assets"],
"url": "https://docs.nomic.io/network/ibc-relayer"
},
{
"keywords": ["ibc", "cctp", "noble", "mint_forward", "assets"],
"url": "https://docs.noble.xyz/cctp/mint_forward"
},
{
"keywords": ["evmos", "erc20", "assets"],
"url": "https://docs.evmos.org/protocol/modules/erc20"
},
{
"keywords": ["nomic", "nbtc", "assets"],
"url": "https://docs.nomic.io/nbtc"
},
{
"keywords": ["mpc", "wallet", "cryptography", "capability", "invokation"],
"url": "https://csrc.nist.gov/CSRC/media/Events/NTCW19/papers/paper-DKLS.pdf"
},
{
"keywords": ["ucan", "spec", "cryptography", "authorization"],
"url": "https://raw.githubusercontent.com/ucan-wg/spec/refs/heads/main/README.md"
},
{
"keywords": ["zero-knowledge", "proofs", "cryptography", "privacy"],
"url": "https://eprint.iacr.org/2021/1672.pdf"
},
{
"keywords": ["gateway", "http", "sse"],
"url": "https://echo.labstack.com/docs/cookbook/sse"
},
{
"keywords": ["gateway", "http", "websocket"],
"url": "https://echo.labstack.com/docs/cookbook/websocket"
},
{
"keywords": ["gateway", "http", "subdomain"],
"url": "https://echo.labstack.com/docs/cookbook/subdomain"
},
{
"keywords": ["tigerbeetle", "models", "oracle"],
"url": "https://docs.tigerbeetle.com/coding/data-modeling"
},
{
"keywords": ["tigerbeetle", "two=phase", "transfers", "oracle"],
"url": "https://docs.tigerbeetle.com/coding/two-phase-transfers"
},
{
"keywords": [
"tigerbeetle",
"oracle",
"reliable",
"transaction",
"submission"
],
"url": "https://docs.tigerbeetle.com/coding/reliable-transaction-submission"
},
{
"keywords": ["currency", "exchange", "tigerbeetle", "oracle"],
"url": "https://docs.tigerbeetle.com/coding/recipes/currency-exchange"
},
{
"keywords": [
"balance",
"tigerbeetle",
"oracle",
"conditional",
"transfers"
],
"url": "https://docs.tigerbeetle.com/coding/recipes/balance-conditional-transfers"
},
{
"keywords": ["tigerbeetle", "account", "oracle"],
"url": "https://docs.tigerbeetle.com/reference/account"
},
{
"keywords": ["tigerbeetle", "transfer", "oracle"],
"url": "https://docs.tigerbeetle.com/reference/transfer"
},
{
"keywords": ["substreams", "packages", "consumer", "oracle"],
"url": "https://docs.substreams.dev/documentation/consume/packages"
},
{
"keywords": ["substreams", "deploy", "service", "oracle"],
"url": "https://docs.substreams.dev/documentation/consume/sql/deployable-services/local-service"
},
{
"keywords": ["substreams", "tutorial", "cosmos", "injective"],
"url": "https://docs.substreams.dev/tutorials/cosmos/injective/foundational"
},
{
"keywords": ["worker", "http", "jwt"],
"url": "https://echo.labstack.com/docs/cookbook/jwt"
},
{
"keywords": ["worker", "http", "secure"],
"url": "https://echo.labstack.com/docs/middleware/secure"
},
{
"keywords": ["worker", "http", "service-workers", "web", "api"],
"url": "https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API"
},
{
"keywords": ["synapse", "matrix", "configuration", "usage"],
"url": "https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html"
},
{
"keywords": ["cosmos", "protobuf", "orm", "sdk"],
"url": "https://docs.cosmos.network/v0.50/build/packages/orm"
},
{
"keywords": ["cosmos", "sdk", "modules", "auth"],
"url": "https://docs.cosmos.network/v0.50/build/modules/auth"
},
{
"keywords": ["cosmos", "sdk", "modules", "bank"],
"url": "https://docs.cosmos.network/v0.50/build/modules/bank"
},
{
"keywords": ["cosmos", "modules", "authz", "sdk"],
"url": "https://docs.cosmos.network/v0.50/build/modules/authz"
},
{
"keywords": ["cosmos", "protobuf", "collections", "sdk"],
"url": "https://docs.cosmos.network/v0.50/build/packages/collections"
},
{
"keywords": ["cosmos", "modules", "gov", "sdk"],
"url": "https://docs.cosmos.network/v0.50/build/modules/gov"
},
{
"keywords": ["cosmos", "modules", "staking", "sdk"],
"url": "https://docs.cosmos.network/v0.50/build/modules/staking"
},
{
"keywords": ["cosmos", "protobuf", "annotations", "sdk"],
"url": "https://docs.cosmos.network/v0.50/build/building-modules/protobuf-annotations"
},
{
"keywords": ["cosmos", "sdk", "modules", "group"],
"url": "https://docs.cosmos.network/v0.50/build/modules/group"
},
{
"keywords": ["cosmos", "sdk", "modules", "nft"],
"url": "https://docs.cosmos.network/v0.50/build/modules/nft"
}
]
}

138
.github/workflows/check-pr.yml vendored Normal file
View File

@ -0,0 +1,138 @@
name: Check PR
on:
pull_request:
merge_group:
permissions:
contents: read # for TimonVS/pr-labeler-action to read config file
pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR
jobs:
verify-pr:
name: Test Lints
if: github.event_name == 'pull_request'
permissions:
contents: read # for TimonVS/pr-labeler-action to read config file
pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required to fetch all history for merging
- uses: TimonVS/pr-labeler-action@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value
- name: Trunk Check
uses: trunk-io/trunk-action@v1
test-builds:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: Test Builds
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- name: Run Sonrd Build
run: make build
test-unit:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: Test Unit
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- run: make test-unit
test-race:
runs-on: ubuntu-latest
if: github.event_name == 'merge_group'
name: Test Race
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- run: make test-race
test-cover:
runs-on: ubuntu-latest
if: github.event_name == 'merge_group'
name: Test Coverage
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- run: make test-cover
validate-release:
if: github.event_name == 'merge_group' || github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: Test Release
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- name: Commitizen Dry Run
uses: commitizen-tools/commitizen-action@master
with:
push: false
dry_run: true
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
- name: Check GoReleaser Config
run: make release-check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: GoReleaser Dry Run
run: make release-dry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

66
.github/workflows/new-release.yml vendored Normal file
View File

@ -0,0 +1,66 @@
name: New Release
on:
release:
types: [published]
permissions:
contents: write
issues: write
jobs:
buf_push:
name: Publish Protobufs
runs-on: ubuntu-latest
steps:
# Run `git checkout`
- uses: actions/checkout@v4
# Install the `buf` CLI
- uses: bufbuild/buf-setup-action@v1
# Push only the Input in `proto` to the BSR
- uses: bufbuild/buf-push-action@v1
continue-on-error: true
with:
input: proto
buf_token: ${{ secrets.BUF_TOKEN }}
container-push:
name: Publish Docker Images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/onsonr/sonr:latest
docs-push:
runs-on: ubuntu-latest
name: Publish Tech Docs
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force

51
.github/workflows/new-tag.yml vendored Normal file
View File

@ -0,0 +1,51 @@
name: New Tag
on:
pull_request:
types: [closed]
push:
tags:
- v*
branches:
- main
permissions:
contents: write
jobs:
new-release:
name: Create Release
if: startsWith(github.ref, 'refs/tags/')
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Run GoReleaser
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
GITHUB_PERSONAL_AUTH_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
REDDIT_APP_ID: ${{ secrets.REDDIT_APP_ID }}
REDDIT_SECRET: ${{ secrets.REDDIT_SECRET }}
REDDIT_USERNAME: ${{ secrets.REDDIT_USERNAME }}
REDDIT_PASSWORD: ${{ secrets.REDDIT_PASSWORD }}

33
.github/workflows/post-merge.yml vendored Normal file
View File

@ -0,0 +1,33 @@
name: Post Merge
on:
pull_request:
types: [closed]
permissions:
contents: write
issues: write
jobs:
bump-version:
name: Version Bump
if: |
github.event.pull_request.merged == true &&
github.event.pull_request.user.login != 'dependabot[bot]' &&
github.event.pull_request.user.login != 'dependabot-preview[bot]'
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: "${{ secrets.COMMIT_KEY }}"
- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
with:
push: false
increment: patch
- name: Push using ssh
run: |
git push origin main --tags

114
.gitignore vendored
View File

@ -4,3 +4,117 @@
.idea .idea
bin bin
tmp tmp
dist
# Aider related generated files
.aider-context
# Binaries
.task
no
.data
schemas
*.db
tools-stamp
*.exe
*.exe~
*.dll
*.so
*.dylib
*.app
.DS_Store
.session.vim
aof*
dist
**/.haptic
static
pkg/webapp/dist
.agent
# Test binary
*.test
.devon*
**/.DS_Store
.task
.wrangler
# Output of the go coverage tool
*.out
tmp
# Exclude embedded files
!internal/files/dist
# Dependency directories
node_modules/
# Go workspace file
go.work
go.work.sum
# Environment files
.env
**/*.env
**/sonr.log
# Terraform
**/.terraform/*
.terraform
*.tfstate
*.tfstate.*
crash.log
crash.*.log
*.tfvars
*.tfvars.json
override.tf
override.tf.json
*_override.tf
*_override.tf.json
.terraformrc
terraform.rc
flake.lock
# Misc
.DS_Store
.tmp/
tmp/
**/*tmp*/
*.tmp
*.log
*.dot
*.pem
dist/
bin/
build/
.devbox
.ignore
.opencommitignore
heighliner*
sonr
deploy/**/data
x/.DS_Store
.aider*
buildenv*
node_modules
cmd/gateway/node_modules
pkg/nebula/node_modules
configs/logs.json
mprocs.yaml
build
sonr.wiki
!devbox.lock
!buf.lock
.air.toml
mprocs.yaml
mprocs.log
tools-stamp
sonr.log
deploy/conf
interchaintest-downloader
.haptic

View File

@ -1,13 +0,0 @@
# https://taskfile.dev
version: '3'
vars:
GREETING: Hello, World!
tasks:
build:
desc: Build the project
cmds:
- echo "{{.GREETING}}"
silent: true

View File

@ -1,14 +0,0 @@
# https://taskfile.dev
version: '3'
vars:
GREETING: Hello, World!
includes:
es: ./ES.yml
go: ./Go.yml
tasks:
default:
cmd: "task -l"

View File

@ -1,14 +0,0 @@
# https://taskfile.dev
version: '3'
vars:
GREETING: Hello, World!
tasks:
install:
desc: Install the pnpm dependencies
dir: web/es-client
cmds:
- pnpm install
silent: true

9
.trunk/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
tmp

View File

@ -0,0 +1,27 @@
linters:
disable:
- unused # Disables unreachable code checking
run:
# Exclude test files from analysis
tests: false
# Define which files and directories to exclude
issues:
exclude-rules:
# Exclude all test files
- path: _test\.go
linters:
- all
# Exclude specific directories
exclude-dirs:
- api/did/v1
- api/dwn/v1
- api/svc/v1
- internal
# Exclude specific file patterns
exclude-files:
- ".*\\.pb\\.go$"
- ".*_templ\\.go$"

View File

@ -0,0 +1,4 @@
# Following source doesn't work in most setups
ignored:
- SC1090
- SC1091

View File

@ -0,0 +1,2 @@
# Prettier friendly markdownlint config (all formatting rules disabled)
extends: markdownlint/style/prettier

View File

@ -0,0 +1,7 @@
enable=all
source-path=SCRIPTDIR
disable=SC2154
# If you're having issues with shellcheck following source, disable the errors via:
# disable=SC1090
# disable=SC1091

View File

@ -0,0 +1,7 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ["{|}"]
key-duplicates: {}
octal-values:
forbid-implicit-octal: true

39
.trunk/trunk.yaml Normal file
View File

@ -0,0 +1,39 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.22.8
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.6.6
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
enabled:
- go@1.23.0
- node@18.20.5
- python@3.10.8
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
# - actionlint@1.7.6
# - checkov@3.2.347
- git-diff-check
- gofmt@1.20.4
- golangci-lint@1.62.2
- hadolint@2.12.1-beta
- markdownlint@0.43.0
- osv-scanner@1.9.2
- prettier@3.4.2
- shellcheck@0.10.0
# - shfmt@3.6.0
- trufflehog@3.88.0
# - yamllint@1.35.1
actions:
enabled:
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
- trunk-upgrade-available

6
Dockerfile Normal file
View File

@ -0,0 +1,6 @@
# For goreleaser
FROM scratch
ENTRYPOINT ["/hway"]
COPY hway /

View File

@ -1,76 +0,0 @@
#!/usr/bin/make -f
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
BINDIR ?= $(GOPATH)/bin
# for dockerized protobuf tools
DOCKER := $(shell which docker)
HTTPS_GIT := github.com/onsonr/hway.git
export RELEASE_DATE="$(date +%Y).$(date +%V).$(date +%u)"
all: deps install test
deps:
go install github.com/apple/pkl-go/cmd/pkl-gen-go@latest
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
go install github.com/go-task/task/v3/cmd/task@latest
build: go.sum
GOOS=js GOARCH=wasm go build -o build/app.wasm ./cmd/main.go
########################################
### Tools & dependencies
########################################
pkl-gen:
@go install github.com/apple/pkl-go/cmd/pkl-gen-go@latest
@pkl-gen-go ./pkl/App.pkl
sqlc-gen:
@go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
@go install github.com/apple/pkl-go/cmd/pkl-gen-go@latest
@cd internal && sqlc generate
go-mod-cache: go.sum
@echo "--> Download go modules to local cache"
@go mod download
go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
@go mod verify
draw-deps:
@# requires brew install graphviz or apt-get install graphviz
go install github.com/RobotsAndPencils/goviz@latest
@goviz -i ./cmd/sonrd -d 2 | dot -Tpng -o dependency-graph.png
clean:
rm -rf .aider*
rm -rf static
rm -rf .out
rm -rf hway.db
rm -rf snapcraft-local.yaml build/
rm -rf build
distclean: clean
rm -rf vendor/
###############################################################################
### help ###
###############################################################################
help:
@echo "Usage: make <target>"
@echo ""
@echo "Available targets:"
@echo " install : Install the binary"
@echo " local-image : Install the docker image"
@echo " proto-gen : Generate code from proto files"
@echo " testnet : Local devnet with IBC"
@echo " sh-testnet : Shell local devnet"
@echo " ictest-basic : Basic end-to-end test"
@echo " ictest-ibc : IBC end-to-end test"
.PHONY: help

20
Taskfile.yml Normal file
View File

@ -0,0 +1,20 @@
# https://taskfile.dev
version: "3"
tasks:
sqlc-gen:
dir: internal
cmds:
- sqlc generate
silent: true
templ-gen:
cmds:
- templ generate
silent: true
pkl-gen:
cmds:
- pkl-gen-go internal/pkl/App.pkl
silent: true

View File

@ -5,9 +5,9 @@ package vault
import ( import (
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
echomiddleware "github.com/labstack/echo/v4/middleware" echomiddleware "github.com/labstack/echo/v4/middleware"
"github.com/onsonr/motr/app/context"
motr "github.com/onsonr/motr/config" motr "github.com/onsonr/motr/config"
motrorm "github.com/onsonr/motr/internal/models" motrorm "github.com/onsonr/motr/internal/models"
"github.com/onsonr/motr/pkg/context"
) )
type Vault = *echo.Echo type Vault = *echo.Echo

1
x/confirm/route.go Normal file
View File

@ -0,0 +1 @@
package wallet