[bitnami/*] Add ASCII validator (#26676)

* [bitnami/*] Add ASCII validator

Signed-off-by: Fran Mulero <fmulero@vmware.com>

* Remove preivous validation

Signed-off-by: Fran Mulero <fmulero@vmware.com>

* Fix grep expression

Signed-off-by: Fran Mulero <fmulero@vmware.com>

---------

Signed-off-by: Fran Mulero <fmulero@vmware.com>
This commit is contained in:
Fran Mulero
2024-06-04 12:32:49 +02:00
committed by GitHub
parent a85830c827
commit 629da67d75
2 changed files with 48 additions and 6 deletions

View File

@@ -195,12 +195,6 @@ jobs:
echo "error=Please ensure all *.tag params are skipped (@skip) in the bitnami/${CHART}/values.yaml file"
exit "$exit_code"
fi
# Ensuring no unprintable characters are present in values.yaml
! grep --quiet "[^[:print:]]" "bitnami/${CHART}/values.yaml" || exit_code=$?
if [[ $exit_code -ne 0 ]]; then
echo "error=Please ensure there are no unprintable characters in the bitnami/${CHART}/values.yaml file"
exit "$exit_code"
fi
echo "Updating README.md for bitnami/${CHART}"
readme-generator --values "bitnami/${CHART}/values.yaml" --readme "bitnami/${CHART}/README.md" --schema "/tmp/schema.json"
# Commit all changes, if any

View File

@@ -0,0 +1,48 @@
# Copyright Broadcom, Inc. All Rights Reserved.
# SPDX-License-Identifier: APACHE-2.0
name: '[CI/CD] Values ASCII validator'
on:
pull_request:
branches:
- main
paths:
- '**/values.yaml'
# Remove all permissions by default
permissions: {}
jobs:
values-ascii:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout project
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- name: Values ASCII validator
env:
DIFF_URL: "${{github.event.pull_request.diff_url}}"
TEMP_FILE: "${{runner.temp}}/pr-${{github.event.number}}.diff"
TEMP_OUTPUT: "${{runner.temp}}/output"
run: |
# This request doesn't consume API calls.
curl -Lkso $TEMP_FILE $DIFF_URL
files_changed="$(sed -nr 's/[\-\+]{3} [ab]\/(.*)/\1/p' $TEMP_FILE | sort | uniq)"
values_files="$(echo "$files_changed" | grep -o ".*values\.yaml$" | sort | uniq || true)"
# Create an empty file, useful when the PR changes ignored files
touch "${TEMP_OUTPUT}"
grep -nHP "[\x80-\xFF]" "${values_files[@]}" | sort -u > ${TEMP_OUTPUT} || true
while read -r line; do
# line format:
# file:row:message
# Split by ':'
readarray -d : -t strarr < <(printf '%s' "$line")
if [[ "${#strarr[@]}" -ge 3 ]]; then
echo "::warning file=${strarr[0]},line=${strarr[1]}:: Non ASCII character in '${strarr[@]:2}'"
else
echo "::warning:: Error processing: ${line}"
fi
done < "${TEMP_OUTPUT}"
if [[ -s ${TEMP_OUTPUT} ]]; then
echo "::error:: Please review warning messages"
exit 1
fi