Skip to content

Dockerize go lint and tests#4765

Draft
johnsaigle wants to merge 6 commits into
wormhole-foundation:mainfrom
johnsaigle:dockerize-go-lint-and-tests
Draft

Dockerize go lint and tests#4765
johnsaigle wants to merge 6 commits into
wormhole-foundation:mainfrom
johnsaigle:dockerize-go-lint-and-tests

Conversation

@johnsaigle

@johnsaigle johnsaigle commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

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 (e.g. by installing go or golangci-lint
via something like brew or apt).

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 (its golangci-lint version was very out-of-date)
  • adds cspell to that container
  • adds make targets for each of these
  • updates goimports to use the latest version that supports Go 1.24

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.


See also #4701 as this PR is now failing with lints related to that version.

@johnsaigle johnsaigle force-pushed the dockerize-go-lint-and-tests branch from 46983c5 to 5c4d726 Compare April 24, 2026 14:16
@johnsaigle johnsaigle marked this pull request as ready for review April 24, 2026 14:27
@johnsaigle

Copy link
Copy Markdown
Contributor Author

Note: this PR should ideally be kept in sync with the golangci-lint version here: #4701

@johnsaigle johnsaigle force-pushed the dockerize-go-lint-and-tests branch from 758686d to 93bfc4f Compare May 1, 2026 18:15
Comment thread Dockerfile.lint

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Mind just adding a one-liner comment describing the command. Could probably split it up into three commands.

Comment thread Dockerfile.unit
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Add a comment

pleasew8t
pleasew8t previously approved these changes May 5, 2026

@pleasew8t pleasew8t left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran both the lint and unit test Makefile commands, and it works fine. It would be nice to have the lint command clean itself up (I see the unit test docker command uses --rm, can lint do this as well?).

@djb15 djb15 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestions, looks ok otherwise

Comment thread .github/workflows/build.yml Outdated
Comment thread Dockerfile.lint Outdated
@johnsaigle johnsaigle force-pushed the dockerize-go-lint-and-tests branch 2 times, most recently from 868ede3 to c6532d4 Compare May 21, 2026 15:31
@johnsaigle johnsaigle marked this pull request as draft May 21, 2026 15:33
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.
@johnsaigle johnsaigle force-pushed the dockerize-go-lint-and-tests branch from c6532d4 to 6e1c644 Compare May 28, 2026 18:24
@johnsaigle

Copy link
Copy Markdown
Contributor Author

Converting to draft mode as this has potential sequencing conflicts with other open PRs. See #4701 (comment) for more details. cc: @mdulin2

@johnsaigle johnsaigle mentioned this pull request May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants