From 9568d28d77583fcda2af5536ce477a2b97379720 Mon Sep 17 00:00:00 2001 From: Stanislav Zhuk Date: Thu, 4 Jun 2026 14:22:27 +0300 Subject: [PATCH 1/2] feat(update-checker): check for `#ddev-generated` comment --- .github/scripts/update-checker.sh | 59 +++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/.github/scripts/update-checker.sh b/.github/scripts/update-checker.sh index 979a158..abe97f3 100755 --- a/.github/scripts/update-checker.sh +++ b/.github/scripts/update-checker.sh @@ -316,6 +316,62 @@ check_license() { fi } +# Check that files listed in install.yaml project_files/global_files contain exactly one #ddev-generated +check_ddev_generated() { + local install_yaml="install.yaml" + + local line entry count in_section section dir_file + local list_item_re='^[[:space:]]*-[[:space:]]+(.*)' + + for section in project_files global_files; do + in_section=false + while IFS= read -r line; do + # Detect section header + if [[ "$line" == "${section}:" ]]; then + in_section=true + continue + fi + + [[ "$in_section" != "true" ]] && continue + + # A top-level YAML key (starts with a letter) ends the section + [[ "$line" =~ ^[a-zA-Z] ]] && break + + # Match non-commented list entries with any indentation: "- " + [[ "$line" =~ $list_item_re ]] || continue + entry="${BASH_REMATCH[1]}" + + [[ -z "$entry" ]] && continue + + # Skip entries with environment variable interpolation (can't resolve at check time) + [[ "$entry" =~ \$\{ ]] && continue + + # For directories, check all files inside recursively + if [[ -d "$entry" ]]; then + while IFS= read -r -d '' dir_file; do + count=$(grep -c "#ddev-generated" "$dir_file" 2>/dev/null) || count=0 + if [[ "$count" -eq 0 ]]; then + actions+=("$dir_file (in directory $entry listed in install.yaml $section) does not contain '#ddev-generated'") + elif [[ "$count" -gt 1 ]]; then + actions+=("$dir_file (in directory $entry listed in install.yaml $section) should contain exactly one '#ddev-generated', found $count occurrences") + fi + done < <(find "$entry" -type f -print0 2>/dev/null) + continue + fi + + [[ ! -f "$entry" ]] && continue + + count=$(grep -c "#ddev-generated" "$entry" 2>/dev/null) || count=0 + + if [[ "$count" -eq 0 ]]; then + actions+=("$entry is listed in install.yaml ($section) but does not contain '#ddev-generated'") + elif [[ "$count" -gt 1 ]]; then + actions+=("$entry is listed in install.yaml ($section) should contain exactly one '#ddev-generated', found $count occurrences") + fi + done < "$install_yaml" + done +} + # Check .gitattributes check_gitattributes() { local gitattributes=".gitattributes" @@ -415,6 +471,9 @@ run_checks() { # Check install.yaml for conditions check_install_yaml + # Check #ddev-generated in files listed in install.yaml + check_ddev_generated + # Check docker-compose.*.yaml for conditions check_docker_compose_yaml From 8e98c425c85277b5632d1f7a0b7075811e635766 Mon Sep 17 00:00:00 2001 From: Stanislav Zhuk Date: Thu, 4 Jun 2026 14:28:36 +0300 Subject: [PATCH 2/2] don't warn for several #ddev-generated, the file may write #ddev-generated comment to another file --- .github/scripts/update-checker.sh | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/scripts/update-checker.sh b/.github/scripts/update-checker.sh index abe97f3..89bf6a6 100755 --- a/.github/scripts/update-checker.sh +++ b/.github/scripts/update-checker.sh @@ -316,11 +316,11 @@ check_license() { fi } -# Check that files listed in install.yaml project_files/global_files contain exactly one #ddev-generated +# Check that files listed in install.yaml project_files/global_files contain #ddev-generated check_ddev_generated() { local install_yaml="install.yaml" - local line entry count in_section section dir_file + local line entry in_section section dir_file local list_item_re='^[[:space:]]*-[[:space:]]+(.*)' for section in project_files global_files; do @@ -349,11 +349,8 @@ check_ddev_generated() { # For directories, check all files inside recursively if [[ -d "$entry" ]]; then while IFS= read -r -d '' dir_file; do - count=$(grep -c "#ddev-generated" "$dir_file" 2>/dev/null) || count=0 - if [[ "$count" -eq 0 ]]; then + if ! grep -q "#ddev-generated" "$dir_file" 2>/dev/null; then actions+=("$dir_file (in directory $entry listed in install.yaml $section) does not contain '#ddev-generated'") - elif [[ "$count" -gt 1 ]]; then - actions+=("$dir_file (in directory $entry listed in install.yaml $section) should contain exactly one '#ddev-generated', found $count occurrences") fi done < <(find "$entry" -type f -print0 2>/dev/null) continue @@ -361,12 +358,8 @@ check_ddev_generated() { [[ ! -f "$entry" ]] && continue - count=$(grep -c "#ddev-generated" "$entry" 2>/dev/null) || count=0 - - if [[ "$count" -eq 0 ]]; then + if ! grep -q "#ddev-generated" "$entry" 2>/dev/null; then actions+=("$entry is listed in install.yaml ($section) but does not contain '#ddev-generated'") - elif [[ "$count" -gt 1 ]]; then - actions+=("$entry is listed in install.yaml ($section) should contain exactly one '#ddev-generated', found $count occurrences") fi done < "$install_yaml" done