Skip to content

Commit aa7a86f

Browse files
authored
Revert "hack: improve validate-boskos.sh with better error handling - Add dy…" (#70836)
This reverts commit d901dee.
1 parent 56a35c0 commit aa7a86f

File tree

1 file changed

+22
-90
lines changed

1 file changed

+22
-90
lines changed

hack/validate-boskos.sh

Lines changed: 22 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -7,93 +7,25 @@ set -o errexit
77
set -o nounset
88
set -o pipefail
99

10-
# Color codes for better output
11-
readonly RED='\033[0;31m'
12-
readonly GREEN='\033[0;32m'
13-
readonly YELLOW='\033[0;33m'
14-
readonly NC='\033[0m' # No Color
15-
16-
# Function to print colored output
17-
print_error() {
18-
echo -e "${RED}ERROR: $1${NC}" >&2
19-
}
20-
21-
print_info() {
22-
echo -e "${GREEN}INFO: $1${NC}"
23-
}
24-
25-
print_warning() {
26-
echo -e "${YELLOW}WARNING: $1${NC}"
27-
}
28-
29-
# Get the root directory of the repository
30-
get_repo_root() {
31-
local script_dir
32-
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
33-
echo "$(cd "${script_dir}/../.." && pwd)"
34-
}
35-
36-
main() {
37-
local repo_root
38-
repo_root="$(get_repo_root)"
39-
local config_dir="${repo_root}/core-services/prow/02_config"
40-
local config_file="_boskos.yaml"
41-
local generator_script="generate-boskos.py"
42-
43-
print_info "Validating Boskos configuration..."
44-
45-
# Check if required files exist
46-
if [[ ! -d "${config_dir}" ]]; then
47-
print_error "Configuration directory not found: ${config_dir}"
48-
exit 1
49-
fi
50-
51-
if [[ ! -f "${config_dir}/${generator_script}" ]]; then
52-
print_error "Generator script not found: ${config_dir}/${generator_script}"
53-
exit 1
54-
fi
55-
56-
cd "${config_dir}"
57-
58-
# Create backup of original file for cleanup
59-
local original_content
60-
if [[ ! -f "${config_file}" ]]; then
61-
print_error "Boskos configuration file not found: ${config_file}"
62-
exit 1
63-
fi
64-
original_content="$(cat "${config_file}")"
65-
66-
# Generate new configuration
67-
if ! python3 "./${generator_script}"; then
68-
print_error "Failed to generate Boskos configuration"
69-
# Restore original content if generation failed
70-
echo "${original_content}" > "${config_file}"
71-
exit 1
72-
fi
73-
74-
# Compare with original
75-
local diff_output
76-
if diff_output="$(diff -u <(echo "${original_content}") "${config_file}" 2>/dev/null)"; then
77-
print_info "Boskos configuration is up-to-date!"
78-
exit 0
79-
fi
80-
81-
# Configuration is out of date
82-
print_error "Boskos configuration is out-of-date!"
83-
echo
84-
print_warning "This check enforces that the Boskos configuration is generated"
85-
print_warning "correctly. We have automation in place that updates the configuration and"
86-
print_warning "new changes to the configuration should be followed with a re-generation."
87-
echo
88-
print_info "Run the following command to re-generate the Boskos configuration:"
89-
print_info "$ make boskos-config"
90-
echo
91-
print_info "The following changes are required:"
92-
echo "${diff_output}"
93-
94-
# Restore original file to avoid modifying the workspace
95-
echo "${original_content}" > "${config_file}"
96-
exit 1
97-
}
98-
99-
main "$@"
10+
base_dir=.
11+
12+
cd "${base_dir}/core-services/prow/02_config"
13+
ORIGINAL="$(cat _boskos.yaml)"
14+
./generate-boskos.py
15+
DIFF="$(diff -u <(echo "${ORIGINAL}") _boskos.yaml || true)"
16+
if test -n "${DIFF}"
17+
then
18+
cat << EOF
19+
ERROR: This check enforces that the Boskos configuration is generated
20+
ERROR: correctly. We have automation in place that updates the configuration and
21+
ERROR: new changes to the configuration should be followed with a re-generation.
22+
23+
ERROR: Run the following command to re-generate the Boskos configuration:
24+
ERROR: $ make boskos-config
25+
26+
ERROR: The following errors were found:
27+
28+
EOF
29+
echo "${DIFF}"
30+
exit 1
31+
fi

0 commit comments

Comments
 (0)