Skip to content

Commit

Permalink
ci: add check to catch missing Policy.yaml version update
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Vernin <[email protected]>
  • Loading branch information
olblak committed Sep 13, 2024
1 parent 06c3369 commit 6e4f2e8
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions .ci/scripts/release.bash
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ function runUpdatecliDiff(){
updatecli diff \
--config "$POLICY_ROOT_DIR/updatecli.d" \
--values "$POLICY_ROOT_DIR/values.yaml" \
--values "$POLICY_ROOT_DIR/testdata/values.yaml" \
--experimental
--values "$POLICY_ROOT_DIR/testdata/values.yaml"
}

function validateRequiredFile(){
Expand Down Expand Up @@ -119,6 +118,16 @@ function validateRequiredFile(){
POLICY_ERROR=true
echo " * Changelog missing a version entry such as '## $versionInformation' in $POLICY_CHANGELOG"
fi

# Testing that the latest changelog version is used in the Policy.yaml
latestVersionChangelogEntry=$( grep -r '## ' -m 1 "$POLICY_CHANGELOG")
latestVersionChangelogEntry=${latestVersionChangelogEntry#"## "}
if [[ "$latestVersionChangelogEntry" != "$versionInformation" ]]; then
POLICY_ERROR=true
echo " * Latest Changelog version isn't the one used in Policy.yaml"
echo " '## $latestVersionChangelogEntry' in $POLICY_CHANGELOG"
echo " '## $versionInformation' in $POLICY_METADATA"
fi
}

function main(){
Expand All @@ -134,20 +143,21 @@ function main(){
POLICY_ROOT_DIR=$(dirname "$POLICY")
POLICY_ERROR=false

if [[ "$PARAM" == "--e2e-test" ]]; then
runUpdatecliDiff "$POLICY_ROOT_DIR"
fi

if [[ "$PARAM" == "--unit-test" || "$PARAM" == "" ]]; then
validateRequiredFile "$POLICY_ROOT_DIR"
fi

if [[ "$POLICY_ERROR" = "false" ]]; then
echo " => all is good"

if [[ "$PARAM" == "--publish" ]]; then
release "$POLICY_ROOT_DIR"
fi

if [[ "$PARAM" == "--e2e-test" ]]; then
runUpdatecliDiff "$POLICY_ROOT_DIR"
fi

if [[ "$PARAM" == "--unit-test" || "$PARAM" == "" ]]; then
validateRequiredFile "$POLICY_ROOT_DIR"
fi
else
echo ""
echo " => validation test not passing"
Expand All @@ -161,3 +171,4 @@ function main(){
}

main "${1:-}"

0 comments on commit 6e4f2e8

Please sign in to comment.