Skip to content

Commit

Permalink
feat!: Make exporter evm chain agnostic
Browse files Browse the repository at this point in the history
Add go tests

Add retries and backoffs to rpc requests

Improve CI
  • Loading branch information
chliddle committed Nov 14, 2024
1 parent f9d6978 commit 6d93e67
Show file tree
Hide file tree
Showing 8 changed files with 496 additions and 78 deletions.
8 changes: 4 additions & 4 deletions .github/release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ module.exports = {
}],
['@semantic-release/github', {
assets: [
{ path: 'release/berachain-exporter-linux-amd64' },
{ path: 'release/berachain-exporter-darwin-amd64' },
{ path: 'release/berachain-exporter-darwin-arm64' },
{ path: 'release/berachain-exporter-windows-amd64.exe' }
{ path: 'release/evm-exporter-linux-amd64' },
{ path: 'release/evm-exporter-darwin-amd64' },
{ path: 'release/evm-exporter-darwin-arm64' },
{ path: 'release/evm-exporter-windows-amd64.exe' }
],
}],
['@semantic-release/git', {
Expand Down
56 changes: 37 additions & 19 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,55 @@
name: Build and Package
name: Build

on:
pull_request:
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
branches: [ main ]

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Run tests
run: go test -v ./...

build:
needs: test
name: Build and Publish
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Setup Go
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.1'
go-version: '1.21'

- name: Get short SHA
id: sha
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Build Binaries
- name: Build binaries
run: |
mkdir -p release
GOOS=linux GOARCH=amd64 go build -o release/berachain-exporter-linux-amd64
GOOS=darwin GOARCH=amd64 go build -o release/berachain-exporter-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -o release/berachain-exporter-darwin-arm64
GOOS=windows GOARCH=amd64 go build -o release/berachain-exporter-windows-amd64.exe
GOOS=linux GOARCH=amd64 go build -o release/evm-exporter-linux-amd64-${{ steps.sha.outputs.sha }}
GOOS=darwin GOARCH=amd64 go build -o release/evm-exporter-darwin-amd64-${{ steps.sha.outputs.sha }}
GOOS=darwin GOARCH=arm64 go build -o release/evm-exporter-darwin-arm64-${{ steps.sha.outputs.sha }}
GOOS=windows GOARCH=amd64 go build -o release/evm-exporter-windows-amd64-${{ steps.sha.outputs.sha }}.exe
- name: Upload to GitHub Packages
uses: actions/upload-artifact@v3
with:
name: binaries
path: release/*
- name: Publish to GitHub Packages
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for file in release/*; do
gh release upload "commit-${{ steps.sha.outputs.sha }}" "$file" --clobber || gh release create "commit-${{ steps.sha.outputs.sha }}" "$file"
done
23 changes: 19 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,22 @@ on:
- 'go.sum'

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.1'

- name: Run tests
run: go test -v ./...

release:
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down Expand Up @@ -38,10 +53,10 @@ jobs:
- name: Build Binaries
run: |
mkdir -p release
GOOS=linux GOARCH=amd64 go build -o release/berachain-exporter-linux-amd64
GOOS=darwin GOARCH=amd64 go build -o release/berachain-exporter-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -o release/berachain-exporter-darwin-arm64
GOOS=windows GOARCH=amd64 go build -o release/berachain-exporter-windows-amd64.exe
GOOS=linux GOARCH=amd64 go build -o release/evm-exporter-linux-amd64
GOOS=darwin GOARCH=amd64 go build -o release/evm-exporter-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -o release/evm-exporter-darwin-arm64
GOOS=windows GOARCH=amd64 go build -o release/evm-exporter-windows-amd64.exe
- name: Install semantic-release
run: npm install @semantic-release/git @semantic-release/changelog @semantic-release/exec conventional-changelog-conventionalcommits
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Berachain Block Exporter
# Cosmos EVM Exporter

A monitoring tool that tracks block production on Berachain's consensus and execution layers, specifically designed to monitor validator block proposals and their corresponding execution blocks.
A monitoring tool that tracks block production on Cosmos EVM chains consensus and execution layers, specifically designed to monitor validator block proposals and their corresponding execution blocks.

## Features

Expand Down Expand Up @@ -46,10 +46,10 @@ enable_stdout = true # Enable console logging
go run main.go --config=./config.toml

# Build binary
go build -o berachain-exporter
go build -o evm-exporter

# Run binary
./berachain-exporter --config=./config.toml
./evm-exporter --config=./config.toml
```

## Metrics Endpoint
Expand All @@ -59,7 +59,7 @@ Prometheus metrics are available at `http://localhost:2113/metrics`
## Requirements

- Go 1.22.1 or later
- Access to Berachain RPC endpoints
- Access to Cosmos & Ethereum RPC endpoints

## Dependencies

Expand All @@ -79,7 +79,7 @@ git clone [repository-url]
go mod download

# Build
go build -o berachain-exporter
go build -o evm-exporter
```

## Example Output
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module blockchecker
module evm-exporter

go 1.22.1

Expand Down
Loading

0 comments on commit 6d93e67

Please sign in to comment.