Skip to content

Commit a17b272

Browse files
committed
Initial commit
0 parents  commit a17b272

323 files changed

Lines changed: 37256 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/go.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Go
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version: "1.23"
19+
20+
- name: Build
21+
run: go build -v ./...
22+
23+
- name: Test
24+
run: go test -short -v ./...

.github/workflows/lint.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
merge_group:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
golangci:
15+
name: golangci-lint
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- uses: actions/setup-go@v5
21+
with:
22+
go-version: "1.23"
23+
24+
- name: golangci-lint
25+
uses: golangci/golangci-lint-action@v4
26+
with:
27+
version: latest
28+
args: --timeout=5m

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: "1.23"
24+
25+
- name: Run GoReleaser
26+
uses: goreleaser/goreleaser-action@v6
27+
with:
28+
distribution: goreleaser
29+
version: "~> v2"
30+
args: release --clean
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Binaries
2+
bin/
3+
dist/
4+
*.exe
5+
*.exe~
6+
*.dll
7+
*.so
8+
*.dylib
9+
10+
# Build artifacts
11+
build/
12+
13+
# IDE
14+
.idea/
15+
.vscode/
16+
.cursor/
17+
18+
# OS
19+
.DS_Store
20+
Thumbs.db
21+
22+
# Environment
23+
.env
24+
.env.local
25+
secrets.yaml
26+
27+
# Test artifacts
28+
*.test
29+
*.out
30+
coverage.txt
31+
32+
# Go
33+
vendor/
34+
go.work
35+
go.work.sum

.goreleaser.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
version: 2
2+
3+
project_name: reporterd
4+
5+
builds:
6+
- id: reporterd
7+
dir: .
8+
main: ./cmd/main.go
9+
binary: reporterd
10+
env:
11+
- CGO_ENABLED=0
12+
goos:
13+
- linux
14+
- darwin
15+
- windows
16+
goarch:
17+
- amd64
18+
- arm64
19+
20+
archives:
21+
- formats: tar.gz
22+
name_template: >-
23+
{{ .ProjectName }}_
24+
{{- title .Os }}_
25+
{{- if eq .Arch "amd64" }}x86_64
26+
{{- else if eq .Arch "386" }}i386
27+
{{- else }}{{ .Arch }}{{ end }}
28+
{{- if .Arm }}v{{ .Arm }}{{ end }}
29+
30+
checksum:
31+
name_template: "{{ .ProjectName }}_checksums.txt"
32+
33+
release:
34+
prerelease: "true"
35+
header: |
36+
## Release {{ .Tag }} - ({{ .Date }})
37+
38+
changelog:
39+
sort: asc
40+
filters:
41+
exclude:
42+
- "^docs:"
43+
- "^test:"

