diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 6319735e2..29570215e 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -142,24 +142,27 @@ function check_incorrect_makefile_variable_brackets() { } function pre_commit() { + if [[ "${MDB_UPDATE_LICENSES:-""}" == "true" ]]; then + ( (time update_licenses) 2>&1 | prepend "update_licenses" ) & + fi + ( (time scripts/evergreen/lint_code.sh) 2>&1 | prepend "lint_code.sh" ) & + ( (time start_shellcheck) 2>&1 | prepend "shellcheck" ) & + # Update release.json first in case there is a newer version (time update_release_json) 2>&1 | prepend "update_release_json" # We need to generate the values files first (time update_values_yaml_files) 2>&1 | prepend "update_values_yaml_files" # The values files are used for generating the standalone yaml (time generate_standalone_yaml) 2>&1 | prepend "generate_standalone_yaml" - # Run black on python files that have changed - (time python_formatting) 2>&1 | prepend "python_formatting" - - (time regenerate_public_rbac_multi_cluster) 2>&1 | prepend "regenerate_public_rbac_multi_cluster" - (time start_shellcheck) 2>&1 | prepend "shellcheck" + ( (time regenerate_public_rbac_multi_cluster) 2>&1 | prepend "regenerate_public_rbac_multi_cluster" ) & - (time check_erroneous_kubebuilder_annotations) 2>&1 | prepend "check_erroneous_kubebuilder_annotations" + # Run black and isort on python files that have changed + ( (time python_formatting) 2>&1 | prepend "python_formatting") & - (time scripts/evergreen/lint_code.sh) 2>&1 | prepend "lint_code.sh" + ( (time check_erroneous_kubebuilder_annotations) 2>&1 | prepend "check_erroneous_kubebuilder_annotations" ) & - (time update_licenses) 2>&1 | prepend "update_licenses" + wait } # Function to run shellcheck on a single file @@ -196,7 +199,7 @@ if [[ "${cmd}" == "generate_standalone_yaml" ]]; then shift 1 generate_standalone_yaml "$@" elif [[ "${cmd}" == "pre-commit" ]]; then - pre_commit + time pre_commit elif [[ "${cmd}" == "shellcheck" ]]; then start_shellcheck elif [[ "${cmd}" == "lint" ]]; then diff --git a/Makefile b/Makefile index 9a27d8153..9c45c1c3b 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,10 @@ prerequisites: @ scripts/dev/install.sh precommit: - @ EVERGREEN_MODE=true .githooks/pre-commit + @ .githooks/pre-commit + +precommit-with-licenses: + @ MDB_UPDATE_LICENSE=true .githooks/pre-commit switch: @ scripts/dev/switch_context.sh $(context) $(additional_override) diff --git a/scripts/dev/contexts/evg-private-context b/scripts/dev/contexts/evg-private-context index f8080cbcb..8f25842e8 100644 --- a/scripts/dev/contexts/evg-private-context +++ b/scripts/dev/contexts/evg-private-context @@ -120,3 +120,5 @@ export cognito_workload_federation_client_secret="${cognito_workload_federation_ export cognito_user_password="${cognito_user_password}" export cognito_workload_url="${cognito_workload_url}" export cognito_workload_user_id="${cognito_workload_user_id}" + +export MDB_UPDATE_LICENSES=true diff --git a/scripts/dev/contexts/private-context-template b/scripts/dev/contexts/private-context-template index d69887199..f1809728e 100644 --- a/scripts/dev/contexts/private-context-template +++ b/scripts/dev/contexts/private-context-template @@ -99,3 +99,6 @@ export e2e_cloud_qa_user_owner_static_2="${OM_USER}" # TODO to be removed at public preview stage of community-search export COMMUNITY_PRIVATE_PREVIEW_PULLSECRET_DOCKERCONFIGJSON="" + +# uncomment to enable license update with pre-commit script +# export MDB_UPDATE_LICENSES=true