Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup CI #5

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
geth-data/
geth-data-archive/
geth-data-archive/
reth-data/
36 changes: 36 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/
.DS_Store
geth-data-archive/
geth-data/
secret/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21 as builder
FROM golang:1.21 AS builder

WORKDIR /app

Expand Down
37 changes: 30 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
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
3 changes: 3 additions & 0 deletions cmd/replayor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion geth/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21 as geth
FROM golang:1.21 AS geth

WORKDIR /app

Expand Down
4 changes: 4 additions & 0 deletions packages/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions packages/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package config

import (
"fmt"
"io/ioutil"
"os"
"strings"

Expand Down Expand Up @@ -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
}
Expand Down