Skip to content

Commit b53466c

Browse files
authored
fix: re-order statements and add on-line help (#900)
- Makefile line order is important, so by convention variables are declared at the top, then specific rules, then generic rules, and finally pattern rules. Make itself is flexible about these high-level groups, but not following this order can yield subtle and hard to debug problems as lines are parsed and interpreted as they are being read. - In this Makefile, we also use some parsing magic to generate an on-line help automatically, but this requires to follow the pattern: ``` target-name: target-dependencies* ## one-line on line help ``` You can declare groups with `##@ group-name`. This affects only the presentation of the on-line help, please check the Makefile to see how it is used.
1 parent 3544b77 commit b53466c

1 file changed

Lines changed: 44 additions & 45 deletions

File tree

Makefile

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,43 @@ tests: test_setup main_tests schemathesis_tests collect_coverage ## Run all tes
141141
pre_commit_checks: ## Run pre-commit checks
142142
poetry run pre-commit run --all-files
143143

144+
##@ Helm/k8s
145+
146+
.PHONY: k3d_cluster
147+
k3d_cluster: ## Creates a k3d cluster for testing
148+
./setup-k3d-cluster.sh --reset --deploy-shipwright
149+
150+
.PHONY: install_amaltheas
151+
install_amaltheas: ## Installs both version of amalthea in the. NOTE: It uses the currently active k8s context.
152+
helm repo add renku https://swissdatasciencecenter.github.io/helm-charts
153+
helm repo update
154+
helm upgrade --install amalthea-js renku/amalthea --version $(AMALTHEA_JS_VERSION)
155+
helm upgrade --install amalthea-se renku/amalthea-sessions --version ${AMALTHEA_SESSIONS_VERSION}
156+
157+
# TODO: Add the version variables from the top of the file here when the charts are fully published
158+
.PHONY: amalthea_schema
159+
amalthea_schema: ## Updates generates pydantic classes from CRDs
160+
curl https://raw.githubusercontent.com/SwissDataScienceCenter/amalthea/${AMALTHEA_SESSIONS_VERSION}/config/crd/bases/amalthea.dev_amaltheasessions.yaml | yq '.spec.versions[0].schema.openAPIV3Schema' | poetry run datamodel-codegen --output components/renku_data_services/notebooks/cr_amalthea_session.py --base-class renku_data_services.notebooks.cr_base.BaseCRD ${CR_CODEGEN_PARAMS}
161+
curl https://raw.githubusercontent.com/SwissDataScienceCenter/amalthea/${AMALTHEA_JS_VERSION}/controller/crds/jupyter_server.yaml | yq '.spec.versions[0].schema.openAPIV3Schema' | poetry run datamodel-codegen --output components/renku_data_services/notebooks/cr_jupyter_server.py --base-class renku_data_services.notebooks.cr_base.BaseCRD ${CR_CODEGEN_PARAMS}
162+
163+
.PHONY: shipwright_schema
164+
shipwright_schema: ## Updates the Shipwright pydantic classes
165+
curl https://raw.githubusercontent.com/shipwright-io/build/refs/tags/v0.15.2/deploy/crds/shipwright.io_buildruns.yaml | yq '.spec.versions[] | select(.name == "v1beta1") | .schema.openAPIV3Schema' | poetry run datamodel-codegen --output components/renku_data_services/session/cr_shipwright_buildrun.py --base-class renku_data_services.session.cr_base.BaseCRD ${CR_CODEGEN_PARAMS}
166+
167+
##@ Devcontainer
168+
169+
.PHONY: devcontainer_up
170+
devcontainer_up: ## Start dev containers
171+
devcontainer up --workspace-folder .
172+
173+
.PHONY: devcontainer_rebuild
174+
devcontainer_rebuild: ## Rebuild dev containers images
175+
devcontainer up --remove-existing-container --workspace-folder .
176+
177+
.PHONY: devcontainer_exec
178+
devcontainer_exec: devcontainer_up ## Start a shell in the development container
179+
devcontainer exec --container-id renku-data-services_devcontainer-data_service-1 -- bash
180+
144181
##@ General
145182

146183
.PHONY: run
@@ -155,6 +192,13 @@ debug: ## Debug the sanic server
155192
run-tasks: ## Run the data tasks
156193
DUMMY_STORES=true poetry run python bases/renku_data_services/data_tasks/main.py
157194

195+
.PHONY: lock
196+
lock: ## Update the lock files for all projects from their repsective poetry.toml
197+
poetry lock $(ARGS)
198+
poetry -C projects/renku_data_service lock $(ARGS)
199+
poetry -C projects/secrets_storage lock $(ARGS)
200+
poetry -C projects/k8s_watcher lock $(ARGS)
201+
poetry -C projects/renku_data_tasks lock $(ARGS)
158202

159203
# From the operator sdk Makefile
160204
# The help target prints out all targets with their descriptions organized
@@ -171,29 +215,6 @@ run-tasks: ## Run the data tasks
171215
help: ## Display this help.
172216
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
173217

174-
##@ Helm/k8s
175-
176-
.PHONY: k3d_cluster
177-
k3d_cluster: ## Creates a k3d cluster for testing
178-
./setup-k3d-cluster.sh --reset --deploy-shipwright
179-
180-
.PHONY: install_amaltheas
181-
install_amaltheas: ## Installs both version of amalthea in the. NOTE: It uses the currently active k8s context.
182-
helm repo add renku https://swissdatasciencecenter.github.io/helm-charts
183-
helm repo update
184-
helm upgrade --install amalthea-js renku/amalthea --version $(AMALTHEA_JS_VERSION)
185-
helm upgrade --install amalthea-se renku/amalthea-sessions --version ${AMALTHEA_SESSIONS_VERSION}
186-
187-
# TODO: Add the version variables from the top of the file here when the charts are fully published
188-
.PHONY: amalthea_schema
189-
amalthea_schema: ## Updates generates pydantic classes from CRDs
190-
curl https://raw.githubusercontent.com/SwissDataScienceCenter/amalthea/${AMALTHEA_SESSIONS_VERSION}/config/crd/bases/amalthea.dev_amaltheasessions.yaml | yq '.spec.versions[0].schema.openAPIV3Schema' | poetry run datamodel-codegen --output components/renku_data_services/notebooks/cr_amalthea_session.py --base-class renku_data_services.notebooks.cr_base.BaseCRD ${CR_CODEGEN_PARAMS}
191-
curl https://raw.githubusercontent.com/SwissDataScienceCenter/amalthea/${AMALTHEA_JS_VERSION}/controller/crds/jupyter_server.yaml | yq '.spec.versions[0].schema.openAPIV3Schema' | poetry run datamodel-codegen --output components/renku_data_services/notebooks/cr_jupyter_server.py --base-class renku_data_services.notebooks.cr_base.BaseCRD ${CR_CODEGEN_PARAMS}
192-
193-
.PHONY: shipwright_schema
194-
shipwright_schema: ## Updates the Shipwright pydantic classes
195-
curl https://raw.githubusercontent.com/shipwright-io/build/refs/tags/v0.15.2/deploy/crds/shipwright.io_buildruns.yaml | yq '.spec.versions[] | select(.name == "v1beta1") | .schema.openAPIV3Schema' | poetry run datamodel-codegen --output components/renku_data_services/session/cr_shipwright_buildrun.py --base-class renku_data_services.session.cr_base.BaseCRD ${CR_CODEGEN_PARAMS}
196-
197218
# Pattern rules
198219

199220
API_SPEC_CODEGEN_PARAMS := ${CODEGEN_PARAMS}
@@ -205,25 +226,3 @@ API_SPEC_CODEGEN_PARAMS := ${CODEGEN_PARAMS}
205226
# newer than the requirements these steps won't be re-triggered.
206227
# Ignore the return value when there are more differences.
207228
( git diff --exit-code -I "^# timestamp\: " $@ >/dev/null && git checkout $@ ) || true
208-
209-
# Devcontainer
210-
211-
.PHONY: devcontainer_up
212-
devcontainer_up:
213-
devcontainer up --workspace-folder .
214-
215-
.PHONY: devcontainer_rebuild
216-
devcontainer_rebuild:
217-
devcontainer up --remove-existing-container --workspace-folder .
218-
219-
.PHONY: devcontainer_exec
220-
devcontainer_exec: devcontainer_up
221-
devcontainer exec --container-id renku-data-services_devcontainer-data_service-1 -- bash
222-
223-
.PHONY: lock
224-
lock:
225-
poetry lock $(ARGS)
226-
poetry -C projects/renku_data_service lock $(ARGS)
227-
poetry -C projects/secrets_storage lock $(ARGS)
228-
poetry -C projects/k8s_watcher lock $(ARGS)
229-
poetry -C projects/renku_data_tasks lock $(ARGS)

0 commit comments

Comments
 (0)