Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure CI failures will fail our pipeline. #102

Merged
merged 2 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions .github/run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
#!/bin/bash

# Run our golang tests
go test ./... -race
# Install the tools we use to test our code-quality.
#
# Here we setup the tools to install only if the "CI" environmental variable
# is not empty. This is because locally I have them installed.
#
# NOTE: Github Actions always set CI=true
#
if [ ! -z "${CI}" ] ; then
go install golang.org/x/lint/golint@latest
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
fi

# Run the perl script to look for function orders
.github/test-ordering.pl || exit 1
# Run the static-check tool - we ignore errors in goserver/static.go
t=$(mktemp)
staticcheck -checks all ./... | grep -v "is deprecated"> $t
if [ -s $t ]; then
echo "Found errors via 'staticcheck'"
cat $t
rm $t
exit 1
fi
rm $t

# At this point failures cause aborts
set -e

# Run the linter
echo "Launching linter .."
golint -set_exit_status ./...
echo "Completed linter .."

# Run the shadow-checker
echo "Launching shadowed-variable check .."
go vet -vettool=$(which shadow) ./...
echo "Completed shadowed-variable check .."

# Run golang tests
go test ./...
23 changes: 12 additions & 11 deletions eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,19 +407,20 @@ func (ev *Eval) eval(exp primitive.Primitive, e *env.Environment, expandMacro bo
// Get the first argument and ensure it is a hash
obj := ev.eval(listArgs[0], e, expandMacro)
hsh, okH := obj.(primitive.Hash)
if okH {
// One argument? Read the value
if len(listArgs) == 1 {
return hsh.Get(access)
}

// Two arguments? Set the value, and return it
val := ev.eval(listArgs[1], e, expandMacro)
hsh.Set(access, val)
return val
} else {
if !okH {
return primitive.Error(fmt.Sprintf("expected a hash, got %v", obj))
}

// One argument? Read the value
if len(listArgs) == 1 {
return hsh.Get(access)
}

// Two arguments? Set the value, and return it
val := ev.eval(listArgs[1], e, expandMacro)
hsh.Set(access, val)
return val

}

// Is this a structure creation?
Expand Down