Skip to content

Commit

Permalink
Merge pull request bpfman#836 from dave-tucker/fix-operator-verify
Browse files Browse the repository at this point in the history
.github: Bring back the verify check
  • Loading branch information
mergify[bot] authored Nov 27, 2023
2 parents 289c29f + 982c677 commit 174b35f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 42 deletions.
26 changes: 8 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,58 +125,48 @@ jobs:
## Build go modules
build-go:
runs-on: ubuntu-latest
# k8s codegen requires this to be set
env:
GOPATH: ${{ github.workspace }}
defaults:
run:
working-directory: ./bpfman-operator
steps:
- uses: actions/checkout@v4
with:
path: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman

- uses: actions/setup-go@v4
with:
go-version: "1.20"
go-version: "1.21"

- name: Go mod check
working-directory: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman
working-directory: ${{ github.workspace }}
run: |
go mod tidy
git diff --exit-code go.mod go.sum
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
# Keep this version synced with /bpfman/scripts/verify-golint.sh
working-directory: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman
version: v1.54.2
skip-cache: true
skip-pkg-cache: true
skip-build-cache: true
args: -v --timeout 5m --enable=gofmt

- name: Build Examples
working-directory: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman/examples
run: |
go build ./...
- name: Build Operator
working-directory: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman/bpfman-operator
run: make build

# FIXME: This is currently failing due to a GOPATH weirdness
# - name: Verify Operator
# working-directory: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman/bpfman-operator
# run: make verify
- name: Verify Operator
run: make verify

- name: Run Tests
working-directory: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman/bpfman-operator
run: make test

- name: Archive Go code coverage results
uses: actions/upload-artifact@v3
with:
name: coverage
path: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman/bpfman-operator/cover.out
path: ./bpfman-operator/cover.out
if-no-files-found: error

basic-integration-tests:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ jobs:
- uses: actions/setup-go@v4
if: ${{ matrix.image.bpf_build_wrapper == 'go' }}
with:
go-version: "1.20"
go-version: "1.21"

- uses: sigstore/cosign-installer@v3.2.0

Expand Down
71 changes: 48 additions & 23 deletions bpfman-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ KIND_CLUSTER_NAME ?= bpfman-deployment

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.25.0
K8S_CODEGEN_VERSION = v0.25.0

.DEFAULT_GOAL := help

Expand Down Expand Up @@ -100,6 +101,10 @@ $(LOCALBIN):
## Tool Binaries
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
REGISTER_GEN ?= $(LOCALBIN)/register-gen
INFORMER_GEN ?= $(LOCALBIN)/informer-gen
LISTER_GEN ?= $(LOCALBIN)/lister-gen
CLIENT_GEN ?= $(LOCALBIN)/client-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
CM_VERIFIER ?= $(LOCALBIN)/cm-verifier
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
Expand Down Expand Up @@ -127,6 +132,26 @@ controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessar
$(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)

.PHONY: register-gen
register-gen: $(REGISTER_GEN) ## Download register-gen locally if necessary.
$(REGISTER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/register-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/register-gen@$(K8S_CODEGEN_VERSION)

.PHONY: informer-gen
informer-gen: $(INFORMER_GEN) ## Download informer-gen locally if necessary.
$(INFORMER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/informer-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/informer-gen@$(K8S_CODEGEN_VERSION)

.PHONY: lister-gen
lister-gen: $(LISTER_GEN) ## Download lister-gen locally if necessary.
$(LISTER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/lister-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/lister-gen@$(K8S_CODEGEN_VERSION)

.PHONY: client-gen
client-gen: $(CLIENT_GEN) ## Download client-gen locally if necessary.
$(CLIENT_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/client-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/client-gen@$(K8S_CODEGEN_VERSION)

.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
Expand Down Expand Up @@ -156,8 +181,8 @@ ifeq ($(VERIFY_CODEGEN), true)
VERIFY_FLAG=--verify-only
endif

OUTPUT_PKG ?= github.com/bpfman/bpfman/bpfman-operator/pkg/client
APIS_PKG ?= github.com/bpfman/bpfman/bpfman-operator
OUTPUT_PKG ?= $(shell pwd)/bpfman-operator/pkg/client
APIS_PKG ?= $(shell pwd)/bpfman-operator
CLIENTSET_NAME ?= versioned
CLIENTSET_PKG_NAME ?= clientset
COMMON_FLAGS ?= ${VERIFY_FLAG} --go-header-file $(shell pwd)/hack/boilerplate.go.txt
Expand All @@ -172,8 +197,8 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
generate: manifests generate-register generate-deepcopy generate-typed-clients generate-typed-listers generate-typed-informers ## Generate ALL auto-generated code.

.PHONY: generate-register
generate-register: ## Generate register code see all `zz_generated.register.go` files.
go run k8s.io/code-generator/cmd/register-gen \
generate-register: register-gen ## Generate register code see all `zz_generated.register.go` files.
$(REGISTER_GEN) \
--input-dirs "${APIS_PKG}/apis/v1alpha1" \
--output-package "${APIS_PKG}/apis/" \
${COMMON_FLAGS}
Expand All @@ -183,31 +208,31 @@ generate-deepcopy: ## Generate code containing DeepCopy, DeepCopyInto, and DeepC
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: generate-typed-clients
generate-typed-clients: ## Generate typed client code
go run k8s.io/code-generator/cmd/client-gen \
--clientset-name "${CLIENTSET_NAME}" \
--input-base "" \
--input "${APIS_PKG}/apis/v1alpha1" \
--output-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME}" \
${COMMON_FLAGS}
generate-typed-clients: client-gen ## Generate typed client code
$(CLIENT_GEN) \
--clientset-name "${CLIENTSET_NAME}" \
--input-base "" \
--input "${APIS_PKG}/apis/v1alpha1" \
--output-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME}" \
${COMMON_FLAGS}


.PHONY: generate-typed-listers
generate-typed-listers: ## Generate typed listers code
go run k8s.io/code-generator/cmd/lister-gen \
--input-dirs "${APIS_PKG}/apis/v1alpha1" \
--output-package "${OUTPUT_PKG}/listers" \
${COMMON_FLAGS}
generate-typed-listers: lister-gen ## Generate typed listers code
$(LISTER_GEN) \
--input-dirs "${APIS_PKG}/apis/v1alpha1" \
--output-package "${OUTPUT_PKG}/listers" \
${COMMON_FLAGS}


.PHONY: generate-typed-informers
generate-typed-informers: ## Generate typed informers code
go run k8s.io/code-generator/cmd/informer-gen \
--input-dirs "${APIS_PKG}/apis/v1alpha1" \
--versioned-clientset-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME}/${CLIENTSET_NAME}" \
--listers-package "${OUTPUT_PKG}/listers" \
--output-package "${OUTPUT_PKG}/informers" \
${COMMON_FLAGS}
generate-typed-informers: informer-gen ## Generate typed informers code
$(INFORMER_GEN) \
--input-dirs "${APIS_PKG}/apis/v1alpha1" \
--versioned-clientset-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME}/${CLIENTSET_NAME}" \
--listers-package "${OUTPUT_PKG}/listers" \
--output-package "${OUTPUT_PKG}/informers" \
${COMMON_FLAGS}

.PHONY: fmt
fmt: ## Run go fmt against code.
Expand Down
1 change: 1 addition & 0 deletions bpfman-operator/hack/verify-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ if git status -s 2>&1 | grep -E -q '^\s+[MADRCU]'
then
echo Uncommitted changes in generated sources:
git status -s
git diff
exit 1
fi

0 comments on commit 174b35f

Please sign in to comment.