From fcbc50e53b11d2d09f51ea2540aeb66ea022c103 Mon Sep 17 00:00:00 2001 From: peak3d Date: Sat, 31 Dec 2022 15:29:20 +0100 Subject: [PATCH] Fix CI / builds --- .github/workflows/ci.yml | 22 +++++++++++++--------- .github/workflows/release.yaml | 8 +++++--- .golangci.yml | 2 +- Dockerfile | 4 ++-- models/types.go | 1 + scripts/lint.sh | 4 +++- services/indexes/pvm/writer.go | 5 +++-- stream/producer_chain.go | 10 ++-------- 8 files changed, 30 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 003ed661a..5920f2339 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,23 +2,25 @@ name: build-check on: push: - branches: [chain4travel] + branches: [chain4travel, dev] pull_request: - branches: [chain4travel] + branches: [chain4travel, dev] jobs: lint: name: lint - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 strategy: matrix: go: - - '1.19.1' + - '1.18' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - name: Submodules + run: git submodule update --init --recursive - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - version: v1.41.1 + version: v1.47.0 args: --timeout 5m skip-go-installation: true test-and-build: @@ -27,7 +29,7 @@ jobs: strategy: matrix: go: - - '1.19.1' + - '1.18' services: mysql: image: mysql:8.0.26 @@ -38,8 +40,10 @@ jobs: MYSQL_DATABASE: magellan_test options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v1 + - uses: actions/checkout@v3 + - name: Submodules + run: git submodule update --init --recursive + - uses: actions/setup-go@v3 with: go-version: ${{ matrix.go }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 821968793..8dc9c64c4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,17 +14,19 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out the repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 + - name: Submodules + run: git submodule update --init --recursive - name: Set output id: vars run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} - name: Log in to Docker Hub - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASS }} - name: Push to Docker Hub - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: push: true tags: c4tplatform/magellan:${{ steps.vars.outputs.tag }} diff --git a/.golangci.yml b/.golangci.yml index b31edacdb..abce907d8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -37,7 +37,7 @@ linters: - goconst - gocritic - gocyclo - - godox +# - godox - gofmt - goimports - golint diff --git a/Dockerfile b/Dockerfile index cb64deee2..00bbf3373 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Create base builder image -FROM golang:1.19.1-alpine3.16 AS builder +FROM golang:1.18.8-alpine3.16 AS builder WORKDIR /go/src/github.com/chain4travel/magellan RUN apk add --no-cache alpine-sdk bash git make gcc musl-dev linux-headers git ca-certificates g++ libstdc++ @@ -7,7 +7,7 @@ RUN apk add --no-cache alpine-sdk bash git make gcc musl-dev linux-headers git c # Build app COPY . . RUN if [ -d "./vendor" ];then export MOD=vendor; else export MOD=mod; fi && \ - GOOS=linux GOARCH=amd64 CGO_CFLAGS="-O -D__BLST_PORTABLE__" go build -mod=$MOD -o /opt/magelland ./cmds/magelland/*.go + GOOS=linux GOARCH=amd64 go build -mod=$MOD -o /opt/magelland ./cmds/magelland/*.go # Create final image FROM alpine:3.16 as execution diff --git a/models/types.go b/models/types.go index d52753b5a..400643b7c 100644 --- a/models/types.go +++ b/models/types.go @@ -50,6 +50,7 @@ var ( TransactionTypeAddDaoVote TransactionType = 0x20 // Camino Custom Datatypes + RegisterTransactionTypeCustom TransactionType = 8192 RegisterOutputTypeCustom OutputType = 8192 diff --git a/scripts/lint.sh b/scripts/lint.sh index 4ceb33a2e..5261f6472 100644 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -11,7 +11,9 @@ fi TARGET="./..." -go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2 +if ! [ -x "$(command -v golangci-lint)" ]; then + go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.47.0 +fi golangci-lint run --config .golangci.yml echo "ALL SUCCESS!" diff --git a/services/indexes/pvm/writer.go b/services/indexes/pvm/writer.go index ae69b2706..3419849c2 100644 --- a/services/indexes/pvm/writer.go +++ b/services/indexes/pvm/writer.go @@ -171,7 +171,6 @@ func (w *Writer) Consume(ctx context.Context, conns *utils.Connections, c servic } func (w *Writer) Bootstrap(ctx context.Context, conns *utils.Connections, persist db.Persist, gc *utils.GenesisContainer) error { - txDupCheck := set.NewSet[ids.ID](2*len(gc.Genesis.Camino.AddressStates) + 2*len(gc.Genesis.Camino.ConsortiumMembersNodeIDs)) @@ -225,7 +224,8 @@ func (w *Writer) Bootstrap(ctx context.Context, conns *utils.Connections, persis } } - platformTx := append(gc.Genesis.Validators, gc.Genesis.Chains...) + platformTx := gc.Genesis.Validators + platformTx = append(platformTx, gc.Genesis.Chains...) platformTx = append(platformTx, gc.Genesis.Camino.Deposits...) for _, tx := range platformTx { @@ -381,6 +381,7 @@ func (w *Writer) indexCommonBlock( return ctx.Persist().InsertPvmBlocks(ctx.Ctx(), ctx.DB(), pvmBlocks, cfg.PerformUpdates) } +//nolint:gocyclo func (w *Writer) indexTransaction(ctx services.ConsumerCtx, blkID ids.ID, tx *txs.Tx, genesis bool) error { var ( txID = tx.ID() diff --git a/stream/producer_chain.go b/stream/producer_chain.go index eed728139..53415660f 100644 --- a/stream/producer_chain.go +++ b/stream/producer_chain.go @@ -448,15 +448,9 @@ func IndexNotReady(err error) bool { } func ChainNotReady(err error) bool { - if strings.HasPrefix(err.Error(), "received status code '404'") { - return true - } - return false + return strings.HasPrefix(err.Error(), "received status code '404'") } func ZeroAcceptedContainers(err error) bool { - if strings.Contains(err.Error(), "no containers have been accepted") { - return true - } - return false + return strings.Contains(err.Error(), "no containers have been accepted") }