From 567d38190f83007e207707519ce6fa645cb2f667 Mon Sep 17 00:00:00 2001 From: Darp Alakun Date: Mon, 6 Jan 2025 14:28:43 -0500 Subject: [PATCH] feat: add CI/CD workflows for improved automation --- .github/scopes.json | 238 +++++++++++++++++++++ .github/workflows/check-pr.yml | 138 ++++++++++++ .github/workflows/new-release.yml | 66 ++++++ .github/workflows/new-tag.yml | 51 +++++ .github/workflows/post-merge.yml | 33 +++ .gitignore | 114 ++++++++++ .taskfiles/Go.yml | 13 -- .taskfiles/Taskfile.yml | 14 -- .taskfiles/es.yml | 14 -- .trunk/.gitignore | 9 + .trunk/configs/.golangci.yaml | 27 +++ .trunk/configs/.hadolint.yaml | 4 + .trunk/configs/.markdownlint.yaml | 2 + .trunk/configs/.shellcheckrc | 7 + .trunk/configs/.yamllint.yaml | 7 + .trunk/trunk.yaml | 39 ++++ Dockerfile | 6 + Makefile | 76 ------- Taskfile.yml | 20 ++ app/app.go | 2 +- {pkl => internal/pkl}/App.pkl | 0 x/{wallet/routes.go => authorize/route.go} | 0 x/confirm/route.go | 1 + x/errors/{routes.go => route.go} | 0 x/{dash/routes.go => index/route.go} | 0 x/{authz/routes.go => login/route.go} | 0 x/{auth/routes.go => register/route.go} | 0 x/search/{routes.go => route.go} | 0 28 files changed, 763 insertions(+), 118 deletions(-) create mode 100644 .github/scopes.json create mode 100644 .github/workflows/check-pr.yml create mode 100644 .github/workflows/new-release.yml create mode 100644 .github/workflows/new-tag.yml create mode 100644 .github/workflows/post-merge.yml delete mode 100644 .taskfiles/Go.yml delete mode 100644 .taskfiles/Taskfile.yml delete mode 100644 .taskfiles/es.yml create mode 100644 .trunk/.gitignore create mode 100644 .trunk/configs/.golangci.yaml create mode 100644 .trunk/configs/.hadolint.yaml create mode 100644 .trunk/configs/.markdownlint.yaml create mode 100644 .trunk/configs/.shellcheckrc create mode 100644 .trunk/configs/.yamllint.yaml create mode 100644 .trunk/trunk.yaml create mode 100644 Dockerfile delete mode 100644 Makefile create mode 100644 Taskfile.yml rename {pkl => internal/pkl}/App.pkl (100%) rename x/{wallet/routes.go => authorize/route.go} (100%) create mode 100644 x/confirm/route.go rename x/errors/{routes.go => route.go} (100%) rename x/{dash/routes.go => index/route.go} (100%) rename x/{authz/routes.go => login/route.go} (100%) rename x/{auth/routes.go => register/route.go} (100%) rename x/search/{routes.go => route.go} (100%) diff --git a/.github/scopes.json b/.github/scopes.json new file mode 100644 index 0000000..ec9594c --- /dev/null +++ b/.github/scopes.json @@ -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" + } + ] +} diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml new file mode 100644 index 0000000..1241d3b --- /dev/null +++ b/.github/workflows/check-pr.yml @@ -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 }} diff --git a/.github/workflows/new-release.yml b/.github/workflows/new-release.yml new file mode 100644 index 0000000..5187773 --- /dev/null +++ b/.github/workflows/new-release.yml @@ -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 diff --git a/.github/workflows/new-tag.yml b/.github/workflows/new-tag.yml new file mode 100644 index 0000000..63ce139 --- /dev/null +++ b/.github/workflows/new-tag.yml @@ -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 }} diff --git a/.github/workflows/post-merge.yml b/.github/workflows/post-merge.yml new file mode 100644 index 0000000..44f1cf5 --- /dev/null +++ b/.github/workflows/post-merge.yml @@ -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 diff --git a/.gitignore b/.gitignore index 90bf051..115025f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,117 @@ .idea bin 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 + diff --git a/.taskfiles/Go.yml b/.taskfiles/Go.yml deleted file mode 100644 index 90e6f6b..0000000 --- a/.taskfiles/Go.yml +++ /dev/null @@ -1,13 +0,0 @@ -# https://taskfile.dev - -version: '3' - -vars: - GREETING: Hello, World! - -tasks: - build: - desc: Build the project - cmds: - - echo "{{.GREETING}}" - silent: true diff --git a/.taskfiles/Taskfile.yml b/.taskfiles/Taskfile.yml deleted file mode 100644 index bacd355..0000000 --- a/.taskfiles/Taskfile.yml +++ /dev/null @@ -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" diff --git a/.taskfiles/es.yml b/.taskfiles/es.yml deleted file mode 100644 index 51358df..0000000 --- a/.taskfiles/es.yml +++ /dev/null @@ -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 diff --git a/.trunk/.gitignore b/.trunk/.gitignore new file mode 100644 index 0000000..15966d0 --- /dev/null +++ b/.trunk/.gitignore @@ -0,0 +1,9 @@ +*out +*logs +*actions +*notifications +*tools +plugins +user_trunk.yaml +user.yaml +tmp diff --git a/.trunk/configs/.golangci.yaml b/.trunk/configs/.golangci.yaml new file mode 100644 index 0000000..7d594af --- /dev/null +++ b/.trunk/configs/.golangci.yaml @@ -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$" diff --git a/.trunk/configs/.hadolint.yaml b/.trunk/configs/.hadolint.yaml new file mode 100644 index 0000000..98bf0cd --- /dev/null +++ b/.trunk/configs/.hadolint.yaml @@ -0,0 +1,4 @@ +# Following source doesn't work in most setups +ignored: + - SC1090 + - SC1091 diff --git a/.trunk/configs/.markdownlint.yaml b/.trunk/configs/.markdownlint.yaml new file mode 100644 index 0000000..b40ee9d --- /dev/null +++ b/.trunk/configs/.markdownlint.yaml @@ -0,0 +1,2 @@ +# Prettier friendly markdownlint config (all formatting rules disabled) +extends: markdownlint/style/prettier diff --git a/.trunk/configs/.shellcheckrc b/.trunk/configs/.shellcheckrc new file mode 100644 index 0000000..8c7b1ad --- /dev/null +++ b/.trunk/configs/.shellcheckrc @@ -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 diff --git a/.trunk/configs/.yamllint.yaml b/.trunk/configs/.yamllint.yaml new file mode 100644 index 0000000..184e251 --- /dev/null +++ b/.trunk/configs/.yamllint.yaml @@ -0,0 +1,7 @@ +rules: + quoted-strings: + required: only-when-needed + extra-allowed: ["{|}"] + key-duplicates: {} + octal-values: + forbid-implicit-octal: true diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml new file mode 100644 index 0000000..24f9f2e --- /dev/null +++ b/.trunk/trunk.yaml @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..859b233 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ + + +# For goreleaser +FROM scratch +ENTRYPOINT ["/hway"] +COPY hway / diff --git a/Makefile b/Makefile deleted file mode 100644 index ec0043e..0000000 --- a/Makefile +++ /dev/null @@ -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 " - @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 - diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..8a832e3 --- /dev/null +++ b/Taskfile.yml @@ -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 diff --git a/app/app.go b/app/app.go index 0046a53..37dd6d2 100644 --- a/app/app.go +++ b/app/app.go @@ -5,9 +5,9 @@ package vault import ( "github.com/labstack/echo/v4" echomiddleware "github.com/labstack/echo/v4/middleware" + "github.com/onsonr/motr/app/context" motr "github.com/onsonr/motr/config" motrorm "github.com/onsonr/motr/internal/models" - "github.com/onsonr/motr/pkg/context" ) type Vault = *echo.Echo diff --git a/pkl/App.pkl b/internal/pkl/App.pkl similarity index 100% rename from pkl/App.pkl rename to internal/pkl/App.pkl diff --git a/x/wallet/routes.go b/x/authorize/route.go similarity index 100% rename from x/wallet/routes.go rename to x/authorize/route.go diff --git a/x/confirm/route.go b/x/confirm/route.go new file mode 100644 index 0000000..23a7507 --- /dev/null +++ b/x/confirm/route.go @@ -0,0 +1 @@ +package wallet diff --git a/x/errors/routes.go b/x/errors/route.go similarity index 100% rename from x/errors/routes.go rename to x/errors/route.go diff --git a/x/dash/routes.go b/x/index/route.go similarity index 100% rename from x/dash/routes.go rename to x/index/route.go diff --git a/x/authz/routes.go b/x/login/route.go similarity index 100% rename from x/authz/routes.go rename to x/login/route.go diff --git a/x/auth/routes.go b/x/register/route.go similarity index 100% rename from x/auth/routes.go rename to x/register/route.go diff --git a/x/search/routes.go b/x/search/route.go similarity index 100% rename from x/search/routes.go rename to x/search/route.go