diff --git a/.dockerignore b/.dockerignore index ff12a6f..eb13b43 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ geth-data/ -geth-data-archive/ \ No newline at end of file +geth-data-archive/ +reth-data/ diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 0000000..ceae020 --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,36 @@ +name: Pull Request + +on: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + arch: [ linux/amd64, linux/arm64 ] + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '>=1.21.0' + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Go Format + run: make fmt && git diff --exit-code + - name: Go Vet + run: make vet + - name: Go Tidy + run: go mod tidy && git diff --exit-code + - name: Go Mod + run: go mod download + - name: Go Mod Verify + run: go mod verify + - name: Go Test + run: make test + - name: Build Docker + uses: docker/build-push-action@v5 + with: + push: false \ No newline at end of file diff --git a/.gitignore b/.gitignore index ef72a4e..a45adbb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea/ +.DS_Store geth-data-archive/ geth-data/ secret/ diff --git a/Dockerfile b/Dockerfile index 50285c9..a4a243e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21 as builder +FROM golang:1.21 AS builder WORKDIR /app diff --git a/Makefile b/Makefile index daa13c0..2c178af 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,37 @@ -build: - docker-compose build +build-docker: + docker compose build run: - docker-compose down - docker-compose build + docker compose down + docker compose build rm -rf ./geth-data cp -R ./geth-data-archive ./geth-data - docker-compose up -d - docker-compose logs -f replayor + docker compose up -d + docker compose logs -f replayor initialize: mkdir secret - openssl rand -hex 32 > secret/jwt \ No newline at end of file + openssl rand -hex 32 > secret/jwt + +build: + go build ./cmd/replayor/main.go +.PHONY: build + +test: + go test ./... +.PHONY: test + +vet: + go vet ./... +.PHONY: vet + +fmt: + gofmt -s -w . +.PHONY: fmt + +check: lint fmt vet test build build-docker +.PHONY: check + +lint: + golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./... +.PHONY: lint \ No newline at end of file diff --git a/cmd/replayor/main.go b/cmd/replayor/main.go index 802bf25..bd5388c 100644 --- a/cmd/replayor/main.go +++ b/cmd/replayor/main.go @@ -47,6 +47,9 @@ func Main() cliapp.LifecycleAction { } c, err := clients.SetupClients(cfg, logger, ctx) + if err != nil { + return nil, err + } // Benchmark stats s, err := stats.NewStorage(logger, cfg) diff --git a/docker-compose.yml b/docker-compose.yml index a5aabeb..e8a4b2d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - services: # node: # this is Optimism's geth client w/ a patch to not reject txns as part of FCU # build: ./geth diff --git a/geth/Dockerfile b/geth/Dockerfile index 0dd320d..6dae0bf 100644 --- a/geth/Dockerfile +++ b/geth/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21 as geth +FROM golang:1.21 AS geth WORKDIR /app diff --git a/packages/clients/clients.go b/packages/clients/clients.go index 0a3f59e..050ae76 100644 --- a/packages/clients/clients.go +++ b/packages/clients/clients.go @@ -60,6 +60,10 @@ func SetupClients(cfg config.ReplayorConfig, logger log.Logger, ctx context.Cont return engineApi, nil }) + if err != nil { + return Clients{}, err + } + return Clients{ SourceNode: sourceNode, DestNode: destNode, diff --git a/packages/config/config.go b/packages/config/config.go index 225da36..31a6ebc 100644 --- a/packages/config/config.go +++ b/packages/config/config.go @@ -2,7 +2,6 @@ package config import ( "fmt" - "io/ioutil" "os" "strings" @@ -45,7 +44,7 @@ func valueOrNil(i *uint64) string { func LoadReplayorConfig(cliCtx *cli.Context, l log.Logger) (ReplayorConfig, error) { jwtFile := cliCtx.String(EngineApiSecret.Name) - jwtBytes, err := ioutil.ReadFile(jwtFile) + jwtBytes, err := os.ReadFile(jwtFile) if err != nil { return ReplayorConfig{}, err }