Skip to content

Commit 8cc1c01

Browse files
cfergeaupraveenkumar
authored andcommitted
build: Add update-go-version and goversioncheck targets
Until recently we were using a very outdated golang 1.13.4 release (latest is 1.13.15). This commit adds an 'update-go-version' Makefile target which will automatically update the golang version to the latest release ones in the various files where we explicitly set it. It also adds a 'goversioncheck' target which can be used in the future by CI to get notifications when the golang version that we use is out of date.
1 parent d32d37f commit 8cc1c01

4 files changed

Lines changed: 61 additions & 5 deletions

File tree

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,11 @@ embed_bundle: clean cross $(HOST_BUILD_DIR)/crc-embedder check_bundledir $(HYPER
206206
$(HOST_BUILD_DIR)/crc-embedder embed --log-level debug --goos=darwin --bundle-dir=$(BUNDLE_DIR) $(BUILD_DIR)/macos-amd64/crc
207207
$(HOST_BUILD_DIR)/crc-embedder embed --log-level debug --goos=linux --bundle-dir=$(BUNDLE_DIR) $(BUILD_DIR)/linux-amd64/crc
208208
$(HOST_BUILD_DIR)/crc-embedder embed --log-level debug --goos=windows --bundle-dir=$(BUNDLE_DIR) $(BUILD_DIR)/windows-amd64/crc.exe
209+
210+
.PHONY: update-go-version
211+
update-go-version:
212+
./update-go-version.sh 1.14
213+
214+
.PHONY: goversioncheck
215+
goversioncheck:
216+
./verify-go-version.sh

appveyor.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
build: off
2-
32
clone_folder: c:\gopath\src\github.com\code-ready\crc
4-
53
environment:
64
GOPATH: c:\gopath
7-
85
stack: go 1.14
9-
106
before_test:
117
- choco install make
128
- make cross
13-
149
test_script:
1510
- make test

update-go-version.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
# Updates our various build files, CI configs, ... to the latest released go
6+
# version in a given minor release stream (1.x)
7+
# This requires yq and jq in addition to fairly standard shell tools (curl, grep, sed, ...)
8+
9+
golang_base_version=$1
10+
latest_version=$(curl --silent 'https://golang.org/dl/?mode=json&include=all' | jq -r '.[].files[].version' |uniq | sed -e 's/go//' |sort -V |grep ${golang_base_version}|tail -1)
11+
echo "Updating golang version to $latest_version"
12+
13+
go mod edit -go ${golang_base_version}
14+
sed -i "s,^FROM registry.svc.ci.openshift.org/openshift/release:golang-1\... AS builder\$,FROM registry.svc.ci.openshift.org/openshift/release:golang-${golang_base_version} AS builder," images/openshift-ci/Dockerfile
15+
sed -i "s/GOVERSION: .*\$/GOVERSION: \"${latest_version}\"/" .circleci/config.yml
16+
sed -i "s/^GO_VERSION=.*$/GO_VERSION=${latest_version}/" centos_ci.sh
17+
yq write --inplace ./appveyor.yml stack "go ${golang_base_version}"
18+
yq write --inplace ./.travis.yml go[0] ${latest_version}

verify-go-version.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
export GO111MODULE=on
8+
9+
readonly REPO_ROOT_DIR="$(git rev-parse --show-toplevel 2> /dev/null)"
10+
readonly TMP_DIFFROOT="$(mktemp -d "${REPO_ROOT_DIR}"/tmpdiffroot.XXXXXX)"
11+
12+
cleanup() {
13+
rm -rf "${TMP_DIFFROOT}"
14+
}
15+
16+
trap "cleanup" EXIT SIGINT
17+
18+
cleanup
19+
20+
git clone "${REPO_ROOT_DIR}" "${TMP_DIFFROOT}"
21+
22+
make -C "${TMP_DIFFROOT}" update-go-version
23+
24+
echo "Diffing ${REPO_ROOT_DIR} against tree with freshly updated golang version"
25+
ret=0
26+
git --no-pager -C ${TMP_DIFFROOT} diff --exit-code 2>&1 >/dev/null || ret=1
27+
#diff -Naupr "${REPO_ROOT_DIR}/vendor" "${TMP_DIFFROOT}/vendor" || ret=1
28+
29+
if [[ $ret -eq 0 ]]
30+
then
31+
echo "${REPO_ROOT_DIR} up to date."
32+
else
33+
echo "${REPO_ROOT_DIR} is out of date. Please run make update-go-version"
34+
exit 1
35+
fi

0 commit comments

Comments
 (0)