create cicd pipeline for deployments to staging environment - step 1 (#71)

* add missing makefiles and fix deps

* add parser makefile and github action for PR

* fix warning

* fix printf

Co-authored-by: gipsh <gipsh@gmail.com>
This commit is contained in:
gipsh 2023-01-23 18:41:19 -03:00 committed by GitHub
parent 2283e84ed6
commit f4f543fc95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 111 additions and 3 deletions

39
.github/workflows/pr_build.yml vendored Normal file
View File

@ -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

27
Makefile Normal file
View File

@ -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

View File

@ -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,

21
parser/Makefile Normal file
View File

@ -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

View File

@ -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 {

21
spy/Makefile Normal file
View File

@ -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