-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aim to simplify the user experience while developing locally. Removed the GOARCH flag, so by default you're using your default ARCH. I think this will simpler for everyone, and reduce the amount of binaries to build. Added helpers to run the acceptance tests, maybe we can also use them in github actions
- Loading branch information
Showing
6 changed files
with
91 additions
and
86 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -47,11 +47,7 @@ jobs: | |
go-version: 1.20.5 | ||
- name: Ensure no go vet errors | ||
run: | | ||
go vet ./cmd/rbac-manager/... | ||
go vet ./cmd/theatre-consoles/... | ||
go vet ./cmd/theatre-secrets/... | ||
go vet ./cmd/vault-manager/... | ||
go vet ./cmd/workloads-manager/... | ||
make vet | ||
unit-integration: | ||
runs-on: ubuntu-latest | ||
|
@@ -60,15 +56,13 @@ jobs: | |
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.20.5 | ||
- name: Install ginkgo test runner | ||
run: go install github.com/onsi/ginkgo/[email protected] | ||
- name: Install Kubebuilder test helpers | ||
- name: Install go tooling and setup-envtest | ||
run: | | ||
sudo mkdir /usr/local/kubebuilder | ||
curl -fsL https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.1/kubebuilder_2.3.1_linux_amd64.tar.gz \ | ||
| sudo tar -xvz --strip=1 -C /usr/local/kubebuilder | ||
make install-tools | ||
- name: Run tests | ||
run: ginkgo -race -randomizeSuites -randomizeAllSpecs -r -v ./... | ||
run: | | ||
export KUBEBUILDER_ASSETS="$(setup-envtest use -p path 1.24.x!)" | ||
ginkgo -race -randomizeSuites -randomizeAllSpecs -r ./... | ||
acceptance: | ||
runs-on: ubuntu-latest | ||
|
@@ -78,9 +72,7 @@ jobs: | |
with: | ||
go-version: 1.20.5 | ||
- name: Build test binaries | ||
run: make bin/acceptance.linux_amd64 | ||
# This tools version don't change that often, it would be a good idea use actions/cache. | ||
# maybe same thing with the toolling in the unit-integration | ||
run: make bin/acceptance.linux | ||
- name: Install tooling | ||
run: |- | ||
sudo bash <<EOF | ||
|
@@ -92,9 +84,9 @@ jobs: | |
chmod a+x /usr/local/bin/kustomize /usr/local/bin/kubectl /usr/local/bin/kind | ||
EOF | ||
- name: Prepare the cluster | ||
run: bin/acceptance.linux_amd64 prepare --verbose && sleep 10 | ||
run: bin/acceptance.linux prepare --verbose && sleep 10 | ||
- name: Run acceptance tests | ||
run: bin/acceptance.linux_amd64 run --verbose | ||
run: bin/acceptance.linux run --verbose | ||
- name: Show all pods | ||
run: kubectl get pods -A -o wide | ||
if: failure() | ||
|
This file contains 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 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 |
---|---|---|
|
@@ -11,57 +11,73 @@ else | |
GOBIN=$(shell go env GOBIN) | ||
endif | ||
|
||
.PHONY: build build-darwin build-linux build-all test generate manifests deploy clean docker-build docker-pull docker-push docker-tag controller-gen | ||
.PHONY: build build-darwin build-linux build-all clean fmt vet test acceptance-e2e acceptance-run acceptance-prepare acceptance-destory generate manifests install-tools deploy | ||
|
||
build: $(PROG) | ||
build-darwin: $(PROG:=.darwin_amd64) | ||
build-linux: $(PROG:=.linux_amd64) | ||
build-darwin: $(PROG:=.darwin) | ||
build-linux: $(PROG:=.linux) | ||
build-all: build-darwin build-linux | ||
|
||
# Specific linux build target, making it easy to work with the docker acceptance | ||
# tests on OSX | ||
bin/%.linux_amd64: | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(BUILD_COMMAND) -a -o $@ ./cmd/$*/. | ||
# tests on OSX. It uses by default your local arch | ||
bin/%.linux: | ||
CGO_ENABLED=0 GOOS=linux $(BUILD_COMMAND) -a -o $@ ./cmd/$*/. | ||
|
||
bin/%.darwin_amd64: | ||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(BUILD_COMMAND) -a -o $@ ./cmd/$*/. | ||
bin/%.darwin: | ||
CGO_ENABLED=0 GOOS=darwin $(BUILD_COMMAND) -a -o $@ ./cmd/$*/. | ||
|
||
bin/%: | ||
CGO_ENABLED=0 GOARCH=amd64 $(BUILD_COMMAND) -o $@ ./cmd/$*/. | ||
CGO_ENABLED=0 $(BUILD_COMMAND) -o $@ ./cmd/$*/. | ||
|
||
# Run the below commands in order to install the required dependencies for | ||
# running `make test` locally. | ||
# go install github.com/onsi/ginkgo/[email protected] | ||
# go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest | ||
# setup-envtest use -p path 1.22.x | ||
# source <(setup-envtest use -i -p env 1.22.x) | ||
test: | ||
ginkgo -race -r ./... | ||
clean: | ||
rm -rvf $(PROG) $(PROG:%=%.linux) $(PROG:%=%.darwin) | ||
|
||
fmt: | ||
go fmt ./... | ||
|
||
vet: | ||
go vet ./cmd/rbac-manager/... | ||
go vet ./cmd/theatre-consoles/... | ||
go vet ./cmd/theatre-secrets/... | ||
go vet ./cmd/vault-manager/... | ||
go vet ./cmd/workloads-manager/... | ||
go vet -tests -unreachable ./... | ||
|
||
test: install-tools | ||
KUBEBUILDER_ASSETS="$(shell setup-envtest use -p path 1.24.x!)" ginkgo -race -randomizeSuites -randomizeAllSpecs -r ./... | ||
|
||
# Requires the following binaries: kubectl, kustomize, kind, docker | ||
acceptance-e2e: install-tools acceptance-prepare acceptance-run acceptance-destroy | ||
|
||
acceptance-run: install-tools | ||
go run cmd/acceptance/main.go run --verbose | ||
|
||
acceptance-prepare: install-tools | ||
go run cmd/acceptance/main.go prepare --verbose | ||
|
||
acceptance-destroy: install-tools | ||
go run cmd/acceptance/main.go prepare --verbose | ||
|
||
generate: controller-gen | ||
$(CONTROLLER_GEN) object paths="./apis/rbac/..." | ||
$(CONTROLLER_GEN) object paths="./apis/workloads/..." | ||
generate: install-tools | ||
controller-gen object paths="./apis/rbac/..." | ||
controller-gen object paths="./apis/workloads/..." | ||
|
||
manifests: generate | ||
$(CONTROLLER_GEN) crd paths="./apis/rbac/..." output:crd:artifacts:config=config/base/crds | ||
$(CONTROLLER_GEN) crd paths="./apis/workloads/..." output:crd:artifacts:config=config/base/crds | ||
controller-gen crd paths="./apis/rbac/..." output:crd:artifacts:config=config/base/crds | ||
controller-gen crd paths="./apis/workloads/..." output:crd:artifacts:config=config/base/crds | ||
|
||
# See https://github.com/kubernetes-sigs/controller-runtime/tree/main/tools/setup-envtest | ||
install-tools: | ||
go install github.com/onsi/ginkgo/[email protected] | ||
go install sigs.k8s.io/controller-tools/cmd/[email protected] | ||
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest | ||
|
||
install-tools-homebrew: | ||
brew install kubernetes-cli kustomize kind | ||
echo "you also need docker and go in your developer environment" | ||
|
||
# Deprecated | ||
deploy: | ||
kustomize build config/base | kubectl apply -f - | ||
|
||
deploy-production: | ||
kustomize build config/overlays/production | kubectl apply -f - | ||
|
||
clean: | ||
rm -rvf $(PROG) $(PROG:%=%.linux_amd64) $(PROG:%=%.darwin_amd64) | ||
|
||
docker-build: | ||
docker build -t $(IMAGE):latest . | ||
|
||
|
@@ -74,19 +90,3 @@ docker-push: | |
docker-tag: | ||
docker tag $(IMAGE):$$(git rev-parse HEAD) $(IMAGE):latest | ||
|
||
# find or download controller-gen | ||
# download controller-gen if necessary | ||
controller-gen: | ||
ifeq (, $(shell which controller-gen)) | ||
@{ \ | ||
set -e ;\ | ||
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\ | ||
cd $$CONTROLLER_GEN_TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
go install sigs.k8s.io/controller-tools/cmd/[email protected] ;\ | ||
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\ | ||
} | ||
CONTROLLER_GEN=$(GOBIN)/controller-gen | ||
else | ||
CONTROLLER_GEN=$(shell which controller-gen) | ||
endif |
This file contains 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 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 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