From 09c1e937ee46ba612623a108d2077cf802f85d36 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Sat, 26 Nov 2022 22:11:18 +0000 Subject: [PATCH 1/4] fix: manifest.json: add v1.37 to versions array --- manifest.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index a74ff9134..fecab03d9 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,14 @@ { - "versions": ["v1.36", "v1.35", "v1.34", "v1.33", "v1.32", "v1.31", "v1.30"], + "versions": [ + "v1.37", + "v1.36", + "v1.35", + "v1.34", + "v1.33", + "v1.32", + "v1.31", + "v1.30" + ], "routes": [ { "path": "./index.md", From b938db0d4313ddca82154d3ee5bf2a8647c8efdc Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 28 Nov 2022 10:42:48 +0000 Subject: [PATCH 2/4] chore: add script to validate manifest versions --- package.json | 3 +++ scripts/validate-manifest.sh | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100755 scripts/validate-manifest.sh diff --git a/package.json b/package.json index 75c944fd1..a44b6b8d3 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,9 @@ "*.md": [ "markdownlint --config .markdownlint.jsonc --rules .markdownlint-rules --fix", "prettier --write" + ], + "manifest.json": [ + "./scripts/validate-manifest.sh" ] }, "dependencies": { diff --git a/scripts/validate-manifest.sh b/scripts/validate-manifest.sh new file mode 100755 index 000000000..9613b98a1 --- /dev/null +++ b/scripts/validate-manifest.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# +# validate-manifest.sh [path/to/manifest.json] +# +# Dependencies: jq tr sort uniq +# +# Description: Ensures consistency of versions specified in manifest.json. +# This script takes no arguments. Returns 0 if no issues found. + +set -eou pipefail + +if ! command -v jq > /dev/null; then + echo "This script requires jq to be available." + exit 1 +fi + +GIT_ROOT=$(git rev-parse --show-toplevel) +MANIFEST_JSON_PATH=${1:-"${GIT_ROOT}/manifest.json"} + +declare -a MANIFEST_VERSIONS +declare -a ROUTE_VERSIONS + +# Read the versions array in manifest.json +readarray -t MANIFEST_VERSIONS < <(jq -r ' + .versions[] + | capture("(?[0-9]+\\.[0-9]+)") + | .v' < "${MANIFEST_JSON_PATH}") + +# Read all the child paths of changelog/index.md and extract major.minor version +readarray -t ROUTE_VERSIONS < <(jq -r ' + .routes[] + | select(.path == "./changelog/index.md") + | .children[] + | .path | + capture("(?[0-9]+\\.[0-9]+)") + | .v' < "${MANIFEST_JSON_PATH}") + +# Compare the two +DIFF=$(echo "${MANIFEST_VERSIONS[@]}" "${ROUTE_VERSIONS[@]}" | tr ' ' '\n' | sort | uniq -u) +if [[ -n $DIFF ]]; then + echo "manifest.json: missing version for changelog(s): ${DIFF}" + exit 1 +fi + +exit 0 \ No newline at end of file From 217bcd9ad551fe48d6132b58b177bb2289d27e0b Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 28 Nov 2022 10:48:40 +0000 Subject: [PATCH 3/4] fixup! chore: add script to validate manifest versions --- scripts/validate-manifest.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/validate-manifest.sh b/scripts/validate-manifest.sh index 9613b98a1..28b3d749a 100755 --- a/scripts/validate-manifest.sh +++ b/scripts/validate-manifest.sh @@ -5,7 +5,6 @@ # Dependencies: jq tr sort uniq # # Description: Ensures consistency of versions specified in manifest.json. -# This script takes no arguments. Returns 0 if no issues found. set -eou pipefail From e921c8d0cc85b404fca4b8aa05e8e6029370d5f9 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 28 Nov 2022 11:18:15 +0000 Subject: [PATCH 4/4] address PR comments --- scripts/validate-manifest.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/validate-manifest.sh b/scripts/validate-manifest.sh index 28b3d749a..b882011b0 100755 --- a/scripts/validate-manifest.sh +++ b/scripts/validate-manifest.sh @@ -2,18 +2,23 @@ # # validate-manifest.sh [path/to/manifest.json] # -# Dependencies: jq tr sort uniq +# Dependencies: bash>=4.x jq tr sort uniq # # Description: Ensures consistency of versions specified in manifest.json. -set -eou pipefail +set -euo pipefail + +if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then + echo "This script requires at least bash version 4." + exit 1 +fi if ! command -v jq > /dev/null; then echo "This script requires jq to be available." exit 1 fi -GIT_ROOT=$(git rev-parse --show-toplevel) +GIT_ROOT=$(cd "$(dirname "$0")" && git rev-parse --show-toplevel) MANIFEST_JSON_PATH=${1:-"${GIT_ROOT}/manifest.json"} declare -a MANIFEST_VERSIONS