-
Notifications
You must be signed in to change notification settings - Fork 1.3k
serving/samples: update helloworld-go to go:1.13 and go modules #1774
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
serving/samples: update helloworld-go to go:1.13 and go modules #1774
Conversation
|
/assign @ahmetb |
|
/test pull-knative-docs-unit-tests |
ahmetb
left a comment
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.
Looks good. Some nits.
| # This is based on Debian and sets the GOPATH to /go. | ||
| # https://hub.docker.com/_/golang | ||
| FROM golang:1.12 as builder | ||
| FROM golang:1.13 as builder |
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.
Any particular reason not to use golang:1?
We have to keep updating this every 6 months otherwise.
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.
Given that sometimes the minor version has significant change to best practices (e.g., modules) I think the clarity is worthwhile for the reader and motivation to update.
| WORKDIR /go/src/github.com/knative/docs/helloworld | ||
| COPY . . | ||
| WORKDIR /app | ||
| COPY . ./ |
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.
I wonder if this should do the go mod download trick, since many people will copy this? I know it's been decided on in the past, but consider adding it.
(I'm not attached to adding it - definitely makes things more complex, but it might be worth it.)
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.
Added go mod download and modified go build to use -mod=readonly for strictness of the build.
54597bb to
4484ccc
Compare
|
/test pull-knative-docs-integration-tests |
|
Looking at the error, I see: However, there is plainly a go.mod file in this sample and it builds locally just fine. Is it possible the test rig itself is skipping a file or missing the addition of go.mod somehow? @chaodaiG could you take a look? |
|
let me TAL |
@grayside you'll need to add docs/test/sampleapp/config.yaml Line 14 in 533e6b7
Also as I tried in #1787, you'll also need to remove -mod=readonly from the go build command.
|
|
Thank you @Fredy-Z for looking into this! |
|
Thanks @Fredy-Z, I want to make sure I understand what's happening here.
|
| @@ -0,0 +1,3 @@ | |||
| module github.com/knative/docs/docs/serving/samples/hello-world/helloworld-go | |||
|
|
|||
| go 1.13 | |||
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.
Add an empty line after this line. Otherwise go build will not work with -mod=readonly.
@grayside sorry for the late reply. For 1, I double checked your PR, this reason that you cannot have |
A piece of background, I have observed that all files needed for tests are already inlined in
|
|
For For file-copy: It makes sense to me that we test that files we include in the README are consistent with source code, but that should not determine what is copied. For example, there are lockfiles such as |
|
Updated to add the go.mod to the test config, and updated the README to add an instruction on how to generate go.mod. Note that I am not copying the go.mod file into the README. |
For file-copy, I'm fine with any change to make it smarter. One thing to keep in mind is, currently it's very tightly enforced to make sure all files needed for compilation are inspected in unit+e2e tests, if we keep separated list of what's copied and what's verified, there is a risk of these 2 lists diverged. So for any example I would recommend inline the content in README, unless it doesn't make sense at all. And in the latter case there is a way to get around it(not highly encouraged though) by running custom docs/test/sampleapp/config.yaml Line 4 in 533e6b7
|
|
It looks like the test is now passing, which tells me that at least some of what we were discussing was a misunderstanding that the tests require inlining all files. |
|
that would be a bug if that's the case. We can have this PR pass and I'll TAL |
|
/approve |
|
@chaodaiG there are files that are required for the build but are not and should not be inlined in the READMEs, for example, |
|
I agree that there are certain exceptions like in |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chaodaiG, grayside, samodell, tbpg The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
First step toward #1686
Proposed Changes
helloworldtoservergo mod downloadto facilitate a layer cache of go deps.-mod=readonlyflag on builds for strictness of container builds