Skip to content

Commit

Permalink
try another pass
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzsequence authored Jul 12, 2023
1 parent 4000c93 commit 706ee08
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions bin/test-dependencies-yml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,25 @@ valid_versions=true
echo "Checking ${filename} for valid versions..."

# Parse the YAML file and validate the current_tag values
while IFS=':' read -r key value; do
key=$(echo "${key}" | awk '{$1=$1};1')
value=$(echo "${value}" | awk '{$1=$1};1')

if [[ $key == "current_tag" ]]; then
echo -n "Validating version for ${prev_key}... "
if [[ ! $value =~ $version_pattern ]]; then
echo -e "${red}Invalid version: ${value}${reset}"
valid_versions=false
else
echo -e "${green}OK${reset}"
yq eval '(.dependencies[] | keys_unsorted) as $keys | .dependencies[] | .[. as $key | $keys[] | select(. == $key)][0] + ": " + .current_tag' "${filename}" | while IFS=':' read -r key value; do
key=$(echo "${key}" | awk '{$1=$1};1')
value=$(echo "${value}" | awk '{$1=$1};1')

if [[ $key != "" ]]; then
echo -n "Validating version for ${key}... "
if [[ ! $value =~ $version_pattern ]]; then
echo -e "${red}Invalid version: ${value}${reset}"
valid_versions=false
else
echo -e "${green}OK${reset}"
fi
fi
fi

prev_key=${key}
done <<< "$(yq eval '(.dependencies[] | keys) as $keys | .dependencies[] | .[. as $key | $keys[] | select(. == $key)][0] + ": " + .current_tag' ${filename})"
done

# Exit with an error code if any version comparison is invalid
if ! "$valid_versions"; then
echo -e "${red}One or more versions are invalid.${reset}"
exit 1
echo -e "${red}One or more versions are invalid.${reset}"
exit 1
else
echo -e "${green}All checks passed!${reset} 🎉"
echo -e "${green}All checks passed!${reset} 🎉"
fi

0 comments on commit 706ee08

Please sign in to comment.