-
Notifications
You must be signed in to change notification settings - Fork 2.1k
docs: include required tools in source tree #4903
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
Conversation
|
(Also wondering if we can rewrite things to be a |
f6f0e4b to
b46bfe4
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4903 +/- ##
=======================================
Coverage 59.43% 59.43%
=======================================
Files 358 358
Lines 29765 29765
=======================================
Hits 17690 17690
Misses 11111 11111
Partials 964 964 🚀 New features to boost your workflow:
|
b46bfe4 to
bc126aa
Compare
bc126aa to
1ff8868
Compare
| //go:build tools | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| _ "github.com/cpuguy83/go-md2man/v2" | ||
| ) |
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 removed the tools.go here, as we already vendor the dependency as indirect dependency of docker/cli-docs-tool. I could keep if it that's a concern (but things would show up pretty fast if we'd miss the dependency at some point)
1ff8868 to
1c298b1
Compare
vendor.mod
Outdated
| github.com/cenkalti/backoff/v4 v4.3.0 // indirect | ||
| github.com/cespare/xxhash/v2 v2.3.0 // indirect | ||
| github.com/containerd/log v0.1.0 // indirect | ||
| github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect |
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.
We could make use of the new tool directive starting Go 1.24:
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.
Ah, yes, but we're not on go1.24 yet 😅
At least currently it works, so I guess it's fine with how we have it right now?
|
Let me move this one out of draft; I have a follow-up to rewrite some code to use more of the man-page code from cli-docs-tool, but didn't want to stuff that in with this PR. |
| tee "${ROOTDIR}/go.mod" >&2 <<- EOF | ||
| module github.com/docker/cli | ||
| go 1.23.0 | ||
| EOF |
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.
Should/could this instead be something like grep -E '^(module|go) ' vendor.mod | tee go.mod so there's less to dual-maintain?
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.
Oh! Didn't do this one yet, might do so in a follow-up
scripts/vendor
Outdated
| } | ||
| update() ( | ||
| set -x | ||
| "${SCRIPTDIR}"/with-go-mod.sh go mod tidy -modfile vendor.mod |
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.
Again, I think it's better to document that the invoker of these should run with-go-mod.sh, especially since that'll cause less churn if there's more than one usage of go.mod within a given script.
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.
❤️ your comments made me realise that I don't have to include it in each script; I moved it to the Makefile instead; it's not perfect, but at least keeps the scripts themselves clean. Possibly we could move it into a Makefile var / macro as well so that it can be overridden (to run the scripts without the with-go-mod.sh script before it).
In order to be able to build the documentation without internet access (as is required by some distribution build systems), all of the source code needed for the build needs to be available in the source tarball. This used to be possible with the docker-cli sources but was accidentally broken with some CI changes that switched to downloading the tools (by modifying go.mod as part of the docs build script). This pattern also maked documentation builds less reproducible since the tool version used was not based on the source code version. Fixes: 7dc35c0 ("validate manpages target") Fixes: a650f4d ("switch to cli-docs-tool for yaml docs generation") Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1c298b1 to
8eb269f
Compare
| _ "github.com/spf13/cobra/doc" | ||
| _ "github.com/spf13/pflag" | ||
| ) | ||
| import _ "github.com/cpuguy83/go-md2man/v2" |
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.
Turned out I needed the tools.go after all (don't ask!) 🙈 😂
| if [ ! -x "$(command -v $GO_MD2MAN)" ]; then | ||
| ( | ||
| set -x | ||
| go build -mod=vendor -modfile=vendor.mod -o ./build/tools/go-md2man ./vendor/github.com/cpuguy83/go-md2man/v2 |
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.
Now that we have this check; perhaps I should even consider using a regular go install for this. Packagers that want to build offline can pre-install go-md2man if needed I guess?
I'll leave that as a follow up I think
tianon-sso
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.
Nice, much better (just a couple really minor nits but overall LGTM ❤️)
Use the same script as is used in moby/moby, which more gracefully handles an existing `go.mod` (which can be symlinked) into account. - keep the scripts called generic, and update the Makefile to invoke them with the "with-go-mod.sh" script. - use "go run" instead of building temporary binaries - check if go-md2man exists before building a binary Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
8eb269f to
535bb6c
Compare
|
I'll have a look at some follow-ups as well;
|
go-md2manIn order to be able to build the documentation without internet access (as is required by some distribution build systems), all of the source code needed for the build needs to be available in the source tarball.
This used to be possible with the docker-cli sources but was accidentally broken with some CI changes that switched to downloading the tools (by modifying go.mod as part of the docs build script).
This pattern also maked documentation builds less reproducible since the tool version used was not based on the source code version.
Fixes: commit 7dc35c0 ("validate manpages target")
Fixes: commit a650f4d ("switch to cli-docs-tool for yaml docs generation")
- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)