Makefile

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/usr/bin/make -f
2+
3+
# Fix version extraction and use hardcoded values for problematic dependencies
4+
GOPATH=$(shell go env GOPATH)
5+
COSMOS_VERSION=$(shell go list -m all | grep "github.com/cosmos/cosmos-sdk" | awk '{print $$NF}' | head -1)
6+
COSMOS_LOG_VERSION=$(shell go list -m all | grep "cosmossdk.io/log" | awk '{print $$NF}' | head -1)
7+
# Use a known stable version instead of trying to extract it
8+
GOGO_PROTO_VERSION=v1.3.2
9+
GRPC_GATEWAY_VERSION=v1.16.0
10+
11+
.PHONY: install build clean mod
12+
13+
install: go.sum
14+
@echo "Installing reporterd..."
15+
@go install -mod=readonly ./cmd
16+
@echo "Completed install!"
17+
18+
build:
19+
@echo "Building reporterd..."
20+
go build -o bin/reporterd ./cmd
21+
22+
clean:
23+
@echo "Cleaning build artifacts..."
24+
rm -rf bin/
25+
go clean
26+
27+
mod:
28+
@echo "--> Updating go.mod"
29+
@go mod tidy
30+
31+
32+
###############################################################################
33+
### tests ###
34+
###############################################################################
35+
.PHONY: test mock-gen-daemon
36+
37+
mock-gen-daemon:
38+
@go run github.com/vektra/mockery/v2 --name=AppOptions --dir=$(GOPATH)/pkg/mod/github.com/cosmos/cosmos-sdk@$(COSMOS_VERSION)/server/types --recursive --output=$(CURDIR)/mocks
39+
@go run github.com/vektra/mockery/v2 --name=ExchangeQueryHandler --dir=$(CURDIR)/pricefeed/client/queryhandler --recursive --output=$(CURDIR)/mocks
40+
@go run github.com/vektra/mockery/v2 --name=ExchangeToMarketPrices --dir=$(CURDIR)/pricefeed/client/types --recursive --output=$(CURDIR)/mocks
41+
@go run github.com/vektra/mockery/v2 --name=GrpcClient --dir=$(CURDIR)/types --recursive --output=$(CURDIR)/mocks
42+
@go run github.com/vektra/mockery/v2 --name=Logger --dir=$(GOPATH)/pkg/mod/cosmossdk.io/log@$(COSMOS_LOG_VERSION) --recursive --output=$(CURDIR)/mocks
43+
@go run github.com/vektra/mockery/v2 --name=PricefeedMutableMarketConfigs --dir=$(CURDIR)/pricefeed/client/types --filename=PriceFeedMutableMarketConfigs.go --recursive --output=$(CURDIR)/mocks
44+
@go run github.com/vektra/mockery/v2 --name=QueryClient --dir=$(CURDIR)/testutil/grpc --recursive --output=$(CURDIR)/mocks
45+
@go run github.com/vektra/mockery/v2 --name=RequestHandler --dir=$(CURDIR)/types --recursive --output=$(CURDIR)/mocks
46+
@go run github.com/vektra/mockery/v2 --name=TimeProvider --dir=$(CURDIR)/lib/time --recursive --output=$(CURDIR)/mocks
47+
48+
49+
test:
50+
@echo "Running tests..."
51+
go test -v ./...
52+
53+
###############################################################################
54+
### linting ###
55+
###############################################################################
56+
.PHONY: lint lint-fix install-lint-deps
57+
58+
lint:
59+
@echo "Linting daemon code..."
60+
golangci-lint run ./...
61+
62+
# Fix linting issues where possible
63+
lint-fix:
64+
@echo "Fixing linting issues..."
65+
golangci-lint run --fix ./...
66+
67+
install-lint-deps:
68+
@echo "Checking for golangci-lint..."
69+
@if ! command -v golangci-lint &> /dev/null; then \
70+
echo "Installing golangci-lint..."; \
71+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; \
72+
else \
73+
echo "golangci-lint already installed"; \
74+
fi
75+
76+
77+
###############################################################################
78+
### proto ###
79+
###############################################################################
80+
.PHONY: proto proto-gen proto-install proto-check proto-deps
81+
82+
proto-gen:
83+
@echo "Generating protocol buffer files using buf..."
84+
@if ! command -v buf > /dev/null; then \
85+
echo "buf not found. Installing..."; \
86+
go install github.com/bufbuild/buf/cmd/buf@latest; \
87+
fi
88+
@echo "Resolving dependencies..."
89+
@cd proto && buf dep update
90+
@echo "Generating code..."
91+
@cd proto && buf generate --template buf.gen.gogo.yaml
92+
@echo "Proto generation completed"
93+
94+
proto-install:
95+
@echo "Installing protobuf dependencies for Cosmos SDK compatibility..."
96+
@go install github.com/cosmos/gogoproto/protoc-gen-gocosmos@latest
97+
@go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@$(GRPC_GATEWAY_VERSION)
98+
@go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
99+
@go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
100+
@go install github.com/bufbuild/buf/cmd/buf@latest
101+
@echo "Proto tooling installation completed"
102+
103+
proto-check:
104+
@if ! command -v buf > /dev/null; then \
105+
echo "Error: buf is not installed. Please install buf first."; \
106+
echo "Run: go install github.com/bufbuild/buf/cmd/buf@latest"; \
107+
exit 1; \
108+
fi
109+
@if [ ! -d proto/daemons ]; then \
110+
echo "Error: proto/daemons directory does not exist."; \
111+
exit 1; \
112+
fi
113+
114+
# Main proto target that depends on proto-gen
115+
proto: proto-check
116+
@echo "Running proto generation..."
117+
@$(MAKE) proto-gen
118+
@echo "Protocol buffers generated successfully"
119+
120+
proto-deps:
121+
@echo "Installing protobuf dependencies..."
122+
@$(MAKE) proto-install

0 commit comments

Comments
 (0)