Skip to content

Commit

Permalink
build: remove csv generation from build
Browse files Browse the repository at this point in the history
since we don't need the csv generation to be part of
our build image let's remove that. And add a check in CI
to validate modified csv files.

Signed-off-by: subhamkrai <[email protected]>
  • Loading branch information
subhamkrai committed Mar 8, 2024
1 parent e709505 commit 8c066ca
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ jobs:
- name: validate crds-gen
run: tests/scripts/validate_modified_files.sh crd

- name: run gen-csv
run: make csv-clean && GOPATH=$(go env GOPATH) make gen-csv

- name: validate gen-csv
run: tests/scripts/validate_modified_files.sh gen-csv

- name: run gen-rbac
run: GOPATH=$(go env GOPATH) make gen-rbac

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ prune: ## Prune cached artifacts.
@$(MAKE) -C images prune

# Change how CRDs are generated for CSVs
csv: export MAX_DESC_LEN=0 # sets the description length to 0 since CSV cannot be bigger than 1MB
csv: export NO_OB_OBC_VOL_GEN=true
csv: csv-clean crds ## Generate a CSV file for OLM.
gen-csv: export MAX_DESC_LEN=0 # sets the description length to 0 since CSV cannot be bigger than 1MB
gen-csv: export NO_OB_OBC_VOL_GEN=true
gen-csv: csv-clean crds ## Generate a CSV file for OLM.
$(MAKE) -C images/ceph csv

csv-clean: ## Remove existing OLM files.
Expand Down
1 change: 0 additions & 1 deletion images/ceph/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ RUN curl --fail -sSL -o /s5cmd.tar.gz https://github.com/peak/s5cmd/releases/dow
COPY rook toolbox.sh set-ceph-debug-level /usr/local/bin/
COPY ceph-monitoring /etc/ceph-monitoring
COPY rook-external /etc/rook-external/
COPY ceph-csv-templates /etc/ceph-csv-templates
RUN useradd rook -u 2016 # 2016 is the UID of the rook user and also the year of the first commit in the project
USER 2016
ENTRYPOINT ["/usr/local/bin/rook"]
Expand Down
11 changes: 1 addition & 10 deletions images/ceph/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,6 @@ do.build:
@cp $(MANIFESTS_DIR)/create-external-cluster-resources.* $(BUILD_CONTEXT_DIR)/rook-external/
@cp ../../tests/ceph-status-out $(BUILD_CONTEXT_DIR)/rook-external/test-data/

ifeq ($(INCLUDE_CSV_TEMPLATES),true)
@$(MAKE) csv
@cp -r ../../build/csv $(BUILD_CONTEXT_DIR)/ceph-csv-templates
@rm $(BUILD_CONTEXT_DIR)/ceph-csv-templates/csv-gen.sh
@$(MAKE) csv-clean

else
mkdir $(BUILD_CONTEXT_DIR)/ceph-csv-templates
endif
@cd $(BUILD_CONTEXT_DIR) && $(SED_IN_PLACE) 's|BASEIMAGE|$(BASEIMAGE)|g' Dockerfile
@if [ -z "$(BUILD_CONTAINER_IMAGE)" ]; then\
$(DOCKERCMD) build $(BUILD_ARGS) \
Expand Down Expand Up @@ -125,11 +116,11 @@ csv: $(OPERATOR_SDK) $(YQv3)
@../../build/csv/csv-gen.sh
@# #adding 2>/dev/null since CI doesn't seems to be creating bundle.Dockerfile file
@rm bundle.Dockerfile 2> /dev/null || true
@git restore $(MANIFESTS_DIR)/crds.yaml ../../deploy/charts/rook-ceph/templates/resources.yaml

csv-clean: ## Remove existing OLM files.
@rm -fr ../../build/csv/ceph/${go env GOARCH}
@rm -f ../../build/csv/rook-ceph.clusterserviceversion.yaml
@git restore $(MANIFESTS_DIR)/crds.yaml ../../deploy/charts/rook-ceph/templates/resources.yaml

# reading from a file and outputting to the same file can have undefined results, so use this intermediate
IMAGE_TMP="/tmp/rook-ceph-image-list"
Expand Down
33 changes: 19 additions & 14 deletions tests/scripts/validate_modified_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ MOD_ERR="changes found by mod.check. You may need to run make clean"
CRD_ERR="changes found by 'make crds'. please run 'make crds' locally and update your PR"
BUILD_ERR="changes found by make build', please commit your go.sum or other changed files"
HELM_ERR="changes found by 'make gen-rbac'. please run 'make gen-rbac' locally and update your PR"
CSV_ERR="changes found by make gen-csv',please run 'make gen-csv' locally and update your PR"

#############
# FUNCTIONS #
#############
function validate(){
function validate() {
git=$(git status --porcelain)
for file in $git; do
if [ -n "$file" ]; then
Expand All @@ -29,22 +30,26 @@ function validate(){
# MAIN #
########
case "$1" in
codegen)
validate "$CODEGEN_ERR"
codegen)
validate "$CODEGEN_ERR"
;;
modcheck)
validate "$MOD_ERR"
modcheck)
validate "$MOD_ERR"
;;
crd)
validate "$CRD_ERR"
crd)
validate "$CRD_ERR"
;;
build)
validate "$BUILD_ERR"
build)
validate "$BUILD_ERR"
;;
gen-rbac)
validate "$HELM_ERR"
gen-rbac)
validate "$HELM_ERR"
;;
gen-csv)
validate "$CSV_ERR"
;;
*)
echo $"Usage: $0 {codegen|modcheck|crd|build|gen-rbac}"
exit 1
;;
*)
echo $"Usage: $0 {codegen|modcheck|crd|build|gen-rbac}"
exit 1
esac

0 comments on commit 8c066ca

Please sign in to comment.