diff --git a/.github/workflows/pr_build.yml b/.github/workflows/pr_build.yml new file mode 100644 index 00000000..cd895982 --- /dev/null +++ b/.github/workflows/pr_build.yml @@ -0,0 +1,39 @@ +name: Go + +on: + pull_request: + branches: [ main ] + push: + branches: [ main ] + + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.19 + + - name: Build + run: make build + + - name: Test fly + working-directory: ./fly + run: make test + + - name: Test api + working-directory: ./api + run: make test + + - name: Test spy + working-directory: ./spy + run: make test + + - name: Test parser + working-directory: ./parser + run: make test \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..04339991 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +SHELL := /bin/bash + + +## help: print this help message +.PHONY: help +help: + @echo 'Usage:' + @sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /' + +build: + make -C api/ build + make -C fly/ build + make -C spy/ build + make -C parser/ build + +doc: + swag init -pd + + +test: + cd api && go test -v -cover ./... + cd fly && go test -v -cover ./... + cd spy && go test -v -cover ./... + cd parser && go test -v -cover ./... + + +.PHONY: build doc test diff --git a/api/handlers/governor/repository.go b/api/handlers/governor/repository.go index 24d9e994..95c66ad4 100644 --- a/api/handlers/governor/repository.go +++ b/api/handlers/governor/repository.go @@ -799,7 +799,7 @@ func (r *Repository) GetEnqueueVass(ctx context.Context, q *EnqueuedVaaQuery) ([ emitterAddress := ea.Address enqueuedVaa := ea.EnqueuedVaas for _, v := range enqueuedVaa { - key := fmt.Sprintf("%s/%d/%s", emitterAddress, v.Sequence, v.TxHash) + key := fmt.Sprintf("%s/%s/%s", emitterAddress, v.Sequence, v.TxHash) if _, ok := keys[key]; !ok { enqueuedVaa := EnqueuedVaa{ ChainID: chainID, @@ -944,7 +944,7 @@ func (r *Repository) GetEnqueueVassByChainID(ctx context.Context, q *EnqueuedVaa enqueuedVaas := row.EnqueuedVaas for _, ev := range enqueuedVaas { for _, v := range ev.EnqueuedVaas[0] { - key := fmt.Sprintf("%s/%d/%s", emitterAddress, v.Sequence, v.TxHash) + key := fmt.Sprintf("%s/%s/%s", emitterAddress, v.Sequence, v.TxHash) if _, ok := keys[key]; !ok { fr := EnqueuedVaaDetail{ ChainID: q.chainID, diff --git a/parser/Makefile b/parser/Makefile new file mode 100644 index 00000000..e46aa02f --- /dev/null +++ b/parser/Makefile @@ -0,0 +1,21 @@ +SHELL := /bin/bash + + +## help: print this help message +.PHONY: help +help: + @echo 'Usage:' + @sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /' + +build: + go build -o parser cmd/main.go + +doc: + swag init -pd + + +test: + go test -v -cover ./... + + +.PHONY: build doc test diff --git a/parser/watcher/watcher.go b/parser/watcher/watcher.go index fd009593..cdd98436 100644 --- a/parser/watcher/watcher.go +++ b/parser/watcher/watcher.go @@ -58,7 +58,7 @@ func NewWatcher(db *mongo.Database, dbName string, handler WatcherFunc, logger * // Start executes database event consumption. func (w *Watcher) Start(ctx context.Context) error { - query := fmt.Sprintf(queryTemplate, w.dbName, w.dbName) + query := fmt.Sprintf(queryTemplate, w.dbName) var steps []bson.D err := bson.UnmarshalExtJSON([]byte(query), true, &steps) if err != nil { diff --git a/spy/Makefile b/spy/Makefile new file mode 100644 index 00000000..d66698de --- /dev/null +++ b/spy/Makefile @@ -0,0 +1,21 @@ +SHELL := /bin/bash + + +## help: print this help message +.PHONY: help +help: + @echo 'Usage:' + @sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /' + +build: + go build -o spy cmd/main.go + +doc: + swag init -pd + + +test: + go test -v -cover ./... + + +.PHONY: build doc test