Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
CI: Refactor static check vendor test
Browse files Browse the repository at this point in the history
Modify the `check_vendor()` function in the static check script. Rather
than exiting the function as early as possible, change the logic to
allow follow on future checks to be added.

Signed-off-by: James O. D. Hunt <[email protected]>
(cherry picked from commit 50f3b03)
Signed-off-by: Ganesh Maharaj Mahalingam <[email protected]>
  • Loading branch information
jodh-intel authored and jcvenegas committed May 2, 2019
1 parent bd82330 commit 23d8194
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions .ci/static-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -622,22 +622,26 @@ check_vendor()
# All vendor operations should modify this file
local vendor_ctl_file="Gopkg.lock"

[ -e "$vendor_ctl_file" ] || { info "No vendoring in this repository" && return; }

info "Checking vendored code is pristine"

files=$(get_pr_changed_file_details_full || true)

# Strip off status
files=$(echo "$files"|awk '{print $NF}')

# No files were changed
[ -z "$files" ] && info "No files found" && return

vendor_files=$(echo "$files" | grep "vendor/" || true)

# No vendor files modified
[ -z "$vendor_files" ] && return

result=$(echo "$files" | egrep "\<${vendor_ctl_file}\>" || true)
if [ -n "$files" ]
then
# PR changed files so check if it changed any vendored files
vendor_files=$(echo "$files" | grep "vendor/" || true)

[ -n "$result" ] || die "PR changes vendor files, but does not update ${vendor_ctl_file}"
if [ -n "$vendor_files" ]
then
result=$(echo "$files" | egrep "\<${vendor_ctl_file}\>" || true)
[ -n "$result" ] || die "PR changes vendor files, but does not update ${vendor_ctl_file}"
fi
fi
}

main()
Expand Down

0 comments on commit 23d8194

Please sign in to comment.