Skip to content

Commit

Permalink
fix: presubmits (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellistarn authored Oct 13, 2022
1 parent e3d23d2 commit c321d05
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
help: ## Display help
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

presubmit: verify test ## Run all steps required for code to be checked in
presubmit: toolchain verify test ## Run all steps required for code to be checked in

test: ## Run tests
go test -run=${TEST_FILTER} ./... \
Expand All @@ -25,4 +25,7 @@ codegen: ## Generate code. Must be run if changes are made to ./pkg/apis/...
output:crd:artifacts:config=chart/crds
hack/boilerplate.sh

.PHONY: help presubmit test verify codegen
toolchain: ## Install developer toolchain
./hack/toolchain.sh

.PHONY: help presubmit test verify codegen toolchain
40 changes: 40 additions & 0 deletions hack/toolchain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
set -euo pipefail

K8S_VERSION="${K8S_VERSION:="1.22.x"}"
KUBEBUILDER_ASSETS="${KUBEBUILDER_ASSETS:="${HOME}/.kubebuilder/bin"}"

main() {
tools
kubebuilder
}

tools() {
go install github.com/google/[email protected]
go install github.com/golangci/golangci-lint/cmd/[email protected]
go install github.com/google/[email protected]
go install github.com/mikefarah/yq/[email protected]
go install github.com/norwoodj/helm-docs/cmd/[email protected]
go install sigs.k8s.io/controller-runtime/tools/[email protected]
go install sigs.k8s.io/controller-tools/cmd/[email protected]
go install github.com/sigstore/cosign/cmd/[email protected]
go install github.com/gohugoio/[email protected]+extended
go install golang.org/x/vuln/cmd/[email protected]

if ! echo "$PATH" | grep -q "${GOPATH:-undefined}/bin\|$HOME/go/bin"; then
echo "Go workspace's \"bin\" directory is not in PATH. Run 'export PATH=\"\$PATH:\${GOPATH:-\$HOME/go}/bin\"'."
fi
}

kubebuilder() {
mkdir -p $KUBEBUILDER_ASSETS
arch=$(go env GOARCH)
## Kubebuilder does not support darwin/arm64, so use amd64 through Rosetta instead
if [[ $(go env GOOS) == "darwin" ]] && [[ $(go env GOARCH) == "arm64" ]]; then
arch="amd64"
fi
ln -sf $(setup-envtest use -p path "${K8S_VERSION}" --arch="${arch}" --bin-dir="${KUBEBUILDER_ASSETS}")/* ${KUBEBUILDER_ASSETS}
find $KUBEBUILDER_ASSETS
}

main "$@"

0 comments on commit c321d05

Please sign in to comment.