Skip to content

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]>
  • Loading branch information
jodh-intel committed Apr 29, 2019
1 parent 40232ed commit 50f3b03
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 @@ -595,22 +595,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 50f3b03

Please sign in to comment.