-
Notifications
You must be signed in to change notification settings - Fork 856
Dockerize go lint and tests #4765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
johnsaigle
wants to merge
6
commits into
wormhole-foundation:main
Choose a base branch
from
johnsaigle:dockerize-go-lint-and-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
065c89d
update goimports to latest that supports go 1.24
johnsaigle ae3fd5c
test: Dockerize unit tests and lints for Go
johnsaigle 91b3ff3
update codeowners
johnsaigle 8be28b4
code review changes
johnsaigle e918992
Use fixed commit hashes for go tools
johnsaigle 6e1c644
code comment; sync with node/go.mod
johnsaigle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # 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 | ||
|
|
||
| # 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 | ||
| 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 | ||
|
|
||
| # 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; commit is v0.42.0) | ||
| RUN go install golang.org/x/tools/cmd/goimports@009367f5c17a8d4c45a961a3a509277190a9a6f0 | ||
|
|
||
| # install golangci-lint (pinned to match CI) | ||
| 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 | ||
|
|
||
| USER 1000 | ||
| WORKDIR /home/lint | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2 | ||
| # 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Add a comment |
||
|
|
||
| WORKDIR /app | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.