Skip to content

Commit e02310c

Browse files
committed
ops: golang ci improvements
1 parent 7591f19 commit e02310c

36 files changed

+588
-396
lines changed

.circleci/config.yml

Lines changed: 333 additions & 124 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
COMPOSEFLAGS=-d
22
ITESTS_L2_HOST=http://localhost:9545
33
BEDROCK_TAGS_REMOTE?=origin
4+
OP_STACK_GO_BUILDER?=us-docker.pkg.dev/oplabs-tools-artifacts/images/op_stack_go:latest
45

56
build: build-go build-ts
67
.PHONY: build
78

89
build-go: submodules op-node op-proposer op-batcher
910
.PHONY: build-go
1011

12+
lint-go:
13+
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./...
14+
.PHONY: lint-go
15+
1116
build-ts: submodules
1217
if [ -n "$$NVM_DIR" ]; then \
1318
. $$NVM_DIR/nvm.sh && nvm use; \
@@ -19,6 +24,13 @@ build-ts: submodules
1924
ci-builder:
2025
docker build -t ci-builder -f ops/docker/ci-builder/Dockerfile .
2126

27+
golang-docker:
28+
DOCKER_BUILDKIT=1 docker build -t op-stack-go \
29+
--build-arg GIT_COMMIT=$$(git rev-parse HEAD) \
30+
--build-arg GIT_DATE=$$(git show -s --format='%ct') \
31+
-f ops/docker/op-stack-go/Dockerfile .
32+
.PHONY: golang-docker
33+
2234
submodules:
2335
# CI will checkout submodules on its own (and fails on these commands)
2436
if [ -z "$$GITHUB_ENV" ]; then \
@@ -163,4 +175,10 @@ bedrock-markdown-links:
163175
--exclude-mail /input/README.md "/input/specs/**/*.md"
164176

165177
install-geth:
166-
go install github.com/ethereum/go-ethereum/cmd/geth@$(shell cat .gethrc)
178+
./ops/scripts/geth-version-checker.sh && \
179+
(echo "Geth versions match, not installing geth..."; true) || \
180+
(echo "Versions do not match, installing geth!"; \
181+
go install -v github.com/ethereum/go-ethereum/cmd/geth@$(shell cat .gethrc); \
182+
echo "Installed geth!"; true)
183+
.PHONY: install-geth
184+

bedrock-devnet/devnet/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ def main():
9696

9797
log.info('Building docker images')
9898
run_command(['docker', 'compose', 'build', '--progress', 'plain'], cwd=paths.ops_bedrock_dir, env={
99-
'PWD': paths.ops_bedrock_dir
99+
'PWD': paths.ops_bedrock_dir,
100+
'DOCKER_BUILDKIT': '1', # (should be available by default in later versions, but explicitly enable it anyway)
101+
'COMPOSE_DOCKER_CLI_BUILD': '1' # use the docker cache
100102
})
101103

102104
log.info('Devnet starting')

cannon/Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
GITCOMMIT := $(shell git rev-parse HEAD)
2-
GITDATE := $(shell git show -s --format='%ct')
1+
GITCOMMIT ?= $(shell git rev-parse HEAD)
2+
GITDATE ?= $(shell git show -s --format='%ct')
33
VERSION := v0.0.0
44

55
LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT)
@@ -20,9 +20,6 @@ elf:
2020
test: elf
2121
go test -v ./...
2222

23-
lint:
24-
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is"
25-
2623
fuzz:
2724
go test -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzStateSyscallBrk ./mipsevm
2825
go test -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzStateSyscallClone ./mipsevm

endpoint-monitor/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
GITCOMMIT := $(shell git rev-parse HEAD)
2-
GITDATE := $(shell git show -s --format='%ct')
1+
GITCOMMIT ?= $(shell git rev-parse HEAD)
2+
GITDATE ?= $(shell git show -s --format='%ct')
33
VERSION := v0.0.0
44

55
LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT)

