Skip to content

Commit 3d6cf55

Browse files
authored
Merge pull request #24 from Zondax/refactor
Refactor
2 parents dde95b5 + fdd3bc3 commit 3d6cf55

37 files changed

Lines changed: 2046 additions & 116 deletions

.github/workflows/main.yml

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Build jobs
22

33
on:
4-
push:
54
pull_request:
65
branches:
76
- main
@@ -16,7 +15,7 @@ jobs:
1615
submodules: true
1716
- uses: actions/setup-go@v2
1817
with:
19-
go-version: '^1.16'
18+
go-version: '^1.17'
2019
- name: Build
2120
run: |
2221
make build
@@ -30,11 +29,47 @@ jobs:
3029
submodules: true
3130
- uses: actions/setup-go@v2
3231
with:
33-
go-version: '^1.16'
32+
go-version: '^1.17'
3433
- run: make build
3534
- name: ModTidy check
3635
run: make check-modtidy
3736
- name: Lint check
3837
run: |
3938
make install_lint
4039
make lint
40+
41+
tests-components:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v2
46+
with:
47+
submodules: true
48+
- uses: actions/setup-go@v2
49+
with:
50+
go-version: '^1.17'
51+
- name: "Launch db engine in background"
52+
run: |
53+
make test-database-up
54+
- name: "Give time for processes to start"
55+
run: sleep 5
56+
- name: Components tests
57+
run: make test-components
58+
59+
tests-integration:
60+
runs-on: ubuntu-latest
61+
steps:
62+
- name: Checkout
63+
uses: actions/checkout@v2
64+
with:
65+
submodules: true
66+
- uses: actions/setup-go@v2
67+
with:
68+
go-version: '^1.17'
69+
- name: "Launch db engine in background"
70+
run: |
71+
make test-database-up
72+
- name: "Give time for processes to start"
73+
run: sleep 5
74+
- name: Integration test
75+
run: make test-integration

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ gitclean:
99
git submodule foreach --recursive git clean -xfd
1010

1111
install_lint:
12-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.35.2
12+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.41.1
1313

1414
check-modtidy:
1515
go mod tidy
@@ -24,9 +24,17 @@ test: build
2424
go test -race ./...
2525

2626
test-database: build
27-
go test ./connections/database/... -v
27+
go test ./components/connections/database/... -v
28+
29+
test-integration: build
30+
go test -v ./indexer/tests/...
31+
32+
test-components: build
33+
go test -v ./components/...
2834

2935
# Docker
36+
test-database-up:
37+
docker-compose -f ./indexer/tests/docker-compose.yml up -d
3038

3139
test-database-services:
3240
docker-compose -f tests_docker/test_database.yml up --abort-on-container-exit
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package connections
22

33
import (
44
"context"
5-
ds "github.com/Zondax/zindexer/connections/data_store"
6-
"github.com/Zondax/zindexer/connections/database"
5+
"github.com/Zondax/zindexer/components/connections/data_store"
6+
"github.com/Zondax/zindexer/components/connections/database"
77
"github.com/coinbase/rosetta-sdk-go/client"
88
"go.mongodb.org/mongo-driver/mongo"
99
"gorm.io/gorm"
@@ -21,7 +21,7 @@ type DataSource struct {
2121
DatabaseMongoCfg database.DBConnectionParams
2222
RosettaClient *client.APIClient
2323
NodeClient interface{}
24-
DataStore ds.DataStoreClient
24+
DataStore data_store.DataStoreClient
2525
// common
2626
Ctx context.Context
2727
RetryDelay time.Duration
@@ -87,9 +87,9 @@ func WithNodeClient(node interface{}) SourceOption {
8787
}
8888
}
8989

90-
func WithDataStore(cfg ds.DataStoreConfig) SourceOption {
90+
func WithDataStore(cfg data_store.DataStoreConfig) SourceOption {
9191
return func(w *DataSource) {
92-
storeClient, err := ds.NewDataStoreClient(cfg)
92+
storeClient, err := data_store.NewDataStoreClient(cfg)
9393
if err != nil {
9494
panic(err)
9595
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

connections/database/graphql/graphql.go renamed to components/connections/database/graphql/graphql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package graphql
33
import (
44
"encoding/json"
55
"fmt"
6+
"github.com/Zondax/zindexer/components/connections/database"
67
"io/ioutil"
78
"net/http"
89
"strings"
910
"time"
1011

11-
"github.com/Zondax/zindexer/connections/database"
1212
"github.com/hasura/go-graphql-client"
1313
"go.uber.org/zap"
1414
)

connections/database/mongodb/mongoDB.go renamed to components/connections/database/mongodb/mongoDB.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package mongodb
33
import (
44
"context"
55
"fmt"
6-
"github.com/Zondax/zindexer/connections/database"
6+
"github.com/Zondax/zindexer/components/connections/database"
77
"go.uber.org/zap"
88
"time"
99

connections/database/mongodb/mongoDB_test.go renamed to components/connections/database/mongodb/mongoDB_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"crypto/rand"
66
"fmt"
7-
"github.com/Zondax/zindexer/connections/database"
7+
"github.com/Zondax/zindexer/components/connections/database"
88
"go.mongodb.org/mongo-driver/bson"
99
"os"
1010
"testing"

0 commit comments

Comments
 (0)