From 065c89d5a625e1ae85f0fa48f27c5d8256b9f93b Mon Sep 17 00:00:00 2001 From: John Saigle Date: Fri, 24 Apr 2026 09:53:07 -0400 Subject: [PATCH 1/6] update goimports to latest that supports go 1.24 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 627a2caaf6e..ee4bb5ffa8e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -303,7 +303,7 @@ jobs: with: go-version: "1.25.10" - name: Install formatter - run: go install golang.org/x/tools/cmd/goimports@v0.8.0 + run: go install golang.org/x/tools/cmd/goimports@v0.42.0 - name: Formatting checks run: ./scripts/lint.sh -l -g format - name: Install linters From ae3fd5c58bffc372f5316fb6a6bcb7cb984d06c6 Mon Sep 17 00:00:00 2001 From: John Saigle Date: Fri, 24 Apr 2026 10:10:54 -0400 Subject: [PATCH 2/6] test: Dockerize unit tests and lints for Go Wormhole is using go 1.24 as well as a slightly out of date version of golangci-lint. This can make it annoying to run unit tests, code coverage tools, or linting locally assuming that a dev wants to use more recent toolchains on their system. This commit - adds a new Dockerfile for running unit tests and test coverage tools - modifies the local Dockerfile for linting to be up-to-date - adds cspell to that container - adds `make` targets for each of these All of this should make it easier for devs to run tests/linting locally without needing to specify extra flags like `GOTOOLCHAIN=1.24.13` It also adds a few more safe entries to `.dockerignore`, though this should not affect the new Dockerfiles or the other ones in the repo, given that they don't use `COPY .` This commit also slightly bumps the sleep duration in the altpub tests as it is more likely to run too slowly to complete properly within a container. Ideally the test would be refactored to not use sleep, but that's not in-scope. --- .dockerignore | 6 ++++++ Dockerfile.lint | 29 +++++++++++++++++++++++++++++ Dockerfile.unit | 9 +++++++++ Makefile | 29 +++++++++++++++++++++++++++++ scripts/Dockerfile.lint | 13 ------------- scripts/lint.sh | 2 +- 6 files changed, 74 insertions(+), 14 deletions(-) create mode 100644 Dockerfile.lint create mode 100644 Dockerfile.unit delete mode 100644 scripts/Dockerfile.lint diff --git a/.dockerignore b/.dockerignore index 78f7b804172..7233cf16441 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,5 +2,11 @@ target bin **/target **/node_modules +.git +.github +.DS_Store +coverage-check +coverage.txt wormchain/build/config/gentx/ +.DS_Store diff --git a/Dockerfile.lint b/Dockerfile.lint new file mode 100644 index 00000000000..77e0d73058d --- /dev/null +++ b/Dockerfile.lint @@ -0,0 +1,29 @@ +# syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2 +FROM node:22.16-bullseye-slim@sha256:550b434f7edc3a1875860657a3e306752358029c957280809ae6395ab296faeb AS node-tools + +RUN npm install -g cspell@9.8.0 + +FROM docker.io/golang:1.24.13-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890540ce6173ea77ac + +ENV GOPATH=/tmp/go +ENV GOCACHE=/tmp/go-build +ENV PATH=/tmp/go/bin:$PATH + +COPY --from=node-tools /usr/local/bin/node /usr/local/bin/node +COPY --from=node-tools /usr/local/lib/node_modules /usr/local/lib/node_modules + +RUN ln -s /usr/local/lib/node_modules/cspell/bin.mjs /usr/local/bin/cspell + +RUN useradd -u 1000 -U -m -d /home/lint lint && mkdir -p /tmp/go /tmp/go-build && chmod -R 1777 /tmp/go /tmp/go-build + +# install goimports (pinned to match CI) +RUN go install golang.org/x/tools/cmd/goimports@v0.42.0 + +# install golangci-lint (pinned to match CI) +RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \ + sh -s -- -b $(go env GOPATH)/bin v2.8.0 + +RUN chmod -R 1777 /tmp/go /tmp/go-build + +USER 1000 +WORKDIR /home/lint diff --git a/Dockerfile.unit b/Dockerfile.unit new file mode 100644 index 00000000000..d2b15e7586d --- /dev/null +++ b/Dockerfile.unit @@ -0,0 +1,9 @@ +# syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2 +FROM docker.io/golang:1.24.13-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890540ce6173ea77ac + +ENV GOPATH=/tmp/go +ENV GOCACHE=/tmp/go-build + +RUN mkdir -p /tmp/go /tmp/go-build && chmod -R 1777 /tmp/go /tmp/go-build + +WORKDIR /app diff --git a/Makefile b/Makefile index b478e809749..ce575b6dfe5 100755 --- a/Makefile +++ b/Makefile @@ -8,6 +8,8 @@ MAKEFLAGS += --no-builtin-rules PREFIX ?= /usr/local OUT = build BIN = $(OUT)/bin +UNIT_DOCKER_IMAGE ?= wormhole-unit-test +UNIT_DOCKER_RUN = docker run --rm --workdir /app --user "$$(id -u):$$(id -g)" --mount type=bind,source=$(CURDIR),target=/app $(UNIT_DOCKER_IMAGE) -include Makefile.help @@ -36,11 +38,33 @@ lint: # Lints spelling and Go bash scripts/lint.sh lint +.PHONY: lint-docker +## Run Go lints in Docker +lint-docker: + bash scripts/lint.sh -c lint + .PHONY: lint-rust lint-rust: # Runs clippy for most Rust crates. bash scripts/clippy.sh +.PHONY: build-unit-docker +## Build the unit test container used for node/sdk Go tests +build-unit-docker: + DOCKER_BUILDKIT=1 docker build -f Dockerfile.unit -t $(UNIT_DOCKER_IMAGE) . + +.PHONY: test-unit +## Run node and sdk Go unit tests +test-unit: + @echo "Running unit tests for node and sdk..." + @cd node && go test -count=1 -v -timeout 5m -race ./... + @cd sdk && go test -count=1 -v -timeout 5m -race ./... + +.PHONY: test-docker +## Run node and sdk Go unit tests in Docker +test-docker: build-unit-docker + $(UNIT_DOCKER_RUN) make test-unit + .PHONY: node ## Build guardiand binary node: $(BIN)/guardiand @@ -59,6 +83,11 @@ test-coverage: @set -o pipefail && (cd node && go test -count=1 -v -timeout 5m -race -cover ./...) 2>&1 | tee coverage.txt @set -o pipefail && (cd sdk && go test -count=1 -v -timeout 5m -race -cover ./...) 2>&1 | tee -a coverage.txt +.PHONY: test-coverage-docker +## Run test-coverage in Docker +test-coverage-docker: build-unit-docker + $(UNIT_DOCKER_RUN) make test-coverage + .PHONY: check-coverage ## Check coverage against baseline (run tests first) check-coverage: build-coverage-check test-coverage diff --git a/scripts/Dockerfile.lint b/scripts/Dockerfile.lint deleted file mode 100644 index a66f32d0648..00000000000 --- a/scripts/Dockerfile.lint +++ /dev/null @@ -1,13 +0,0 @@ -# syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2 -FROM docker.io/golang:1.25.10-bookworm@sha256:154bd7001b6eb339e88c964442c0ad6ed5e53f09844cc818a41ce4ecb3ce3b43 - -RUN useradd -u 1000 -U -m -d /home/lint lint -USER 1000 -WORKDIR /home/lint - -# install goimports -RUN go install golang.org/x/tools/cmd/goimports@latest - -# install golangci-lint -RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \ - sh -s -- -b $(go env GOPATH)/bin v1.52.2 diff --git a/scripts/lint.sh b/scripts/lint.sh index da82a8b4b2e..43e4cd055e8 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -4,7 +4,7 @@ set -eo pipefail -o nounset ROOT="$(dirname "$(dirname "$(realpath "$0")")")" -DOCKERFILE="$ROOT/scripts/Dockerfile.lint" +DOCKERFILE="$ROOT/Dockerfile.lint" VALID_COMMANDS=("lint" "format") From 91b3ff319cc050b3dd62135fa02a4a704e9675a8 Mon Sep 17 00:00:00 2001 From: John Saigle Date: Fri, 24 Apr 2026 10:18:27 -0400 Subject: [PATCH 3/6] update codeowners --- .github/CODEOWNERS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 404aa953933..d5f6bb38755 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -185,3 +185,6 @@ scripts/coverage-check @evan-gray @kcsongor @johnsaigle @mdulin2 @pleasew8t @bem ## CI .golangci.yml @evan-gray @djb15 @johnsaigle @mdulin2 cspell* @evan-gray @kcsongor @panoel @djb15 @SEJeff @johnsaigle @mdulin2 @pleasew8t @bemic +Dockerfile.unit @evan-gray @panoel @djb15 @SEJeff @johnsaigle @mdulin2 @pleasew8t @bemic +Dockerfile.lint @evan-gray @panoel @djb15 @SEJeff @johnsaigle @mdulin2 @pleasew8t @bemic +.dockerignore @evan-gray @panoel @djb15 @SEJeff @johnsaigle @mdulin2 @pleasew8t @bemic From 8be28b4cbf749cdf132ba1e83e226c460df7f56b Mon Sep 17 00:00:00 2001 From: John Saigle Date: Wed, 6 May 2026 07:48:11 -0400 Subject: [PATCH 4/6] code review changes --- Dockerfile.lint | 5 +++++ Dockerfile.unit | 2 ++ scripts/lint.sh | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Dockerfile.lint b/Dockerfile.lint index 77e0d73058d..4b588dd2c51 100644 --- a/Dockerfile.lint +++ b/Dockerfile.lint @@ -5,6 +5,7 @@ RUN npm install -g cspell@9.8.0 FROM docker.io/golang:1.24.13-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890540ce6173ea77ac +# Direct Go module/state under /tmp so the non-root user can write to it. ENV GOPATH=/tmp/go ENV GOCACHE=/tmp/go-build ENV PATH=/tmp/go/bin:$PATH @@ -14,6 +15,9 @@ COPY --from=node-tools /usr/local/lib/node_modules /usr/local/lib/node_modules RUN ln -s /usr/local/lib/node_modules/cspell/bin.mjs /usr/local/bin/cspell +# Create a non-root user for the lint container (matches host UID convention). +# Direct Go caches to /tmp with world-writable perms so goimports/golangci-lint +# can download modules at runtime regardless of user. RUN useradd -u 1000 -U -m -d /home/lint lint && mkdir -p /tmp/go /tmp/go-build && chmod -R 1777 /tmp/go /tmp/go-build # install goimports (pinned to match CI) @@ -23,6 +27,7 @@ RUN go install golang.org/x/tools/cmd/goimports@v0.42.0 RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \ sh -s -- -b $(go env GOPATH)/bin v2.8.0 +# Re-apply perms after go install wrote into /tmp/go as root. RUN chmod -R 1777 /tmp/go /tmp/go-build USER 1000 diff --git a/Dockerfile.unit b/Dockerfile.unit index d2b15e7586d..3d468313ea7 100644 --- a/Dockerfile.unit +++ b/Dockerfile.unit @@ -1,6 +1,8 @@ # syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2 FROM docker.io/golang:1.24.13-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890540ce6173ea77ac +# Direct Go module/state under /tmp because the container runs as an arbitrary host UID, +# which cannot write to the default /go owned by root. ENV GOPATH=/tmp/go ENV GOCACHE=/tmp/go-build diff --git a/scripts/lint.sh b/scripts/lint.sh index 43e4cd055e8..da83a7502b6 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -147,7 +147,7 @@ if [ "$DOCKER" == "true" ]; then if ! [[ "$GOIMPORTS_ARGS" =~ "w" ]]; then MOUNT+=",readonly" fi - docker run --workdir /app "$MOUNT" "$DOCKER_IMAGE" "$DOCKER_EXEC" $SELF_ARGS_WITHOUT_DOCKER "$COMMAND" + docker run --rm --workdir /app "$MOUNT" "$DOCKER_IMAGE" "$DOCKER_EXEC" $SELF_ARGS_WITHOUT_DOCKER "$COMMAND" exit "$?" fi From e91899208d9b5318cad6268f3b9e01bab22a7b0e Mon Sep 17 00:00:00 2001 From: John Saigle Date: Wed, 20 May 2026 15:45:26 -0400 Subject: [PATCH 5/6] Use fixed commit hashes for go tools --- .github/workflows/build.yml | 4 ++-- Dockerfile.lint | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee4bb5ffa8e..46803a1fef5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -303,11 +303,11 @@ jobs: with: go-version: "1.25.10" - name: Install formatter - run: go install golang.org/x/tools/cmd/goimports@v0.42.0 + run: go install golang.org/x/tools/cmd/goimports@009367f5c17a8d4c45a961a3a509277190a9a6f0 # v0.42.0 - name: Formatting checks run: ./scripts/lint.sh -l -g format - name: Install linters - run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.8.0 + run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@c0d3ddc9cf3faa61a4e378e879ece580256d76e5 # v2.12.2 - name: Run linters run: make generate && golangci-lint --version && ./scripts/lint.sh -g lint - name: Ensure generated proto matches diff --git a/Dockerfile.lint b/Dockerfile.lint index 4b588dd2c51..3ed0f66a404 100644 --- a/Dockerfile.lint +++ b/Dockerfile.lint @@ -20,12 +20,11 @@ RUN ln -s /usr/local/lib/node_modules/cspell/bin.mjs /usr/local/bin/cspell # can download modules at runtime regardless of user. RUN useradd -u 1000 -U -m -d /home/lint lint && mkdir -p /tmp/go /tmp/go-build && chmod -R 1777 /tmp/go /tmp/go-build -# install goimports (pinned to match CI) -RUN go install golang.org/x/tools/cmd/goimports@v0.42.0 +# install goimports (pinned to match CI; commit is v0.42.0) +RUN go install golang.org/x/tools/cmd/goimports@009367f5c17a8d4c45a961a3a509277190a9a6f0 # install golangci-lint (pinned to match CI) -RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \ - sh -s -- -b $(go env GOPATH)/bin v2.8.0 +RUN go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@c0d3ddc9cf3faa61a4e378e879ece580256d76e5 # Re-apply perms after go install wrote into /tmp/go as root. RUN chmod -R 1777 /tmp/go /tmp/go-build From 6e1c644f44a352101f7eb83c6379546da742ec48 Mon Sep 17 00:00:00 2001 From: John Saigle Date: Thu, 28 May 2026 14:23:54 -0400 Subject: [PATCH 6/6] code comment; sync with node/go.mod --- Dockerfile.lint | 3 ++- Dockerfile.unit | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile.lint b/Dockerfile.lint index 3ed0f66a404..7c81e22145a 100644 --- a/Dockerfile.lint +++ b/Dockerfile.lint @@ -3,7 +3,8 @@ FROM node:22.16-bullseye-slim@sha256:550b434f7edc3a1875860657a3e306752358029c957 RUN npm install -g cspell@9.8.0 -FROM docker.io/golang:1.24.13-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890540ce6173ea77ac +# keep Go version in sync with node/go.mod +FROM docker.io/golang:1.25.10-bookworm@sha256:154bd7001b6eb339e88c964442c0ad6ed5e53f09844cc818a41ce4ecb3ce3b43 # Direct Go module/state under /tmp so the non-root user can write to it. ENV GOPATH=/tmp/go diff --git a/Dockerfile.unit b/Dockerfile.unit index 3d468313ea7..0cea08f936f 100644 --- a/Dockerfile.unit +++ b/Dockerfile.unit @@ -1,11 +1,14 @@ # syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2 -FROM docker.io/golang:1.24.13-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890540ce6173ea77ac +# keep Go version in sync with node/go.mod +FROM docker.io/golang:1.25.10-bookworm@sha256:154bd7001b6eb339e88c964442c0ad6ed5e53f09844cc818a41ce4ecb3ce3b43 # Direct Go module/state under /tmp because the container runs as an arbitrary host UID, # which cannot write to the default /go owned by root. ENV GOPATH=/tmp/go ENV GOCACHE=/tmp/go-build +# Create Go cache dirs with world-writable sticky bit so that any user (including +# the host-mapped UID at runtime) can read and write module downloads and build cache. RUN mkdir -p /tmp/go /tmp/go-build && chmod -R 1777 /tmp/go /tmp/go-build WORKDIR /app