From 8f5d80ab5e45365d4518065ab87ac57adbca5400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=E1=B4=87=CA=80=C9=B4=E1=B4=85=20S=E1=B4=84=CA=9C?= =?UTF-8?q?=E1=B4=8F=CA=80=C9=A2=E1=B4=87=CA=80s?= Date: Thu, 6 Jan 2022 13:02:21 +0100 Subject: [PATCH] ci: Update linting script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs --- .github/workflows/charts-validate.yaml | 1 + hack/check-releasenotes.sh | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/charts-validate.yaml b/.github/workflows/charts-validate.yaml index a7742d71..d962ed1f 100644 --- a/.github/workflows/charts-validate.yaml +++ b/.github/workflows/charts-validate.yaml @@ -246,6 +246,7 @@ jobs: # Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7 lint_success: needs: + - changes-lint - lint if: | always() && diff --git a/hack/check-releasenotes.sh b/hack/check-releasenotes.sh index de2c8784..867cffb0 100755 --- a/hack/check-releasenotes.sh +++ b/hack/check-releasenotes.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash -set -eu +set -e # Check if release notes have been changed # Usage ./check-releasenotes.sh path # require yq command -v yq >/dev/null 2>&1 || { - echo >&2 "yq (https://github.com/mikefarah/yq) is not installed. Aborting." + printf >&2 "%s\n" "yq (https://github.com/mikefarah/yq) is not installed. Aborting." exit 1 } @@ -19,17 +19,21 @@ if [ $# -ge 1 ] && [ -n "$1" ]; then root="$1" chart_file="${1}/Chart.yaml" if [ ! -f "$chart_file" ]; then - echo "File ${chart_file} does not exist." + printf >&2 "File %s\n does not exist.\n" "${chart_file}" exit 1 fi - echo "Validating release notes for $root" - cd $root + + if [ -z "$DEFAULT_BRANCH" ]; then + DEFAULT_BRANCH=$(git remote show origin | awk '/HEAD branch/ {print $NF}') + fi + + printf "Checking changelog annotation for chart %s\n" "$root" CURRENT=$(cat Chart.yaml | yq e '.annotations."artifacthub.io/changes"' -P -) if [ "$CURRENT" == "" ] || [ "$CURRENT" == "null" ]; then - echo >&2 "Release notes have not been set for this chart!" + printf >&2 "%s\n" "Changelog annotation has not been set for this chart!" exit 1 fi @@ -37,10 +41,16 @@ if [ $# -ge 1 ] && [ -n "$1" ]; then ORIGINAL=$(git show origin/$DEFAULT_BRANCH:./Chart.yaml | yq e '.annotations."artifacthub.io/changes"' -P -) if [ "$CURRENT" == "$ORIGINAL" ]; then - echo >&2 "Release notes have not been updated!" + printf >&2 "%s\n" "Changelog annotation has not been updated!" + # exit 1 + fi + + printf "Checking README.md for chart %s\n" "$root" + if diff README.md <(git show origin/$DEFAULT_BRANCH:./README.md) >/dev/null; then + printf >&2 "%s\n" "README.md has not been updated!" exit 1 fi else - echo >&2 "No chart folder has been specified." + printf >&2 "%s\n" "No chart folder has been specified." exit 1 fi