Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit 4eb7370

Browse files
yradsmikhambnookala
authored andcommitted
add manifest validation
1 parent 725d409 commit 4eb7370

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

tests/functions.sh

+13-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ function verify_pipeline_with_poll () {
336336
}
337337

338338
function validate_file () {
339-
echo "Validatng file $1"
339+
echo "Validating file $1"
340340
if grep -q "$2" "$1";
341341
then
342342
echo "File contents have been successfully validated in $1"
@@ -535,3 +535,15 @@ function approve_pull_request () {
535535
exit 1
536536
fi
537537
}
538+
539+
function validate_commit () {
540+
commit_history=$(git --no-pager log --decorate=short --pretty=oneline -n1)
541+
if [[ "$commit_history" == *"$1"* ]]; then
542+
echo "Commit Validated"
543+
else
544+
echo "Commit not validated. Retrying..."
545+
sleep 10s
546+
git pull
547+
validate_commit $1
548+
fi
549+
}

tests/validations.sh

+16
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ services_dir=services
4040
mono_repo_dir=fabrikam2019
4141
helm_charts_dir=fabrikam-helm-charts
4242
services_full_dir="$TEST_WORKSPACE/$mono_repo_dir/$services_dir"
43+
FrontEndCompliant="${FrontEnd//./-}"
4344

4445
shopt -s expand_aliases
4546
alias spk=$SPK_LOCATION
@@ -316,6 +317,21 @@ echo "Attempting to approve pull request: '$pr_title'"
316317
approve_pull_request $AZDO_ORG_URL $AZDO_PROJECT "$pr_title"
317318
# --------------------------------
318319

320+
##################################
321+
# Manifest Validation Start
322+
##################################
323+
324+
echo "Validating image tag in manifest repo"
325+
cd $TEST_WORKSPACE/$hld_dir
326+
git pull
327+
cd $mono_repo_dir/$FrontEndCompliant/master/config
328+
image_repository=$(grep -A3 'image:' common.yaml | tail -n3 | awk '{print $2}' | head -n1 )
329+
image_tag=$(grep -A3 'image:' common.yaml | tail -n2 | awk '{print $2}' | head -n 1)
330+
cd $TEST_WORKSPACE/$manifests_dir
331+
git pull
332+
validate_commit $image_tag
333+
validate_file "$TEST_WORKSPACE/$manifests_dir/prod/$mono_repo_dir/$FrontEndCompliant/master/chart.yaml" "image: $image_repository:$image_tag"
334+
319335
# ##################################
320336
# TODO
321337
# Fix issues where image tag update not reflected in manifest yaml

0 commit comments

Comments
 (0)