Skip to content

Commit

Permalink
Make check fixes (#1534)
Browse files Browse the repository at this point in the history
* Modified make check to run inside the build container

* Modified Go version check
To check for existence of Go rather an specific version

* Changes to run `make check` on the local system
  • Loading branch information
aish-where-ya committed Jul 5, 2022
1 parent b561303 commit 029e0a4
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions build/check.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

GO_BIN=go
DOCKER_BIN=docker
Expand All @@ -11,55 +11,46 @@ failed="❌"
pad=$(printf '%0.1s' "."{1..25})
pad_len=25

function output() {
local bin=$1
output() {
local bin=$(echo "$1" | awk '{print toupper(substr( $0, 1, 1 )) substr($0, 2)}')
local result=$2
local msg=$3
local msg=$(echo "$3" | awk '{print toupper(substr( $0, 1, 1 )) substr($0, 2)}')

printf "* need %s" "${bin^}"
printf "* need %s" "${bin}"
printf "%*.*s %s" 0 $((pad_len - ${#bin})) "${pad}" "${result}"
if [ ! -z "${msg}" ]; then
printf "\n → %s" "${msg}"
fi
printf "\n"
}

function check_version_go() {
local expected=$(cat go.mod | grep "go [0-9]\.[0-9]*" | cut -d" " -f2)
check_version_go() {
local result=""
local msg=""

if command -v ${GO_BIN} > /dev/null 2>&1 ; then
local installed=$(go version | cut -d" " -f3)
installed=${installed:2}

if [ "${expected}" != "${installed}" ]; then
result="${warning}"
msg="version mismatched - got ${installed}, need ${expected}"
else
result="${ok}"
fi
result="${ok}"
else
result="${failed}"
msg="${GO_BIN^} not installed"
msg="${GO_BIN} not installed"
fi

output "${GO_BIN}" "${result}" "${msg}"
}

function check_version_docker() {

check_version_docker() {
local result=""
if command -v ${DOCKER_BIN} > /dev/null 2>&1 ; then
result="${ok}"
else
result="${failed}"
msg="${DOCKER_BIN^} not installed"
msg="${DOCKER_BIN} not installed"
fi

output "${DOCKER_BIN}" "${result}" "${msg}"
}

function check_version_kubectl() {
check_version_kubectl() {
local result=""
if command -v ${KUBECTL_BIN} > /dev/null 2>&1 ; then
result="${ok}"
Expand All @@ -68,7 +59,7 @@ function check_version_kubectl() {
msg="${KUBECTL_BIN} not installed"
fi

output "${KUBECTL_BIN^}" "${result}" "${msg}"
output "${KUBECTL_BIN}" "${result}" "${msg}"
}

check_version_go
Expand Down

0 comments on commit 029e0a4

Please sign in to comment.