Skip to content

Commit 5bb7132

Browse files
Add CI check for auto-generated files (#336)
* add CI validation check to make sure all generated files are part of the PR * seaprate out set default operator VERSION to 'ensure-generate-is-noop' target
1 parent 0d58f28 commit 5bb7132

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

.github/workflows/continuous-integration.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ jobs:
2222
- name: "install kubebuilder"
2323
run: ./hack/install-kubebuilder.sh
2424

25+
- uses: jpkrohling/[email protected]
26+
with:
27+
operator-sdk-version: v1.9.0
28+
2529
- name: "basic checks"
2630
run: make ci
2731

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ $ gh pr create
2828

2929
Build the manifests, install the CRD and run the operator as a local process:
3030
```
31-
$ make manifests install run
31+
$ make bundle install run
3232
```
3333

3434
### Deployment with webhooks
@@ -47,7 +47,7 @@ make cert-manager
4747
Once it's ready, the following can be used to build and deploy a manager, along with the required webhook configuration:
4848

4949
```
50-
make manifests container container-push deploy
50+
make bundle container container-push deploy
5151
```
5252

5353
By default, it will generate an image following the format `quay.io/${USER}/opentelemetry-operator:${VERSION}`. You can set the following env vars in front of the `make` command to override parts or the entirety of the image:

Makefile

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ VERSION ?= "$(shell git describe --tags | sed 's/^v//')"
33
VERSION_DATE ?= $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
44
VERSION_PKG ?= "github.com/open-telemetry/opentelemetry-operator/internal/version"
55
OTELCOL_VERSION ?= "$(shell grep -v '\#' versions.txt | grep opentelemetry-collector | awk -F= '{print $$2}')"
6+
OPERATOR_VERSION ?= "$(shell grep -v '\#' versions.txt | grep operator | awk -F= '{print $$2}')"
67
LD_FLAGS ?= "-X ${VERSION_PKG}.version=${VERSION} -X ${VERSION_PKG}.buildDate=${VERSION_DATE} -X ${VERSION_PKG}.otelCol=${OTELCOL_VERSION}"
78

89
# Image URL to use all building/pushing image targets
@@ -43,11 +44,16 @@ endif
4344
KUBE_VERSION ?= 1.21
4445
KIND_CONFIG ?= kind-$(KUBE_VERSION).yaml
4546

47+
ensure-generate-is-noop: VERSION=$(OPERATOR_VERSION)
48+
ensure-generate-is-noop: generate bundle
49+
@git diff -s --exit-code api/v1alpha1/zz_generated.*.go || (echo "Build failed: a model has been changed but the generated resources aren't up to date. Run 'make generate' and update your PR." && exit 1)
50+
@git diff -s --exit-code bundle config || (echo "Build failed: the bundle, config files has been changed but the generated bundle, config files aren't up to date. Run 'make bundle' and update your PR." && exit 1)
51+
4652
all: manager
4753
ci: test
4854

4955
# Run tests
50-
test: generate fmt vet manifests
56+
test: generate fmt vet ensure-generate-is-noop
5157
go test ${GOTEST_OPTS} ./...
5258

5359
# Build manager binary

bundle/manifests/opentelemetry-operator.clusterserviceversion.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ metadata:
2121
containerImage: quay.io/opentelemetry/opentelemetry-operator
2222
createdAt: "2020-12-16T13:37:00+00:00"
2323
description: Provides the OpenTelemetry components, including the Collector
24-
operators.operatorframework.io/builder: operator-sdk-v1.9.0
24+
operators.operatorframework.io/builder: operator-sdk-v1.8.0+git
2525
operators.operatorframework.io/project_layout: go.kubebuilder.io/v2
2626
repository: github.com/open-telemetry/opentelemetry-operator
2727
support: OpenTelemetry Community

versions.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# the docs as well.
55
opentelemetry-collector=0.29.0
66

7-
# Represents the next release of the OpenTelemetry Operator.
7+
# Represents the current release of the OpenTelemetry Operator.
88
operator=0.29.0

0 commit comments

Comments
 (0)