gitpod/components/common-go/go-update-wc-deps.sh
Kyle Brennan 80ac25ca97
[workspace] update deps for gen98 (#17719)
* [docker-up] update docker compose to 2.18.1-gitpod.2

* [workspace] update containerd

From v1.6.20 -> v1.6.21

* [image-builder-bob] fix build error after containerd update

Context:
[components/image-builder-bob:app] level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: buildir: failed to load package tracetransform: could not load export data: no export data for \"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform\"\n\n"

* [preview] update VM image with fewer cached images

This will help us avoid pod eviction and improve stability

Related: https://github.com/gitpod-io/gitpod-packer-gcp-image/pull/235

* [test] more cowbell
2023-05-24 21:18:59 +08:00

54 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# Copyright (c) 2023 Gitpod GmbH. All rights reserved.
# Licensed under the GNU Affero General Public License (AGPL).
# See License.AGPL.txt in the project root for license information.
set -eo pipefail
cd ../..
# an array of commponents we'll update and test at the end
COMPONENTS_TO_TEST=( )
# an associative array to describe dependencies we'd like to search for and update to
declare -A WORKSPACE_CLUSTER_DEPENDENCIES
WORKSPACE_CLUSTER_DEPENDENCIES["github.com/containerd/containerd"]="1.6.21"
WORKSPACE_CLUSTER_DEPENDENCIES["github.com/moby/buildkit"]="0.11.6"
# loop through keys of each associative array
for key in "${!WORKSPACE_CLUSTER_DEPENDENCIES[@]}"
do
echo "Inspecting ${key}"
# make an array of go.mod from components containing the dependency
RELATED_COMPONENTS=( )
mapfile -t "RELATED_COMPONENTS" < <(grep -r "${key}" --include="go.mod" -l)
# update the dependency in each component
for c in "${RELATED_COMPONENTS[@]}"
do
echo "On component ${c}"
FOLDER="$(dirname "${c}")"
pushd "${FOLDER}"
if grep -q "${key}" go.mod && ! grep -q "${key} v${WORKSPACE_CLUSTER_DEPENDENCIES[${key}]}" go.mod; then
go get "${key}"@v"${WORKSPACE_CLUSTER_DEPENDENCIES[${key}]}"
# shellcheck disable=SC2076
if [[ ! " ${COMPONENTS_TO_TEST[*]} " =~ " ${FOLDER} " ]]; then
COMPONENTS_TO_TEST+=("${FOLDER}")
fi
fi
popd
done
done
for t in "${COMPONENTS_TO_TEST[@]}"
do
pushd "${t}"
# clean it up
go mod tidy
# assert that build and tests pass
go test ./...
popd
done