From bafb0303871eaeec638e2a8b93edecaed92fc573 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Mon, 12 Feb 2024 17:07:56 +0100 Subject: [PATCH] add make step to validate the introductionVersion annotation to env-vars Signed-off-by: Christian Richter --- .drone.star | 1 - .make/check-env-var-annotations.sh | 49 +++++++++++++++++++++ Makefile | 4 ++ changelog/unreleased/env-var-annotations.md | 6 +++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100755 .make/check-env-var-annotations.sh create mode 100644 changelog/unreleased/env-var-annotations.md diff --git a/.drone.star b/.drone.star index dc8bcb32aa..3f86efd1fd 100644 --- a/.drone.star +++ b/.drone.star @@ -1824,7 +1824,6 @@ def docs(): "image": OC_CI_GOLANG, "environment": DRONE_HTTP_PROXY_ENV, "commands": [ - "apk update && apk add asciidoctor" "make -C docs test", ], }, diff --git a/.make/check-env-var-annotations.sh b/.make/check-env-var-annotations.sh new file mode 100755 index 0000000000..173b79d03b --- /dev/null +++ b/.make/check-env-var-annotations.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# The following grep will filter out every line containing an `env` annotation +# it will ignore every line that has allready a valid `introductionVersion` annotation +# +# valid examples: +# +# introductionVersion:"pre5.0" +# introductionVersion:"5.0" +# introductionVersion:"4.9.3-rc5" +# introductionVersion:"5.0.1-cheesecake" +# introductionVersion:"5.10.100.15" +# introductionVersion:"0.0" +# +# invalid examples: +# +# introductionVersion:"5.0cheesecake" +# introductionVersion:"5" +# introductionVersion:"5blueberry" +# introductionVersion:"5-lasagna" +# introductionVersion:"4.9.3rc5" + +ERROR=0 + +QUERY_INTRO=$(git grep "env:" -- '*.go' |grep -v -P "introductionVersion:\"([0-9.]{3,}([-].*)?|(pre5\.0))\""|grep -v "_test.go"|grep -v "vendor/") + +RESULTS_INTRO=$(echo "${QUERY_INTRO}"|wc -l) +if [ "${RESULTS_INTRO}" -gt 0 ]; then + echo "===============================================================================================" + echo "The following ${RESULTS_INTRO} files contain an invalid introductionVersion annotation:" + echo "===============================================================================================" + echo "$QUERY_INTRO" + ERROR=1 +fi + +# The following grep will filter out every line containing an `env` annotation +# it will ignore every line that has allready a valid `desc` annotation + +QUERY_DESC=$(git grep "env:" -- '*.go' |grep -v -P "desc:\".{10,}\""|grep -v "_test.go"|grep -v "vendor/") + +RESULTS_DESC=$(echo "${QUERY_DESC}"|wc -l) +if [ "${RESULTS_DESC}" -gt 0 ]; then + echo "===============================================================================================" + echo "The following ${RESULTS_DESC} files contain an invalid description annotation:" + echo "===============================================================================================" + echo "$QUERY_DESC" + ERROR=1 +fi +exit ${ERROR} diff --git a/Makefile b/Makefile index 517f08d4bf..c042d35944 100644 --- a/Makefile +++ b/Makefile @@ -176,6 +176,10 @@ docs-generate: $(MAKE) --no-print-directory -C docs docs-generate || exit 1 cp docs/services/general-info/env-var-deltas/*.adoc docs/services/_includes/adoc/env-var-deltas/ +.PHONY: check-env-var-annotations +check-env-var-annotations: + .make/check-env-var-annotations.sh + .PHONY: ci-go-generate ci-go-generate: @for mod in $(OCIS_MODULES); do \ diff --git a/changelog/unreleased/env-var-annotations.md b/changelog/unreleased/env-var-annotations.md new file mode 100644 index 0000000000..98be7169b1 --- /dev/null +++ b/changelog/unreleased/env-var-annotations.md @@ -0,0 +1,6 @@ +Enhancement: Add a make step to validate the env var annotations + +We have added a make step `make validate-env-var-annotations` to validate the env var annotations in to the environment variables. + +https://github.com/owncloud/ocis/pull/8436 +https://github.com/owncloud/ocis/issues/8258