Skip to content
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

Make update-all & ensure bazel-only targets are runnable #5251

Merged
merged 1 commit into from Jun 30, 2022

Conversation

SgtCoDFish
Copy link
Member

This allows us to maintain the bazel build files until they're removed, but tries to avoid accidentally encouraging their use

make update-all implementes a non-bazel version of hack/update-all.sh, with hack/update-all.sh now calling make but also doing the bazel stuff it used to.

Kind

/kind cleanup

Release Note

Adds `make update-all` as a convenience target to run before raising a PR

@jetstack-bot jetstack-bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 30, 2022
Copy link
Member Author

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

Some notes to help with reviewing!

Comment on lines +1 to +2
bin
_bin
Copy link
Member Author

Choose a reason for hiding this comment

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

This stops bazel from trying to look in these directories for files!

Comment on lines +19 to +37
sh_binary(
name = "update-deps",
srcs = ["update-deps.sh"],
args = [
"$(location %s)" % GO,
"$(location %s)" % GAZELLE,
"$(location %s)" % KAZEL,
"$(location :update-bazel)",
"$(location :update-deps-licenses)",
],
data = [
GAZELLE,
GO,
KAZEL,
":update-bazel",
":update-deps-licenses",
],
tags = ["manual"],
)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is re-added from an older commit but marked manual so it won't be automatically run anywhere.

Comment on lines +50 to +62
tags = ["manual"],
)

sh_binary(
name = "update-deps-licenses",
srcs = ["update-deps-licenses.sh"],
args = [
"$(location %s)" % GO,
],
data = [
GO,
],
tags = ["manual"],
Copy link
Member Author

Choose a reason for hiding this comment

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

update-deps-licenses is re-added from an older commit but marked manual so it won't be automatically run anywhere.

update-bazel and the licenses target become manual

Comment on lines +27 to +29
echo -e "\033[0;33mThis script is preserved for legacy reasons, and as such will also update bazel
You shouldn't need to run this script or install bazel for normal development.
Use 'make update-all' to do everything this script does without touching bazel\033[0m"
Copy link
Member Author

Choose a reason for hiding this comment

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

I felt like removing update-bazel here would be a more disruptive change for people who use these hack scripts due to muscle memory, so I kept it here but added make update-all for more general use.

Comment on lines -38 to -42
if [[ ! -f go.mod ]]; then
echo "No module defined, see https://github.com/golang/go/wiki/Modules#how-to-define-a-module" >&2
exit 1
fi

Copy link
Member Author

Choose a reason for hiding this comment

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

This just seems redundant, although I recognise it's an unnecessary change!

Comment on lines -58 to -89
export GO111MODULE=on
export GOPROXY=https://proxy.golang.org
export GOSUMDB=sum.golang.org
mode="${1:-}"
shift || true
case "$mode" in
--minor)
if [[ -z "$@" ]]; then
"$go" get -u ./...
else
"$go" get -u "$@"
fi
;;
--patch)
if [[ -z "$@" ]]; then
"$go" get -u=patch ./...
else
"$go" get -u=patch "$@"
fi
;;
"")
# Just validate, or maybe manual go.mod edit
;;
*)
echo "Usage: $(basename "$0") [--patch|--minor] [packages]" >&2
exit 1
;;
esac

rm -rf vendor
"$go" mod tidy
unset GOROOT
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed this because it doesn't do anything when update-deps is called via bazel (i.e. without an argument) and I don't really see a need to wrap these commands in make.

If someone needs a helper script to update our dependencies (as in, they don't understand how to update the dependencies without a helper) then they probably shouldn't be updating our dependencies (an action which has huge supply-chain implications and needs careful review in any case).

If someone doesn't need this helper script, surely they'd just use go get -u themselves?

Comment on lines -34 to +36
args=$(ls "$(pwd)" | grep -v 'bazel-' | grep -v 'external/' | grep -v 'bin' )
args=$(ls "$(pwd)" | grep -v 'bazel-' | grep -v 'external/' | grep -v 'bin' | grep -v '_bin' )
Copy link
Member Author

Choose a reason for hiding this comment

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

unrelated but I think this is an obvious thing to do!

echo "Please run 'bazel run //hack:update-gofmt'"
exit 1
fi
make verify-imports
Copy link
Member Author

Choose a reason for hiding this comment

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

goimports isn't the same as gofmt but I think it's fine to replace gofmt entirely here. We already run goimports on every PR.

Comment on lines +21 to +28
# NB: This script requires bazel, and is no longer supported since we no longer support bazel
# We want to add something like this to make, but since this script was never part of any CI
# pipeline it's not a priority. The script is kept for backwards compatibility for now but may
# change or be removed in the future.

# See https://github.com/cert-manager/cert-manager/pull/3037#issue-440523030

# Currently only works on linux/amd64, darwin/amd64.
Copy link
Member Author

Choose a reason for hiding this comment

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

I initially just removed this script and I think that'd probably be fine, but might as well leave it in this PR.

Comment on lines -39 to -41
## Update all CRDs to the latest version based on the current checkout
##
## @category Development
Copy link
Member Author

Choose a reason for hiding this comment

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

It seems pointless to document this when most people will want to run both update-crds and update-codegen together at the same time. make update-all is probably preferable to document for most uses.

this allows us to maintain the bazel build files until they're removed,
but tries to avoid accidentally encouraging their use

`make update-all` implementes a non-bazel version of
`hack/update-all.sh`, with `hack/update-all.sh` now calling make but
also doing the bazel stuff it used to.

Signed-off-by: Ashley Davis <ashley.davis@jetstack.io>
@SgtCoDFish
Copy link
Member Author

/test pull-cert-manager-make-test

Copy link
Collaborator

@irbekrm irbekrm left a comment

Choose a reason for hiding this comment

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

Thanks @SgtCoDFish agree that one target to udpate everything seems like the most straightforward thing and easiest for contributors 👍🏼

/lgtm

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Jun 30, 2022
@jetstack-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: irbekrm, SgtCoDFish

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@SgtCoDFish
Copy link
Member Author

/test pull-cert-manager-make-test

❄️

@jetstack-bot jetstack-bot merged commit eb9eedd into cert-manager:master Jun 30, 2022
@jetstack-bot jetstack-bot added this to the v1.9 milestone Jun 30, 2022
@SgtCoDFish SgtCoDFish deleted the update-deps branch June 30, 2022 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants