Skip to content

Commit 4f82468

Browse files
committed
refactor to single cmd entrypoint
1 parent e9ef84e commit 4f82468

16 files changed

Lines changed: 353 additions & 280 deletions

File tree

.github/workflows/checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
test:
1111
name: Test
12-
runs-on: ubuntu-latest
12+
runs-on: warp-ubuntu-latest-x64-32x
1313
steps:
1414
- name: Set up Go
1515
uses: actions/setup-go@v3
@@ -25,7 +25,7 @@ jobs:
2525

2626
lint:
2727
name: Lint
28-
runs-on: ubuntu-latest
28+
runs-on: warp-ubuntu-latest-x64-32x
2929
steps:
3030
- name: Set up Go
3131
uses: actions/setup-go@v3

.github/workflows/release.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010

1111
jobs:
1212
build_and_release:
13-
runs-on: ubuntu-latest
13+
runs-on: warp-ubuntu-latest-x64-32x
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v4
@@ -22,15 +22,12 @@ jobs:
2222
with:
2323
go-version: ^v1.24
2424

25-
- name: Build
26-
run: make build
27-
28-
# https://goreleaser.com/cmd/goreleaser_release/
25+
# https://github.com/goreleaser/goreleaser-action
2926
- name: Run GoReleaser
3027
uses: goreleaser/goreleaser-action@v6
3128
with:
3229
distribution: goreleaser
3330
version: "~> v2"
34-
args: release --config .goreleaser.yaml
31+
args: release --config .goreleaser.yaml --clean
3532
env:
3633
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
1-
# https://goreleaser.com/customization/release/
21
version: 2
2+
3+
# https://goreleaser.com/customization/builds/go/
34
builds:
4-
- skip: true
5+
- id: mempool-dumpster
6+
main: ./cmd/
7+
binary: mempool-dumpster
8+
9+
env:
10+
# Force build to be all Go.
11+
- CGO_ENABLED=0
12+
flags:
13+
# Remove all file system paths from the executable.
14+
- -trimpath
15+
ldflags:
16+
# Sets the value of the symbol.
17+
- -X github.com/flashbots/mempool-dumpster/common.Version={{.Version}}
18+
goos:
19+
- linux
20+
- darwin
21+
goarch:
22+
- amd64
23+
- arm64
24+
- riscv64
25+
ignore:
26+
- goos: darwin
27+
goarch: riscv64
28+
29+
# https://goreleaser.com/customization/release/
530
release:
631
draft: true
732
extra_files:
8-
- glob: ./build/*
33+
- glob: ./dist/mempool-dumpster*.tar.gz
34+
- glob: ./dist/mempool-dumpster*.txt
935
header: |
1036
# 🚀 Features
1137
# 🎄 Enhancements
1238
# 🐞 Notable bug fixes
39+
# 🔖 Version updates
1340
# 🎠 Community

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ RUN --mount=type=cache,target=/root/.cache/go-build go mod download
1212
# Now adding all the code and start building
1313
ADD . .
1414
ENV GOCACHE=/root/.cache/go-build
15-
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "-s -X main.version=${VERSION}" -v -o ./bin/collect cmd/collect/*
16-
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "-s -X main.version=${VERSION}" -v -o ./bin/merge cmd/merge/*
17-
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "-s -X main.version=${VERSION}" -v -o ./bin/analyze cmd/analyze/*
15+
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "-s -X github.com/flashbots/mempool-dumpster/common.Version=${VERSION}" -v -o ./bin/mempool-dumpster cmd/main.go
1816

1917
FROM alpine:latest
2018
WORKDIR /app
2119
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
2220
COPY --from=builder /build/bin/* /app/
23-
CMD ["/app/collect"]
21+
CMD ["/app/mempool-dumpster", "collect"]

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ v: ## Show the current version
1717
.PHONY: build
1818
build: clean-build ## build the binaries
1919
@mkdir -p build
20-
go build -trimpath -ldflags "-X main.version=${VERSION}" -v -o ./build/collect cmd/collect/*
21-
go build -trimpath -ldflags "-X main.version=${VERSION}" -v -o ./build/merge cmd/merge/*
22-
go build -trimpath -ldflags "-X main.version=${VERSION}" -v -o ./build/analyze cmd/analyze/*
23-
go build -trimpath -ldflags "-X main.version=${VERSION}" -v -o ./build/website cmd/website/*
20+
go build -trimpath -ldflags "-X github.com/flashbots/mempool-dumpster/common.Version=${VERSION}" -v -o ./build/mempool-dumpster cmd/main.go
2421

2522
.PHONY: website
2623
website: ## Build the website and upload to R2

cmd/analyze/main.go

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package cmd_analyze //nolint:stylecheck
22

33
import (
44
"fmt"
@@ -9,16 +9,11 @@ import (
99
"github.com/urfave/cli/v2"
1010
"github.com/xitongsys/parquet-go-source/local"
1111
"github.com/xitongsys/parquet-go/reader"
12-
"go.uber.org/zap"
1312
)
1413

1514
var (
16-
version = "dev" // is set during build process
17-
debug = os.Getenv("DEBUG") == "1"
18-
maxTxs = common.GetEnvInt("MAX", 0) // 0 means no limit
19-
20-
// Helpers
21-
log *zap.SugaredLogger
15+
debug = os.Getenv("DEBUG") == "1"
16+
maxTxs = common.GetEnvInt("MAX", 0) // 0 means no limit
2217

2318
// CLI flags
2419
cliFlags = []cli.Flag{
@@ -34,41 +29,25 @@ var (
3429
Name: "out",
3530
Usage: "output filename",
3631
},
37-
// &cli.StringSliceFlag{
38-
// Name: "tx-blacklist",
39-
// Usage: "metadata CSV/ZIP input files with transactions to ignore in analysis",
40-
// },
41-
// &cli.StringSliceFlag{
42-
// Name: "tx-whitelist",
43-
// Usage: "metadata CSV/ZIP input files to only use transactions in there for analysis",
44-
// },
4532
&cli.StringSliceFlag{
4633
Name: "cmp",
4734
Usage: "compare these sources",
4835
},
4936
}
5037
)
5138

52-
func main() {
53-
log = common.GetLogger(debug, false)
54-
defer func() { _ = log.Sync() }()
55-
56-
app := &cli.App{
57-
Name: "analyze",
58-
Usage: "Analyze transaction and sourcelog files",
59-
Flags: cliFlags,
60-
Action: analyzeV2,
61-
}
62-
63-
if err := app.Run(os.Args); err != nil {
64-
log.Fatal(err)
65-
}
39+
var Command = cli.Command{
40+
Name: "analyze",
41+
Usage: "Analyze transaction and sourcelog files",
42+
Flags: cliFlags,
43+
Action: analyzeV2,
6644
}
6745

6846
func analyzeV2(cCtx *cli.Context) error {
47+
log := common.GetLogger(debug, false)
48+
defer func() { _ = log.Sync() }()
49+
6950
outFile := cCtx.String("out")
70-
// ignoreTxsFiles := cCtx.StringSlice("tx-blacklist")
71-
// whitelistTxsFiles := cCtx.StringSlice("tx-whitelist")
7251
parquetInputFiles := cCtx.StringSlice("input-parquet")
7352
inputSourceLogFiles := cCtx.StringSlice("input-sourcelog")
7453
cmpSources := cCtx.StringSlice("cmp")
@@ -81,7 +60,7 @@ func analyzeV2(cCtx *cli.Context) error {
8160
log.Fatal("no input-parquet files specified")
8261
}
8362

84-
log.Infow("Analyzer V2", "version", version)
63+
log.Infow("Analyzer V2", "version", common.Version)
8564
// log.Infow("Comparing:", "sources", sourceComps)
8665

8766
// Ensure output files are don't yet exist

0 commit comments

Comments
 (0)