Skip to content

Commit

Permalink
Fix ci by upgrading go and dynamically setting go version in tests (#22)
Browse files Browse the repository at this point in the history
* Upgrade go in hermit

* Update tests with runtime.Version() so it passes on different go versions
  • Loading branch information
joshcarp authored Nov 12, 2022
1 parent 9a4d98b commit d33db94
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 15 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions bin/activate-hermit
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
# This file must be used with "source bin/activate-hermit" from bash or zsh.
# You cannot run it directly
#
# THIS FILE IS GENERATED; DO NOT MODIFY

if [ "${BASH_SOURCE-}" = "$0" ]; then
echo "You must source this script: \$ source $0" >&2
Expand Down
2 changes: 1 addition & 1 deletion bin/go
2 changes: 1 addition & 1 deletion bin/gofmt
2 changes: 1 addition & 1 deletion bin/golangci-lint
23 changes: 20 additions & 3 deletions bin/hermit
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#!/bin/bash
#
# THIS FILE IS GENERATED; DO NOT MODIFY

set -eo pipefail

export HERMIT_USER_HOME=~

if [ -z "${HERMIT_STATE_DIR}" ]; then
case "$(uname -s)" in
Darwin)
export HERMIT_STATE_DIR="${HOME}/Library/Caches/hermit"
export HERMIT_STATE_DIR="${HERMIT_USER_HOME}/Library/Caches/hermit"
;;
Linux)
export HERMIT_STATE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/hermit"
export HERMIT_STATE_DIR="${XDG_CACHE_HOME:-${HERMIT_USER_HOME}/.cache}/hermit"
;;
esac
fi
Expand All @@ -20,7 +24,20 @@ export HERMIT_EXE=${HERMIT_EXE:-${HERMIT_STATE_DIR}/pkg/hermit@${HERMIT_CHANNEL}

if [ ! -x "${HERMIT_EXE}" ]; then
echo "Bootstrapping ${HERMIT_EXE} from ${HERMIT_DIST_URL}" 1>&2
curl -fsSL "${HERMIT_DIST_URL}/install.sh" | /bin/bash 1>&2
INSTALL_SCRIPT="$(mktemp)"
# This value must match that of the install script
INSTALL_SCRIPT_SHA256="180e997dd837f839a3072a5e2f558619b6d12555cd5452d3ab19d87720704e38"
if [ "${INSTALL_SCRIPT_SHA256}" = "BYPASS" ]; then
curl -fsSL "${HERMIT_DIST_URL}/install.sh" -o "${INSTALL_SCRIPT}"
else
# Install script is versioned by its sha256sum value
curl -fsSL "${HERMIT_DIST_URL}/install-${INSTALL_SCRIPT_SHA256}.sh" -o "${INSTALL_SCRIPT}"
# Verify install script's sha256sum
openssl dgst -sha256 "${INSTALL_SCRIPT}" | \
awk -v EXPECTED="$INSTALL_SCRIPT_SHA256" \
'$2!=EXPECTED {print "Install script sha256 " $2 " does not match " EXPECTED; exit 1}'
fi
/bin/bash "${INSTALL_SCRIPT}" 1>&2
fi

exec "${HERMIT_EXE}" --level=fatal exec "$0" -- "$@"
17 changes: 9 additions & 8 deletions command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"runtime"
"testing"

"google.golang.org/genproto/googleapis/api/annotations"
Expand Down Expand Up @@ -57,7 +58,7 @@ func TestBuildCommand(t *testing.T) {
json: fmt.Sprintf("{\n \"message\": \"Incoming Message: blah \\n "+
"Metadata: map[:authority:[%s] accept-encoding:[identity] "+
"content-type:[application/grpc+proto] grpc-accept-encoding:[gzip] "+
"user-agent:[grpc-go-connect/1.1.0 (go1.18.2)]]\"\n}", addr),
"user-agent:[grpc-go-connect/1.1.0 (%s)]]\"\n}", addr, runtime.Version()),
},
{
name: "completion_enabled",
Expand Down Expand Up @@ -149,7 +150,7 @@ help Help about any command
json: fmt.Sprintf("{\n \"message\": \"Incoming Message: blah \\n "+
"Metadata: map[:authority:[%s] accept-encoding:[identity] "+
"content-type:[application/grpc+proto] foo:[Bar] grpc-accept-encoding:[gzip] "+
"user-agent:[grpc-go-connect/1.1.0 (go1.18.2)]]\"\n}", addr),
"user-agent:[grpc-go-connect/1.1.0 (%s)]]\"\n}", addr, runtime.Version()),
},
{
name: "headers",
Expand All @@ -173,7 +174,7 @@ help Help about any command
json: fmt.Sprintf("{\n \"message\": \"Incoming Message: blah \\n "+
"Metadata: map[:authority:[%s] accept-encoding:[identity] content-type:[application/grpc+proto] "+
"foo:[Bar] foo2:[Bar2] grpc-accept-encoding:[gzip] "+
"user-agent:[grpc-go-connect/1.1.0 (go1.18.2)]]\"\n}", addr),
"user-agent:[grpc-go-connect/1.1.0 (%s)]]\"\n}", addr, runtime.Version()),
},
{
name: "WithContextFunc-No-Change",
Expand All @@ -200,7 +201,7 @@ help Help about any command
json: fmt.Sprintf("{\n \"message\": \"Incoming Message: blah \\n "+
"Metadata: map[:authority:[%s] accept-encoding:[identity] content-type:[application/grpc+proto] "+
"foo:[Bar] foo2:[Bar2] grpc-accept-encoding:[gzip] "+
"user-agent:[grpc-go-connect/1.1.0 (go1.18.2)]]\"\n}", addr),
"user-agent:[grpc-go-connect/1.1.0 (%s)]]\"\n}", addr, runtime.Version()),
},
{
name: "WithContextFunc-No-Change",
Expand All @@ -227,7 +228,7 @@ help Help about any command
json: fmt.Sprintf("{\n \"message\": \"Incoming Message: blah \\n "+
"Metadata: map[:authority:[%s] accept-encoding:[identity] content-type:[application/grpc+proto] "+
"foo:[Bar] foo2:[Bar2] grpc-accept-encoding:[gzip] "+
"user-agent:[grpc-go-connect/1.1.0 (go1.18.2)]]\"\n}", addr),
"user-agent:[grpc-go-connect/1.1.0 (%s)]]\"\n}", addr, runtime.Version()),
},
{
name: "WithContextFunc",
Expand All @@ -254,7 +255,7 @@ help Help about any command
json: fmt.Sprintf("{\n \"message\": \"Incoming Message: blah \\n "+
"Metadata: map[:authority:[%s] accept-encoding:[identity] content-type:[application/grpc+proto] "+
"foo:[Bar] foo2:[Bar2] fookey:[fooval] grpc-accept-encoding:[gzip] "+
"user-agent:[grpc-go-connect/1.1.0 (go1.18.2)]]\"\n}", addr),
"user-agent:[grpc-go-connect/1.1.0 (%s)]]\"\n}", addr, runtime.Version()),
},
{
name: "WithDescriptorContextFuncSimple",
Expand All @@ -281,7 +282,7 @@ help Help about any command
json: fmt.Sprintf("{\n \"message\": \"Incoming Message: "+
"blah \\n Metadata: map[:authority:[%s] accept-encoding:[identity] "+
"content-type:[application/grpc+proto] foo:[Bar] foo2:[Bar2] fookey:[fooval] "+
"grpc-accept-encoding:[gzip] user-agent:[grpc-go-connect/1.1.0 (go1.18.2)]]\"\n}", addr),
"grpc-accept-encoding:[gzip] user-agent:[grpc-go-connect/1.1.0 (%s)]]\"\n}", addr, runtime.Version()),
},
{
name: "WithDescriptorContextFuncMethodDescriptorsUsed",
Expand Down Expand Up @@ -315,7 +316,7 @@ help Help about any command
"blah \\n Metadata: map[:authority:[%s] "+
"accept-encoding:[identity] content-type:[application/grpc+proto] "+
"foo:[Bar] foo2:[Bar2] fookey:[] grpc-accept-encoding:[gzip] "+
"user-agent:[grpc-go-connect/1.1.0 (go1.18.2)]]\"\n}", addr),
"user-agent:[grpc-go-connect/1.1.0 (%s)]]\"\n}", addr, runtime.Version()),
},
}
for _, tt := range tests {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/joshcarp/grpctl

go 1.18
go 1.19

require (
github.com/bufbuild/connect-go v1.1.0
Expand Down

0 comments on commit d33db94

Please sign in to comment.