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

🌱 add verify-crd-compatibility make target and GHA #471

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ $(CONTROLLER_GEN): $(BINGO_DIR)/controller-gen.mod
@echo "(re)installing $(GOBIN)/controller-gen-v0.16.1"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=controller-gen.mod -o=$(GOBIN)/controller-gen-v0.16.1 "sigs.k8s.io/controller-tools/cmd/controller-gen"

CRD_DIFF := $(GOBIN)/crd-diff-v0.1.0
$(CRD_DIFF): $(BINGO_DIR)/crd-diff.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/crd-diff-v0.1.0"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=crd-diff.mod -o=$(GOBIN)/crd-diff-v0.1.0 "github.com/everettraven/crd-diff"

GINKGO := $(GOBIN)/ginkgo-v2.21.0
$(GINKGO): $(BINGO_DIR)/ginkgo.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
Expand Down
5 changes: 5 additions & 0 deletions .bingo/crd-diff.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.22.5

require github.com/everettraven/crd-diff v0.1.0
323 changes: 323 additions & 0 deletions .bingo/crd-diff.sum

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .bingo/variables.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ BINGO="${GOBIN}/bingo-v0.9.0"

CONTROLLER_GEN="${GOBIN}/controller-gen-v0.16.1"

CRD_DIFF="${GOBIN}/crd-diff-v0.1.0"

GINKGO="${GOBIN}/ginkgo-v2.21.0"

GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.60.3"
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/crd-diff.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: crd-diff
on:
pull_request:
jobs:
crd-diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Run make verify-crd-compatibility
run: make verify-crd-compatibility CRD_DIFF_ORIGINAL_REF=${{ github.event.pull_request.base.sha }} CRD_DIFF_UPDATED_SOURCE="git://${{ github.event.pull_request.head.sha }}?path=config/base/crd/bases/olm.operatorframework.io_clustercatalogs.yaml"

7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ tidy: ## Update dependencies
verify: tidy fmt vet generate ## Verify the current code generation and lint
git diff --exit-code

.PHONY: verify-crd-compatibility
CRD_DIFF_ORIGINAL_REF := main
CRD_DIFF_UPDATED_SOURCE := file://config/base/crd/bases/olm.operatorframework.io_clustercatalogs.yaml
CRD_DIFF_CONFIG := crd-diff-config.yaml
verify-crd-compatibility: $(CRD_DIFF)
$(CRD_DIFF) --config="${CRD_DIFF_CONFIG}" "git://${CRD_DIFF_ORIGINAL_REF}?path=config/base/crd/bases/olm.operatorframework.io_clustercatalogs.yaml" ${CRD_DIFF_UPDATED_SOURCE}

.PHONY: lint
lint: $(GOLANGCI_LINT) ## Run golangci linter.
$(GOLANGCI_LINT) run --build-tags $(GO_BUILD_TAGS) $(GOLANGCI_LINT_ARGS)
Expand Down
109 changes: 109 additions & 0 deletions crd-diff-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
checks:
crd:
scope:
enabled: true
existingFieldRemoval:
enabled: true
storedVersionRemoval:
enabled: true
version:
sameVersion:
enabled: true
unhandledFailureMode: "Closed"
enum:
enabled: true
removalEnforcement: "Strict"
additionEnforcement: "Strict"
default:
enabled: true
changeEnforcement: "Strict"
removalEnforcement: "Strict"
additionEnforcement: "Strict"
required:
enabled: true
newEnforcement: "Strict"
type:
enabled: true
changeEnforcement: "Strict"
maximum:
enabled: true
additionEnforcement: "Strict"
decreaseEnforcement: "Strict"
maxItems:
enabled: true
additionEnforcement: "Strict"
decreaseEnforcement: "Strict"
maxProperties:
enabled: true
additionEnforcement: "Strict"
decreaseEnforcement: "Strict"
maxLength:
enabled: true
additionEnforcement: "Strict"
decreaseEnforcement: "Strict"
minimum:
enabled: true
additionEnforcement: "Strict"
increaseEnforcement: "Strict"
minItems:
enabled: true
additionEnforcement: "Strict"
increaseEnforcement: "Strict"
minProperties:
enabled: true
additionEnforcement: "Strict"
increaseEnforcement: "Strict"
minLength:
enabled: true
additionEnforcement: "Strict"
increaseEnforcement: "Strict"
servedVersion:
enabled: true
unhandledFailureMode: "Closed"
enum:
enabled: true
removalEnforcement: "Strict"
additionEnforcement: "Strict"
default:
enabled: true
changeEnforcement: "Strict"
removalEnforcement: "Strict"
additionEnforcement: "Strict"
required:
enabled: true
newEnforcement: "Strict"
type:
enabled: true
changeEnforcement: "Strict"
maximum:
enabled: true
additionEnforcement: "Strict"
decreaseEnforcement: "Strict"
maxItems:
enabled: true
additionEnforcement: "Strict"
decreaseEnforcement: "Strict"
maxProperties:
enabled: true
additionEnforcement: "Strict"
decreaseEnforcement: "Strict"
maxLength:
enabled: true
additionEnforcement: "Strict"
decreaseEnforcement: "Strict"
minimum:
enabled: true
additionEnforcement: "Strict"
increaseEnforcement: "Strict"
minItems:
enabled: true
additionEnforcement: "Strict"
increaseEnforcement: "Strict"
minProperties:
enabled: true
additionEnforcement: "Strict"
increaseEnforcement: "Strict"
minLength:
enabled: true
additionEnforcement: "Strict"
increaseEnforcement: "Strict"
Loading