From 6cd243f14edba2dd034c41b5ecc55cbe1b12c4e6 Mon Sep 17 00:00:00 2001 From: Kenichi Omichi <ken1ohmichi@gmail.com> Date: Wed, 29 Jun 2022 00:14:05 -0700 Subject: [PATCH] Add component version check for README.md (#9042) During code-review, reviwers needed to take care of README.md also should be updated when the pull request updated component versions. This adds the corresponding check to reduce reviwer's burden. --- .gitlab-ci/lint.yml | 7 ++++++ README.md | 2 +- tests/scripts/check_readme_versions.sh | 30 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100755 tests/scripts/check_readme_versions.sh diff --git a/.gitlab-ci/lint.yml b/.gitlab-ci/lint.yml index 57c8b0847..53f73e512 100644 --- a/.gitlab-ci/lint.yml +++ b/.gitlab-ci/lint.yml @@ -68,6 +68,13 @@ markdownlint: script: - markdownlint $(find . -name '*.md' | grep -vF './.git') --ignore docs/_sidebar.md --ignore contrib/dind/README.md +check-readme-versions: + stage: unit-tests + tags: [light] + image: python:3 + script: + - tests/scripts/check_readme_versions.sh + ci-matrix: stage: unit-tests tags: [light] diff --git a/README.md b/README.md index e6871b37d..b4129299e 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ Note: Upstart/SysV init based OS types are not supported. - [calico](https://github.com/projectcalico/calico) v3.23.1 - [canal](https://github.com/projectcalico/canal) (given calico/flannel versions) - [cilium](https://github.com/cilium/cilium) v1.11.3 - - [flanneld](https://github.com/flannel-io/flannel) v0.17.0 + - [flannel](https://github.com/flannel-io/flannel) v0.17.0 - [kube-ovn](https://github.com/alauda/kube-ovn) v1.9.2 - [kube-router](https://github.com/cloudnativelabs/kube-router) v1.5.0 - [multus](https://github.com/intel/multus-cni) v3.8 diff --git a/tests/scripts/check_readme_versions.sh b/tests/scripts/check_readme_versions.sh new file mode 100755 index 000000000..ec18ffd18 --- /dev/null +++ b/tests/scripts/check_readme_versions.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +TARGET_COMPONENTS="containerd calico cilium flannel kube-ovn kube-router weave cert-manager" + +# cd to the root directory of kubespray +cd $(dirname $0)/../../ + +echo checking kubernetes.. +version_from_default=$(grep "^kube_version:" ./roles/kubespray-defaults/defaults/main.yaml | awk '{print $2}' | sed s/\"//g) +version_from_readme=$(grep " \[kubernetes\]" ./README.md | awk '{print $3}') +if [ "${version_from_default}" != "${version_from_readme}" ]; then + echo "The version of kubernetes is different between main.yml(${version_from_default}) and README.md(${version_from_readme})." + echo "If the pull request updates kubernetes version, please updates README.md also." + exit 1 +fi + +for component in $(echo ${TARGET_COMPONENTS}); do + echo checking ${component}.. + version_from_default=$(grep "^$(echo ${component} | sed s/"-"/"_"/)_version:" ./roles/download/defaults/main.yml | awk '{print $2}' | sed s/\"//g | sed s/^v//) + version_from_readme=$(grep "\[${component}\]" ./README.md | grep "https" | awk '{print $3}' | sed s/^v//) + if [ "${version_from_default}" != "${version_from_readme}" ]; then + echo "The version of ${component} is different between main.yml(${version_from_default}) and README.md(${version_from_readme})." + echo "If the pull request updates ${component} version, please updates README.md also." + exit 1 + fi +done + +echo "Succeeded to check all components." +exit 0 -- GitLab