Skip to content

Commit

Permalink
wip: verify-dep
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Valdes <[email protected]>
  • Loading branch information
ivanvc committed Aug 8, 2024
1 parent f2c30d8 commit c7c03a5
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -543,18 +543,30 @@ function bom_pass {
######## VARIOUS CHECKERS ######################################################

function dump_deps_of_module() {
local module
if ! module=$(go mod edit -json | jq -r '.Module.Path'); then
return 255
fi
run go mod edit -json | jq -r '.Require[] | .Path+","+.Version+","+if .Indirect then " (indirect)" else "" end+",'"${module}"'"'
local modules=("$@")
local deps=()
for module in "${modules[@]}"; do
local module_file
local module_name
local module_deps
module_file="${module/.../go.mod}"
if ! module_name=$(go mod edit -json "$module_file" | jq -r '.Module.Path'); then
return 255
fi
mapfile -t module_deps < <(go mod edit -json "$module_file" | jq -r '.Require[] | .Path+","+.Version+","+if .Indirect then " (indirect)" else "" end+",'"${module_name}"'"')
go mod edit -json "$module_file" | jq -r '.Require[] | .Path+","+.Version+","+if .Indirect then " (indirect)" else "" end+",'"${module_name}"'"' >> depsl.txt
echo "${module_deps[@]}" > deps.txt
deps+=("${module_deps[@]}")
done
echo "${deps[@]}"
}

# Checks whether dependencies are consistent across modules
function dep_pass {
local all_dependencies
local tools_mod_dependencies
all_dependencies=$(run_for_modules dump_deps_of_module) || return 2
echo $all_dependencies > depsall.txt
# tools/mod is a special case. It is a module that is not included in the
# module list from test_lib.sh. However, we need to ensure that the
# dependency versions match the rest of the project. Therefore, explicitly
Expand Down

0 comments on commit c7c03a5

Please sign in to comment.