Skip to content

Commit 5e53e42

Browse files
kylos101roboquat
authored andcommitted
[common-go] convenience script to manage workspace-cluster dependencies
1 parent 877d14e commit 5e53e42

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# Copyright (c) 2023 Gitpod GmbH. All rights reserved.
3+
# Licensed under the GNU Affero General Public License (AGPL).
4+
# See License.AGPL.txt in the project root for license information.
5+
6+
set -eo pipefail
7+
8+
cd ../..
9+
10+
# an array of commponents we'll update and test at the end
11+
COMPONENTS_TO_TEST=( )
12+
13+
# an associative array to describe dependencies we'd like to search for and update to
14+
declare -A WORKSPACE_CLUSTER_DEPENDENCIES
15+
WORKSPACE_CLUSTER_DEPENDENCIES["github.com/containerd/containerd"]="1.6.18"
16+
WORKSPACE_CLUSTER_DEPENDENCIES["github.com/moby/buildkit"]="0.11.3"
17+
18+
# loop through keys of each associative array
19+
for key in "${!WORKSPACE_CLUSTER_DEPENDENCIES[@]}"
20+
do
21+
echo "Working on ${key}"
22+
# make an array of go.mod from components containing the dependency
23+
RELATED_COMPONENTS=( )
24+
mapfile -t "RELATED_COMPONENTS" < <(grep -r "${key}" --include="go.mod" -l)
25+
26+
# update the dependency in each component
27+
for c in "${RELATED_COMPONENTS[@]}"
28+
do
29+
echo "Working on ${c}"
30+
FOLDER="$(dirname "${c}")"
31+
pushd "${FOLDER}"
32+
echo "${key}"
33+
go get "${key}"@v"${WORKSPACE_CLUSTER_DEPENDENCIES[${key}]}"
34+
# shellcheck disable=SC2076
35+
if [[ ! " ${COMPONENTS_TO_TEST[*]} " =~ " ${FOLDER} " ]]; then
36+
COMPONENTS_TO_TEST+=("${FOLDER}")
37+
fi
38+
popd
39+
done
40+
done
41+
42+
for t in "${COMPONENTS_TO_TEST[@]}"
43+
do
44+
pushd "${t}"
45+
# clean it up
46+
go mod tidy
47+
# assert that build and tests pass
48+
go test ./...
49+
popd
50+
done

0 commit comments

Comments
 (0)