README.md version match check (#916)

* README.md version match check

Signed-off-by: Kevin Fox <[email protected]>

* Fix existing version issues

Signed-off-by: Kevin Fox <[email protected]>

* Fix existing version issues

Signed-off-by: Kevin Fox <[email protected]>

---------

Signed-off-by: Kevin Fox <[email protected]>
This commit is contained in:
kfox1111
2026-08-21 05:22:55 -07:00
committed by GitHub
parent 27026e4657
commit b47ab6c197
9 changed files with 142 additions and 5 deletions
+114
View File
@@ -0,0 +1,114 @@
#!/usr/bin/env bash
# Verify that the shields.io version badges in each top-level chart README
# agree with the version and appVersion declared in the sibling Chart.yaml.
# Nothing regenerates those badges, so they drift silently as charts are bumped.
#
# READMEs without a Version badge (library charts, hand written docs) are
# skipped. A leading 'v' is ignored when comparing, so 'v0.3.0' matches '0.3.0'.
set -euo pipefail
SCRIPT="$(readlink -f "$0")"
SCRIPTPATH="$(dirname "${SCRIPT}")"
REPO_ROOT="$(dirname "${SCRIPTPATH}")/.."
function print_problem {
echo >&2 "${*}"
}
function require_command {
command -v "$1" >/dev/null 2>&1 || {
print_problem "$2"
exit 1
}
}
# Print the value of a shields.io badge as "<alt text> <url value>", or nothing
# at all when the badge is absent. Each version is spelled twice in the badge
# markup, and both spellings need checking.
function badge_values {
local readme="$1"
local name="$2"
local badge alt url
badge="$(grep -o "!\[${name}: [^]]*\](https://img.shields.io/badge/${name}-[^)]*)" "${readme}" | head -1 || true)"
if [ -z "${badge}" ]; then
return 0
fi
alt="$(printf '%s' "${badge}" | sed "s#^!\[${name}: \([^]]*\)\].*#\1#")"
# shields.io escapes a literal dash in the value as '--'
url="$(printf '%s' "${badge}" | sed "s#.*/badge/${name}-\(.*\)-informational.*#\1#; s#--#-#g")"
printf '%s %s' "${alt}" "${url}"
}
# Compare two versions, ignoring a single leading 'v' on either side.
function versions_match {
[ "${1#v}" = "${2#v}" ]
}
require_command yq 'yq is required to run this script'
problems=0
for chart_yaml in "${REPO_ROOT}"/charts/*/Chart.yaml; do
[ -f "${chart_yaml}" ] || continue
chart_dir="$(dirname "${chart_yaml}")"
readme="${chart_dir}/README.md"
label="charts/$(basename "${chart_dir}")/README.md"
[ -f "${readme}" ] || continue
version_badge="$(badge_values "${readme}" Version)"
if [ -z "${version_badge}" ]; then
# No version badges in this README, nothing to keep in sync.
continue
fi
chart_version="$(yq e '.version // ""' "${chart_yaml}")"
chart_app_version="$(yq e '.appVersion // ""' "${chart_yaml}")"
version_alt="${version_badge%% *}"
version_url="${version_badge##* }"
if ! versions_match "${version_alt}" "${chart_version}"; then
print_problem "${label}: Version badge ${version_alt} does not match Chart.yaml version ${chart_version}"
problems=$((problems + 1))
fi
if [ "${version_url}" != "${version_alt}" ]; then
print_problem "${label}: Version badge text (${version_alt}) and image URL (${version_url}) disagree"
problems=$((problems + 1))
fi
app_badge="$(badge_values "${readme}" AppVersion)"
if [ -z "${app_badge}" ]; then
if [ -n "${chart_app_version}" ]; then
print_problem "${label}: has a Version badge but no AppVersion badge, while Chart.yaml declares appVersion ${chart_app_version}"
problems=$((problems + 1))
fi
continue
fi
app_alt="${app_badge%% *}"
app_url="${app_badge##* }"
if [ -z "${chart_app_version}" ]; then
print_problem "${label}: AppVersion badge is ${app_alt} but Chart.yaml declares no appVersion"
problems=$((problems + 1))
elif ! versions_match "${app_alt}" "${chart_app_version}"; then
print_problem "${label}: AppVersion badge ${app_alt} does not match Chart.yaml appVersion ${chart_app_version}"
problems=$((problems + 1))
fi
if [ "${app_url}" != "${app_alt}" ]; then
print_problem "${label}: AppVersion badge text (${app_alt}) and image URL (${app_url}) disagree"
problems=$((problems + 1))
fi
done
if [ "${problems}" -ne 0 ]; then
print_problem "${problems} README version badge problem(s) found. Update the badges to match Chart.yaml."
exit 1
fi
@@ -10,6 +10,7 @@ on:
- '.github/tests/**/*.yaml' - '.github/tests/**/*.yaml'
- '.github/tests/**/*.sh' - '.github/tests/**/*.sh'
- '.github/tests/**/*.json' - '.github/tests/**/*.json'
- '.github/scripts/check-readme-versions.sh'
- 'examples/**/*.yaml' - 'examples/**/*.yaml'
- 'helm-docs.sh' - 'helm-docs.sh'
+17
View File
@@ -16,6 +16,7 @@ on:
- '.github/tests/**/*.yaml' - '.github/tests/**/*.yaml'
- '.github/tests/**/*.sh' - '.github/tests/**/*.sh'
- '.github/tests/**/*.json' - '.github/tests/**/*.json'
- '.github/scripts/check-readme-versions.sh'
- 'examples/**/*.yaml' - 'examples/**/*.yaml'
- 'examples/**/*.sh' - 'examples/**/*.sh'
- 'tests/**/*' - 'tests/**/*'
@@ -42,6 +43,22 @@ jobs:
- name: Verify Docs updated - name: Verify Docs updated
run: ./helm-docs.sh run: ./helm-docs.sh
- name: Verify README version badges
run: |
set +e
.github/scripts/check-readme-versions.sh 2>/tmp/badge-findings
res=$?
if [ $res -ne 0 ]; then
{
echo "## README version badges"
echo
echo ":x: These chart READMEs have version badges that disagree with their Chart.yaml. Please fix."
echo
cat /tmp/badge-findings
} >> "$GITHUB_STEP_SUMMARY"
exit 1
fi
- name: Verify Spire appVersion - name: Verify Spire appVersion
run: | run: |
set +e set +e
+5
View File
@@ -15,6 +15,11 @@ lint-release: ## Lint the charts using chart-testing for release
@echo Linting charts… @echo Linting charts…
@ct lint --config ct.yaml --target-branch $(TARGET_BRANCH) @ct lint --config ct.yaml --target-branch $(TARGET_BRANCH)
.PHONY: check-readme-versions
check-readme-versions: ## Verify chart README version badges match Chart.yaml
@echo Checking README version badges…
@.github/scripts/check-readme-versions.sh
##@ Testing: (ensure to run on dedicated test cluster) ##@ Testing: (ensure to run on dedicated test cluster)
.PHONY: clean-test-leftovers .PHONY: clean-test-leftovers
+1 -1
View File
@@ -1,6 +1,6 @@
# spire-crds # spire-crds
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.7.2](https://img.shields.io/badge/AppVersion-1.7.2-informational?style=flat-square) ![Version: 0.6.0](https://img.shields.io/badge/Version-0.6.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.0.1](https://img.shields.io/badge/AppVersion-0.0.1-informational?style=flat-square)
A Helm chart to install the SPIRE CRDS. A Helm chart to install the SPIRE CRDS.
+1 -1
View File
@@ -1,6 +1,6 @@
# spire-ha-agent # spire-ha-agent
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.7.2](https://img.shields.io/badge/AppVersion-1.7.2-informational?style=flat-square) ![Version: 0.3.0](https://img.shields.io/badge/Version-0.3.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.3.0](https://img.shields.io/badge/AppVersion-0.3.0-informational?style=flat-square)
A Helm chart to install the SPIRE HA agent. A Helm chart to install the SPIRE HA agent.
+1 -1
View File
@@ -1,6 +1,6 @@
# spire # spire
![Version: 0.28.5](https://img.shields.io/badge/Version-0.28.5-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.15.2](https://img.shields.io/badge/AppVersion-1.15.2-informational?style=flat-square) ![Version: 0.30.0](https://img.shields.io/badge/Version-0.30.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.15.2](https://img.shields.io/badge/AppVersion-1.15.2-informational?style=flat-square)
[![Development Phase](https://github.com/spiffe/spiffe/blob/main/.img/maturity/dev.svg)](https://github.com/spiffe/spiffe/blob/main/MATURITY.md#development) [![Development Phase](https://github.com/spiffe/spiffe/blob/main/.img/maturity/dev.svg)](https://github.com/spiffe/spiffe/blob/main/MATURITY.md#development)
A Helm chart for deploying the complete Spire stack including: spire-server, spire-agent, spiffe-csi-driver, spiffe-oidc-discovery-provider and spire-controller-manager. A Helm chart for deploying the complete Spire stack including: spire-server, spire-agent, spiffe-csi-driver, spiffe-oidc-discovery-provider and spire-controller-manager.
+1 -1
View File
@@ -5,7 +5,7 @@ description: >
type: application type: application
version: 0.30.0 version: 0.30.0
appVersion: "1.14.5" appVersion: "1.15.2"
keywords: ["spiffe", "spire", "spire-server", "spire-agent", "oidc", "spire-controller-manager"] keywords: ["spiffe", "spire", "spire-server", "spire-agent", "oidc", "spire-controller-manager"]
home: https://github.com/spiffe/helm-charts-hardened/tree/main/charts/spire home: https://github.com/spiffe/helm-charts-hardened/tree/main/charts/spire
sources: sources:
+1 -1
View File
@@ -1,6 +1,6 @@
# spire # spire
![Version: 0.28.5](https://img.shields.io/badge/Version-0.28.5-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.15.2](https://img.shields.io/badge/AppVersion-1.15.2-informational?style=flat-square) ![Version: 0.30.0](https://img.shields.io/badge/Version-0.30.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.15.2](https://img.shields.io/badge/AppVersion-1.15.2-informational?style=flat-square)
[![Development Phase](https://github.com/spiffe/spiffe/blob/main/.img/maturity/dev.svg)](https://github.com/spiffe/spiffe/blob/main/MATURITY.md#development) [![Development Phase](https://github.com/spiffe/spiffe/blob/main/.img/maturity/dev.svg)](https://github.com/spiffe/spiffe/blob/main/MATURITY.md#development)
A Helm chart for deploying the complete Spire stack including: spire-server, spire-agent, spiffe-csi-driver, spiffe-oidc-discovery-provider and spire-controller-manager. A Helm chart for deploying the complete Spire stack including: spire-server, spire-agent, spiffe-csi-driver, spiffe-oidc-discovery-provider and spire-controller-manager.