diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5906bd38a..0883fe7bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,30 @@ jobs: paths_ignore: '["**.md", "**.png", "**.jpg"]' do_not_skip: '["workflow_dispatch", "schedule", "push"]' + report-breaking-changes: + runs-on: ubuntu-22.04 + needs: detect-noop + if: needs.detect-noop.outputs.noop != 'true' + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: true + + - name: Get modified CRDs + id: modified-crds + uses: tj-actions/changed-files@v34 + with: + files: | + package/crds/** + + - name: Report breaking CRD OpenAPI v3 schema changes + if: steps.modified-crds.outputs.any_changed == 'true' + env: + MODIFIED_CRD_LIST: ${{ steps.modified-crds.outputs.all_changed_files }} + run: | + mkdir -p .cache/tools/linux_x86_64 + make crddiff lint: runs-on: ubuntu-22.04 diff --git a/Makefile b/Makefile index 11667e04e..d4f32f3a6 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ GO111MODULE = on KIND_VERSION = v0.15.0 UP_VERSION = v0.14.0 UP_CHANNEL = stable -UPTEST_VERSION = v0.3.0 +UPTEST_VERSION = v0.4.0 -include build/makelib/k8s_tools.mk # ==================================================================================== @@ -179,7 +179,26 @@ local-deploy: build controlplane.up local.xpkg.deploy.provider.$(PROJECT_NAME) # - UPTEST_DATASOURCE_PATH, see https://github.com/upbound/uptest#injecting-dynamic-values-and-datasource e2e: local-deploy uptest -.PHONY: uptest e2e +# TODO: please move this to the common build submodule +# once the use cases mature +crddiff: $(UPTEST) + @$(INFO) Checking breaking CRD schema changes + @for crd in $${MODIFIED_CRD_LIST}; do \ + if ! git cat-file -e "$${GITHUB_BASE_REF}:$${crd}" 2>/dev/null; then \ + echo "CRD $${crd} does not exist in the $${GITHUB_BASE_REF} branch. Skipping..." ; \ + continue ; \ + fi ; \ + echo "Checking $${crd} for breaking API changes..." ; \ + changes_detected=$$($(UPTEST) crddiff revision <(git cat-file -p "$${GITHUB_BASE_REF}:$${crd}") "$${crd}" 2>&1) ; \ + if [[ $$? != 0 ]] ; then \ + printf "\033[31m"; echo "Breaking change detected!"; printf "\033[0m" ; \ + echo "$${changes_detected}" ; \ + echo ; \ + fi ; \ + done + @$(OK) Checking breaking CRD schema changes + +.PHONY: uptest e2e crddiff # ==================================================================================== # Special Targets