op-batcher/Dockerfile

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,9 @@
1-
FROM --platform=$BUILDPLATFORM golang:1.21.1-alpine3.18 as builder
2-
3-
ARG VERSION=v0.0.0
4-
5-
RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash
6-
7-
COPY ./go.mod /app/go.mod
8-
COPY ./go.sum /app/go.sum
9-
10-
WORKDIR /app
11-
12-
RUN go mod download
13-
14-
# build op-batcher with the shared go.mod & go.sum files
15-
COPY ./op-batcher /app/op-batcher
16-
COPY ./op-bindings /app/op-bindings
17-
COPY ./op-node /app/op-node
18-
COPY ./op-service /app/op-service
19-
20-
COPY ./.git /app/.git
21-
22-
WORKDIR /app/op-batcher
23-
24-
ARG TARGETOS TARGETARCH
25-
26-
RUN make op-batcher VERSION="$VERSION" GOOS=$TARGETOS GOARCH=$TARGETARCH
1+
ARG OP_STACK_GO_BUILDER=us-docker.pkg.dev/oplabs-tools-artifacts/images/op_stack_go:latest
2+
FROM $OP_STACK_GO_BUILDER as builder
3+
# See "make golang-docker" and /ops/docker/op-stack-go
274

285
FROM alpine:3.18
296

30-
COPY --from=builder /app/op-batcher/bin/op-batcher /usr/local/bin
7+
COPY --from=builder /usr/local/bin/op-batcher /usr/local/bin/op-batcher
318

32-
ENTRYPOINT ["op-batcher"]
9+
CMD ["op-batcher"]

op-batcher/Dockerfile.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# ignore everything but the dockerfile, the op-stack-go base image performs the build
2+
*

op-batcher/Makefile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
GITCOMMIT := $(shell git rev-parse HEAD)
2-
GITDATE := $(shell git show -s --format='%ct')
1+
GITCOMMIT ?= $(shell git rev-parse HEAD)
2+
GITDATE ?= $(shell git show -s --format='%ct')
33
VERSION := v0.0.0
44

55
LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT)
@@ -16,9 +16,6 @@ clean:
1616
test:
1717
go test -v ./...
1818

19-
lint:
20-
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./...
21-
2219
fuzz:
2320
go test -run NOTAREALTEST -v -fuzztime 10s -fuzz FuzzChannelConfig_CheckTimeout ./batcher
2421
go test -run NOTAREALTEST -v -fuzztime 10s -fuzz FuzzDurationZero ./batcher
@@ -33,5 +30,4 @@ fuzz:
3330
op-batcher \
3431
clean \
3532
test \
36-
lint \
3733
fuzz

op-bindings/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ bindings-build:
2626
-package $(pkg) \
2727
-monorepo-base $(monorepo-base)
2828

29-
lint:
30-
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./...
31-
3229
mkdir:
3330
mkdir -p $(pkg)
3431

op-bootnode/Makefile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
GITCOMMIT := $(shell git rev-parse HEAD)
2-
GITDATE := $(shell git show -s --format='%ct')
1+
GITCOMMIT ?= $(shell git rev-parse HEAD)
2+
GITDATE ?= $(shell git show -s --format='%ct')
33
VERSION := v0.0.0
44

55
LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT)
@@ -16,11 +16,7 @@ clean:
1616
test:
1717
go test -v ./...
1818

19-
lint:
20-
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./...
21-
2219
.PHONY: \
2320
op-bootnode \
2421
clean \
25-
test \
26-
lint
22+
test

op-chain-ops/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ check-l2:
66
test:
77
go test ./...
88

9-
lint:
10-
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./...
11-
129
fuzz:
1310
go test -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzEncodeDecodeWithdrawal ./crossdomain
1411
go test -run NOTAREALTEST -v -fuzztime 10s -fuzz=FuzzEncodeDecodeLegacyWithdrawal ./crossdomain

