Skip to content

Commit

Permalink
Add GOWORK env variable when go vet is run
Browse files Browse the repository at this point in the history
The cinder-operator patch [1] introduces the 'go.work' file within the
repository with the goal of automating the way we deal with multi module
dependencies.
However, the side effect of having a versioned 'go.work' in the repo is
the failure of this script because GOWORK is automatically set to "on".
This patch fixes the CI run on the cinder-operator PR [1], introducing
a GOWORK variable (which is set to off by default) to make sure we can
successfully run this check regardless of the Makefile approach.

[1] openstack-k8s-operators/cinder-operator#79

Signed-off-by: Francesco Pantano <[email protected]>
  • Loading branch information
fmount committed Nov 29, 2022
1 parent 9471567 commit 022d0ee
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion test-runner/gofmt.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
set -ex

GOWORK=${GOWORK:-'off'}
BASE_DIR="$(dirname $0)"
cd "${BASE_DIR}/../.."

Expand All @@ -10,5 +11,5 @@ if [ -n "$1" ]; then
fi

pushd ${MODULE_DIR}
go fmt ./...
GOWORK=$GOWORK go fmt ./...
popd
3 changes: 2 additions & 1 deletion test-runner/golangci.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
set -ex

GOWORK=${GOWORK:-'off'}
BASE_DIR="$(dirname $0)"
cd "${BASE_DIR}/../.."

Expand All @@ -21,5 +22,5 @@ fi

pushd ${MODULE_DIR}

GOGC=10 GOLANGCI_LINT_CACHE=/tmp/golangci-cache ${BASE_DIR}/../../bin/golangci-lint run --timeout=${TIMEOUT}m -v
GOWORK=$GOWORK GOGC=10 GOLANGCI_LINT_CACHE=/tmp/golangci-cache ${BASE_DIR}/../../bin/golangci-lint run --timeout=${TIMEOUT}m -v
popd
3 changes: 2 additions & 1 deletion test-runner/golint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -ex
# "-set_exit_status" otherwise
LINT_EXIT_STATUS="-set_exit_status"

GOWORK=${GOWORK:-'off'}
BASE_DIR="$(dirname $0)"
cd "${BASE_DIR}/../.."

Expand All @@ -25,5 +26,5 @@ fi
pushd ${MODULE_DIR}
export GOFLAGS="-mod=mod"

golint ${LINT_EXIT_STATUS} ./...
GOWORK=$GOWORK golint ${LINT_EXIT_STATUS} ./...
popd
3 changes: 2 additions & 1 deletion test-runner/gotest.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
set -ex

GOWORK=${GOWORK:-'off'}
BASE_DIR="$(dirname $0)"
cd "${BASE_DIR}/../.."

Expand All @@ -10,5 +11,5 @@ if [ -n "$1" ]; then
fi

pushd ${MODULE_DIR}
go test -mod=mod -v ./...
GOWORK=$GOWORK go test -mod=mod -v ./...
popd
3 changes: 2 additions & 1 deletion test-runner/govet.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
set -ex

GOWORK=${GOWORK:-'off'}
BASE_DIR="$(dirname $0)"
cd "${BASE_DIR}/../.."

Expand All @@ -10,5 +11,5 @@ if [ -n "$1" ]; then
fi

pushd ${MODULE_DIR}
go vet -mod=mod ./...
GOWORK=$GOWORK go vet -mod=mod ./...
popd

0 comments on commit 022d0ee

Please sign in to comment.