Skip to content

Commit

Permalink
[GHA] - add new target to catch uncommitted generated files in GHA, m…
Browse files Browse the repository at this point in the history
…ake sure to generate-mock target before testing (#193)

* add new target to catch uncommitted generated files in GHA

* rename generate targets
  • Loading branch information
AshleyDumaine authored Mar 14, 2024
1 parent a81e615 commit 6cfe528
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build_test_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ jobs:
- name: Build
run: make build

- name: Check for generated diff
run: make check-gen-diff

- name: Test
run: make test

Expand Down
20 changes: 13 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ help: ## Display this help.
## --------------------------------------

##@ Generate:
.PHONY: generate
generate: generate-manifests generate-code generate-mock

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
.PHONY: generate-manifests
generate-manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
.PHONY: generate-code
generate-code: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: generate-mock
Expand All @@ -92,6 +94,10 @@ generate-mock: mockgen ## Generate mocks for the Linode API client.
generate-flavors: $(KUSTOMIZE)
./hack/generate-flavors.sh

.PHONY: check-gen-diff
check-gen-diff:
git diff --no-ext-diff --quiet --exit-code

## --------------------------------------
## Development
## --------------------------------------
Expand Down Expand Up @@ -133,11 +139,11 @@ docs:
##@ Testing:

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
test: generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -race -timeout 60s ./... -coverprofile cover.out

.PHONY: e2etest
e2etest: manifests generate local-deploy chainsaw
e2etest: generate local-deploy chainsaw
$(CHAINSAW) test ./e2e

local-deploy: kind ctlptl tilt kustomize clusterctl
Expand All @@ -150,7 +156,7 @@ local-deploy: kind ctlptl tilt kustomize clusterctl
## --------------------------------------

.PHONY: build
build: manifests generate fmt vet ## Build manager binary.
build: generate fmt vet ## Build manager binary.
go build -ldflags="-X github.com/linode/cluster-api-provider-linode/version.version=$(VERSION)" -o bin/manager cmd/main.go

# If you wish to build the manager image targeting other platforms you can use the --platform flag.
Expand Down

0 comments on commit 6cfe528

Please sign in to comment.