op-challenger/Dockerfile

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,17 @@
1-
FROM --platform=$BUILDPLATFORM golang:1.21.1-alpine3.18 as builder
2-
3-
ARG VERSION=v0.0.0
4-
5-
RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash
6-
7-
COPY ./go.mod /app/go.mod
8-
COPY ./go.sum /app/go.sum
9-
10-
WORKDIR /app
11-
12-
RUN go mod download
13-
14-
# build op-challenger with the shared go.mod & go.sum files
15-
COPY ./op-challenger /app/op-challenger
16-
COPY ./op-program /app/op-program
17-
COPY ./op-preimage /app/op-preimage
18-
COPY ./op-bindings /app/op-bindings
19-
COPY ./op-node /app/op-node
20-
COPY ./op-service /app/op-service
21-
COPY ./.git /app/.git
22-
23-
# Copy cannon and its dependencies
24-
COPY ./cannon /app/cannon
25-
COPY ./op-preimage /app/op-preimage
26-
COPY ./op-chain-ops /app/op-chain-ops
27-
28-
WORKDIR /app/op-program
29-
30-
ARG TARGETOS TARGETARCH
31-
32-
RUN make op-program-host VERSION="$VERSION" GOOS=$TARGETOS GOARCH=$TARGETARCH
33-
34-
WORKDIR /app/cannon
35-
36-
ARG TARGETOS TARGETARCH
37-
38-
RUN make cannon VERSION="$VERSION" GOOS=$TARGETOS GOARCH=$TARGETARCH
39-
40-
WORKDIR /app/op-challenger
41-
42-
RUN make op-challenger VERSION="$VERSION" GOOS=$TARGETOS GOARCH=$TARGETARCH
1+
ARG OP_STACK_GO_BUILDER=us-docker.pkg.dev/oplabs-tools-artifacts/images/op_stack_go:latest
2+
FROM $OP_STACK_GO_BUILDER as builder
3+
# See "make golang-docker" and /ops/docker/op-stack-go
434

445
FROM alpine:3.18
456

467
# Make the bundled op-program the default cannon server
47-
COPY --from=builder /app/op-program/bin/op-program /usr/local/bin
8+
COPY --from=builder /usr/local/bin/op-program /usr/local/bin/op-program
489
ENV OP_CHALLENGER_CANNON_SERVER /usr/local/bin/op-program
4910

5011
# Make the bundled cannon the default cannon executable
51-
COPY --from=builder /app/cannon/bin/cannon /usr/local/bin
12+
COPY --from=builder /usr/local/bin/cannon /usr/local/bin/cannon
5213
ENV OP_CHALLENGER_CANNON_BIN /usr/local/bin/cannon
5314

54-
COPY --from=builder /app/op-challenger/bin/op-challenger /usr/local/bin
15+
COPY --from=builder /usr/local/bin/op-challenger /usr/local/bin/op-challenger
5516

5617
CMD ["op-challenger"]

op-challenger/Dockerfile.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# ignore everything but the dockerfile, the op-stack-go base image performs the build
2+
*

op-challenger/Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
GITCOMMIT := $(shell git rev-parse HEAD)
2-
GITDATE := $(shell git show -s --format='%ct')
1+
GITCOMMIT ?= $(shell git rev-parse HEAD)
2+
GITDATE ?= $(shell git show -s --format='%ct')
33
VERSION := v0.0.0
44

55
LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT)
@@ -16,9 +16,6 @@ clean:
1616
test:
1717
go test -v ./...
1818

19-
lint:
20-
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./...
21-
2219
visualize:
2320
./scripts/visualize.sh
2421

op-e2e/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,3 @@ clean:
5151
rm -r ../.devnet
5252
rm -r ../op-program/bin
5353
.PHONY: clean
54-
55-
lint:
56-
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./...
57-
.PHONY: lint

