Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Merge self-upgrade into main #380

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions klone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,60 @@ targets:
- folder_name: api-docs
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: f17b4139e38425a1d8624af4e38d63df337f440f
repo_hash: d3fbbe92ebeace2b369fdc51eb785b42fe39d1d9
repo_path: modules/api-docs
- folder_name: boilerplate
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: f17b4139e38425a1d8624af4e38d63df337f440f
repo_hash: d3fbbe92ebeace2b369fdc51eb785b42fe39d1d9
repo_path: modules/boilerplate
- folder_name: cert-manager
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: f17b4139e38425a1d8624af4e38d63df337f440f
repo_hash: d3fbbe92ebeace2b369fdc51eb785b42fe39d1d9
repo_path: modules/cert-manager
- folder_name: controller-gen
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: f17b4139e38425a1d8624af4e38d63df337f440f
repo_hash: d3fbbe92ebeace2b369fdc51eb785b42fe39d1d9
repo_path: modules/controller-gen
- folder_name: generate-verify
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: f17b4139e38425a1d8624af4e38d63df337f440f
repo_hash: d3fbbe92ebeace2b369fdc51eb785b42fe39d1d9
repo_path: modules/generate-verify
- folder_name: helm
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: f17b4139e38425a1d8624af4e38d63df337f440f
repo_hash: d3fbbe92ebeace2b369fdc51eb785b42fe39d1d9
repo_path: modules/helm
- folder_name: help
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: f17b4139e38425a1d8624af4e38d63df337f440f
repo_hash: d3fbbe92ebeace2b369fdc51eb785b42fe39d1d9
repo_path: modules/help
- folder_name: kind
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: f17b4139e38425a1d8624af4e38d63df337f440f
repo_hash: d3fbbe92ebeace2b369fdc51eb785b42fe39d1d9
repo_path: modules/kind
- folder_name: klone
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: f17b4139e38425a1d8624af4e38d63df337f440f
repo_hash: d3fbbe92ebeace2b369fdc51eb785b42fe39d1d9
repo_path: modules/klone
- folder_name: oci-image
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: f17b4139e38425a1d8624af4e38d63df337f440f
repo_hash: d3fbbe92ebeace2b369fdc51eb785b42fe39d1d9
repo_path: modules/oci-image
- folder_name: repository-base
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: f17b4139e38425a1d8624af4e38d63df337f440f
repo_hash: d3fbbe92ebeace2b369fdc51eb785b42fe39d1d9
repo_path: modules/repository-base
- folder_name: tools
repo_url: https://github.com/cert-manager/makefile-modules.git
repo_ref: main
repo_hash: f17b4139e38425a1d8624af4e38d63df337f440f
repo_hash: d3fbbe92ebeace2b369fdc51eb785b42fe39d1d9
repo_path: modules/tools
4 changes: 3 additions & 1 deletion make/_shared/help/01_mod.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ help_sh := $(dir $(lastword $(MAKEFILE_LIST)))/help.sh

.PHONY: help
help:
@MAKEFILE_LIST="$(MAKEFILE_LIST)" $(help_sh)
@MAKEFILE_LIST="$(MAKEFILE_LIST)" \
MAKE="$(MAKE)" \
$(help_sh)
36 changes: 31 additions & 5 deletions make/_shared/help/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

set -eu -o pipefail

RULE_COLOR="$(tput setaf 6)"
CATEGORY_COLOR="$(tput setaf 3)"
CLEAR_STYLE="$(tput sgr0)"
PURPLE=$(tput setaf 125)
## 1. Build set of extracted line items

EMPTYLINE_REGEX="^[[:space:]]*$"
DOCBLOCK_REGEX="^##[[:space:]]*(.*)$"
Expand All @@ -28,7 +25,6 @@ TARGET_REGEX="^(([a-zA-Z0-9\_\/\%\$\(\)]|-)+):.*$"

EMPTY_ITEM="<start-category><end-category><start-target><end-target><start-comment><end-comment>"


# shellcheck disable=SC2086
raw_lines=$(cat ${MAKEFILE_LIST} | tr '\t' ' ' | grep -E "($TARGET_REGEX|$DOCBLOCK_REGEX|$EMPTYLINE_REGEX)")
extracted_lines=""
Expand Down Expand Up @@ -56,6 +52,28 @@ while read -r line; do
fi
done <<< "$raw_lines"

## 2. Build mapping for expanding targets

ASSIGNMENT_REGEX="^(([a-zA-Z0-9\_\/\%\$\(\)]|-)+)\s*:=\s*(.*)$"

raw_expansions=$(${MAKE} --dry-run --print-data-base noop | tr '\t' ' ' | grep -E "$ASSIGNMENT_REGEX")
extracted_expansions=""

while read -r line; do
if [[ $line =~ $ASSIGNMENT_REGEX ]]; then
target=${BASH_REMATCH[1]}
expansion=${BASH_REMATCH[3]// /, }
extracted_expansions="$extracted_expansions\n<start-target>$target<end-target><start-expansion>$expansion<end-expansion>"
fi
done <<< "$raw_expansions"

## 3. Sort and print the extracted line items

RULE_COLOR="$(tput setaf 6)"
CATEGORY_COLOR="$(tput setaf 3)"
CLEAR_STYLE="$(tput sgr0)"
PURPLE=$(tput setaf 125)

extracted_lines=$(echo -e "$extracted_lines" | LC_ALL=C sort -r)
current_category=""

Expand All @@ -67,11 +85,19 @@ IFS=$'\n'; for line in $extracted_lines; do
target=$([[ $line =~ \<start-target\>(.*)\<end-target\> ]] && echo "${BASH_REMATCH[1]}")
comment=$([[ $line =~ \<start-comment\>(.*)\<end-comment\> ]] && echo -e "${BASH_REMATCH[1]//<newline>/\\n}")

# Print the category header if it's changed
if [[ "$current_category" != "$category" ]]; then
current_category=$category
echo -e "\n${CATEGORY_COLOR}${current_category}${CLEAR_STYLE}"
fi

# replace any $(...) with the actual value
if [[ $target =~ \$\((.*)\) ]]; then
target=$(echo -e "$extracted_expansions" | grep "<start-target>${BASH_REMATCH[1]}<end-target>")
target=$([[ $target =~ \<start-expansion\>(.*)\<end-expansion\> ]] && echo -e "${BASH_REMATCH[1]}")
fi

# Print the target and its multiline comment
is_first_line=true
while read -r comment_line; do
if [[ "$is_first_line" == true ]]; then
Expand Down