op-heartbeat/Dockerfile

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
1-
FROM golang:1.21.1-alpine3.18 as builder
2-
3-
RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash
4-
5-
# build op-heartbeat with local monorepo go modules
6-
COPY ./op-heartbeat /app/op-heartbeat
7-
COPY ./op-node /app/op-node
8-
COPY ./op-service /app/op-service
9-
COPY ./go.mod /app/go.mod
10-
COPY ./go.sum /app/go.sum
11-
12-
COPY ./.git /app/.git
13-
14-
WORKDIR /app/op-heartbeat
15-
16-
RUN make op-heartbeat
1+
ARG OP_STACK_GO_BUILDER=us-docker.pkg.dev/oplabs-tools-artifacts/images/op_stack_go:latest
2+
FROM $OP_STACK_GO_BUILDER as builder
3+
# See "make golang-docker" and /ops/docker/op-stack-go
174

185
FROM alpine:3.18
196

20-
COPY --from=builder /app/op-heartbeat/bin/op-heartbeat /usr/local/bin
7+
COPY --from=builder /usr/local/bin/op-heartbeat /usr/local/bin/op-heartbeat
218

229
CMD ["op-heartbeat"]

op-heartbeat/Dockerfile.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# ignore everything but the dockerfile, the op-stack-go base image performs the build
2+
*

op-heartbeat/Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
GITCOMMIT := $(shell git rev-parse HEAD)
2-
GITDATE := $(shell git show -s --format='%ct')
1+
GITCOMMIT ?= $(shell git rev-parse HEAD)
2+
GITDATE ?= $(shell git show -s --format='%ct')
33
VERSION := v0.0.0
44

55
LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT)
@@ -16,9 +16,6 @@ clean:
1616
test:
1717
go test -v ./...
1818

19-
lint:
20-
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./...
21-
2219
.PHONY: \
2320
clean \
2421
op-heartbeat \

op-node/Dockerfile

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,9 @@
1-
FROM --platform=$BUILDPLATFORM golang:1.21.1-alpine3.18 as builder
2-
3-
ARG VERSION=v0.0.0
4-
5-
RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash
6-
7-
COPY ./go.mod /app/go.mod
8-
COPY ./go.sum /app/go.sum
9-
10-
WORKDIR /app
11-
12-
RUN go mod download
13-
14-
# build op-node with the shared go.mod & go.sum files
15-
COPY ./op-node /app/op-node
16-
COPY ./op-chain-ops /app/op-chain-ops
17-
COPY ./op-service /app/op-service
18-
COPY ./op-bindings /app/op-bindings
19-
COPY ./.git /app/.git
20-
21-
WORKDIR /app/op-node
22-
23-
ARG TARGETOS TARGETARCH
24-
25-
RUN make op-node VERSION="$VERSION" GOOS=$TARGETOS GOARCH=$TARGETARCH
1+
ARG OP_STACK_GO_BUILDER=us-docker.pkg.dev/oplabs-tools-artifacts/images/op_stack_go:latest
2+
FROM $OP_STACK_GO_BUILDER as builder
3+
# See "make golang-docker" and /ops/docker/op-stack-go
264

275
FROM alpine:3.18
286

29-
COPY --from=builder /app/op-node/bin/op-node /usr/local/bin
7+
COPY --from=builder /usr/local/bin/op-node /usr/local/bin/op-node
308

319
CMD ["op-node"]

op-node/Dockerfile.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# ignore everything but the dockerfile, the op-stack-go base image performs the build
2+
*

op-node/Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
GITCOMMIT := $(shell git rev-parse HEAD)
2-
GITDATE := $(shell git show -s --format='%ct')
1+
GITCOMMIT ?= $(shell git rev-parse HEAD)
2+
GITDATE ?= $(shell git show -s --format='%ct')
33
VERSION := v0.0.0
44

55
LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT)
@@ -17,9 +17,6 @@ clean:
1717
test:
1818
go test -v ./...
1919

20-
lint:
21-
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./...
22-
2320
fuzz:
2421
go test -run NOTAREALTEST -v -fuzztime 10s -fuzz FuzzL1InfoRoundTrip ./rollup/derive
2522
go test -run NOTAREALTEST -v -fuzztime 10s -fuzz FuzzL1InfoAgainstContract ./rollup/derive

0 commit comments

Comments
 (0)