Skip to content

Commit ea69850

Browse files
authored
Merge pull request #54 from pohly/prow-update-master
master: update release-tools
2 parents 69b974f + 40bd270 commit ea69850

26 files changed

+190
-5520
lines changed

release-tools/build.make

Lines changed: 18 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
# including build.make.
2323
REGISTRY_NAME=quay.io/k8scsi
2424

25+
# Can be set to -mod=vendor to ensure that the "vendor" directory is used.
26+
GOFLAGS_VENDOR=
27+
2528
# Revision that gets built into each binary via the main.version
2629
# string. Uses the `git describe` output based on the most recent
2730
# version tag with a short revision suffix or, if nothing has been
@@ -62,11 +65,11 @@ ARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
6265
# Specific packages can be excluded from each of the tests below by setting the *_FILTER_CMD variables
6366
# to something like "| grep -v 'github.com/kubernetes-csi/project/pkg/foobar'". See usage below.
6467

65-
build-%:
68+
build-%: check-go-version-go
6669
mkdir -p bin
67-
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$* ./cmd/$*
70+
CGO_ENABLED=0 GOOS=linux go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$* ./cmd/$*
6871
if [ "$$ARCH" = "amd64" ]; then \
69-
CGO_ENABLED=0 GOOS=windows go build -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$*.exe ./cmd/$* ; \
72+
CGO_ENABLED=0 GOOS=windows go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$*.exe ./cmd/$* ; \
7073
fi
7174

7275
container-%: build-%
@@ -97,19 +100,19 @@ push: $(CMDS:%=push-%)
97100
clean:
98101
-rm -rf bin
99102

100-
test:
103+
test: check-go-version-go
101104

102105
.PHONY: test-go
103106
test: test-go
104107
test-go:
105108
@ echo; echo "### $@:"
106-
go test `go list ./... | grep -v -e 'vendor' -e '/test/e2e$$' $(TEST_GO_FILTER_CMD)` $(TESTARGS)
109+
go test $(GOFLAGS_VENDOR) `go list $(GOFLAGS_VENDOR) ./... | grep -v -e 'vendor' -e '/test/e2e$$' $(TEST_GO_FILTER_CMD)` $(TESTARGS)
107110

108111
.PHONY: test-vet
109112
test: test-vet
110113
test-vet:
111114
@ echo; echo "### $@:"
112-
go vet `go list ./... | grep -v vendor $(TEST_VET_FILTER_CMD)`
115+
go test $(GOFLAGS_VENDOR) `go list $(GOFLAGS_VENDOR) ./... | grep -v vendor $(TEST_VET_FILTER_CMD)`
113116

114117
.PHONY: test-fmt
115118
test: test-fmt
@@ -154,43 +157,7 @@ test-fmt:
154157
test: test-vendor
155158
test-vendor:
156159
@ echo; echo "### $@:"
157-
@ if [ -f Gopkg.toml ]; then \
158-
echo "Repo uses 'dep' for vendoring."; \
159-
case "$$(dep version 2>/dev/null | grep 'version *:')" in \
160-
*v0.[56789]*) dep check && echo "vendor up-to-date" || false;; \
161-
*) echo "skipping check, dep >= 0.5 required";; \
162-
esac; \
163-
elif [ -f go.mod ]; then \
164-
echo "Repo uses 'go mod'."; \
165-
if [ "$${JOB_NAME}" ] && \
166-
( [ "$${JOB_TYPE}" != "presubmit" ] || \
167-
[ $$( (git diff "${PULL_BASE_SHA}..HEAD" -- go.mod go.sum vendor release-tools; \
168-
git diff "${PULL_BASE_SHA}..HEAD" | grep -e '^@@.*@@ import (' -e '^[+-]import') | \
169-
wc -l) -eq 0 ] ); then \
170-
echo "Skipping vendor check because the Prow pre-submit job does not affect dependencies."; \
171-
elif ! GO111MODULE=on go mod tidy; then \
172-
echo "ERROR: vendor check failed."; \
173-
false; \
174-
elif [ $$(git status --porcelain -- go.mod go.sum | wc -l) -gt 0 ]; then \
175-
echo "ERROR: go module files *not* up-to-date, they did get modified by 'GO111MODULE=on go mod tidy':"; \
176-
git diff -- go.mod go.sum; \
177-
false; \
178-
elif [ -d vendor ]; then \
179-
if ! GO111MODULE=on go mod vendor; then \
180-
echo "ERROR: vendor check failed."; \
181-
false; \
182-
elif [ $$(git status --porcelain -- vendor | wc -l) -gt 0 ]; then \
183-
echo "ERROR: vendor directory *not* up-to-date, it did get modified by 'GO111MODULE=on go mod vendor':"; \
184-
git status -- vendor; \
185-
git diff -- vendor; \
186-
false; \
187-
else \
188-
echo "Go dependencies and vendor directory up-to-date."; \
189-
fi; \
190-
else \
191-
echo "Go dependencies up-to-date."; \
192-
fi; \
193-
fi
160+
@ ./release-tools/verify-vendor.sh
194161

195162
.PHONY: test-subtree
196163
test: test-subtree
@@ -216,3 +183,11 @@ test-shellcheck:
216183
./release-tools/verify-shellcheck.sh "$$dir" || ret=1; \
217184
done; \
218185
exit $$ret
186+
187+
# Targets in the makefile can depend on check-go-version-<path to go binary>
188+
# to trigger a warning if the x.y version of that binary does not match
189+
# what the project uses. Make ensures that this is only checked once per
190+
# invocation.
191+
.PHONY: check-go-version-%
192+
check-go-version-%:
193+
./release-tools/verify-go-version.sh "$*"

release-tools/prow.sh

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ get_versioned_variable () {
8585
echo "$value"
8686
}
8787

88+
# If we have a vendor directory, then use it. We must be careful to only
89+
# use this for "make" invocations inside the project's repo itself because
90+
# setting it globally can break other go usages (like "go get <some command>"
91+
# which is disabled with GOFLAGS=-mod=vendor).
92+
configvar GOFLAGS_VENDOR "$( [ -d vendor ] && echo '-mod=vendor' )" "Go flags for using the vendor directory"
93+
8894
# Go versions can be specified seperately for different tasks
8995
# If the pre-installed Go is missing or a different
9096
# version, the required version here will get installed
@@ -101,7 +107,8 @@ configvar CSI_PROW_GO_VERSION_GINKGO "${CSI_PROW_GO_VERSION_BUILD}" "Go version
101107
# kind version to use. If the pre-installed version is different,
102108
# the desired version is downloaded from https://github.com/kubernetes-sigs/kind/releases/download/
103109
# (if available), otherwise it is built from source.
104-
configvar CSI_PROW_KIND_VERSION "v0.5.0" "kind"
110+
# TODO: https://github.com/kubernetes-csi/csi-release-tools/issues/39
111+
configvar CSI_PROW_KIND_VERSION "86bc23d84ac12dcb56a0528890736e2c347c2dc3" "kind"
105112

106113
# ginkgo test runner version to use. If the pre-installed version is
107114
# different, the desired version is built from source.
@@ -136,7 +143,6 @@ configvar CSI_PROW_KUBERNETES_VERSION 1.15.3 "Kubernetes"
136143
#
137144
# If the version is prefixed with "release-", then nothing
138145
# is overridden.
139-
override_k8s_version "1.13.10"
140146
override_k8s_version "1.14.6"
141147
override_k8s_version "1.15.3"
142148

@@ -183,7 +189,7 @@ configvar CSI_PROW_WORK "$(mkdir -p "$GOPATH/pkg" && mktemp -d "$GOPATH/pkg/csip
183189
#
184190
# When no deploy script is found (nothing in `deploy` directory,
185191
# CSI_PROW_HOSTPATH_REPO=none), nothing gets deployed.
186-
configvar CSI_PROW_HOSTPATH_VERSION "v1.2.0-rc8" "hostpath driver"
192+
configvar CSI_PROW_HOSTPATH_VERSION "v1.2.0" "hostpath driver"
187193
configvar CSI_PROW_HOSTPATH_REPO https://github.com/kubernetes-csi/csi-driver-host-path "hostpath repo"
188194
configvar CSI_PROW_DEPLOYMENT "" "deployment"
189195
configvar CSI_PROW_HOSTPATH_DRIVER_NAME "hostpath.csi.k8s.io" "the hostpath driver name"
@@ -200,9 +206,10 @@ configvar CSI_PROW_HOSTPATH_CANARY "" "hostpath image"
200206
# all generated files are present.
201207
#
202208
# CSI_PROW_E2E_REPO=none disables E2E testing.
203-
configvar CSI_PROW_E2E_VERSION_1_13 v1.14.0 "E2E version for Kubernetes 1.13.x" # we can't use the one from 1.13.x because it didn't have --storage.testdriver
209+
# TOOO: remove versioned variables and make e2e version match k8s version
204210
configvar CSI_PROW_E2E_VERSION_1_14 v1.14.0 "E2E version for Kubernetes 1.14.x"
205211
configvar CSI_PROW_E2E_VERSION_1_15 v1.15.0 "E2E version for Kubernetes 1.15.x"
212+
configvar CSI_PROW_E2E_VERSION_1_16 v1.16.0 "E2E version for Kubernetes 1.16.x"
206213
# TODO: add new CSI_PROW_E2E_VERSION entry for future Kubernetes releases
207214
configvar CSI_PROW_E2E_VERSION_LATEST master "E2E version for Kubernetes master" # testing against Kubernetes master is already tracking a moving target, so we might as well use a moving E2E version
208215
configvar CSI_PROW_E2E_REPO_LATEST https://github.com/kubernetes/kubernetes "E2E repo for Kubernetes >= 1.13.x" # currently the same for all versions
@@ -292,11 +299,6 @@ regex_join () {
292299
# alpha in previous Kubernetes releases. This was considered too
293300
# error prone. Therefore we use E2E tests that match the Kubernetes
294301
# version that is getting tested.
295-
#
296-
# However, for 1.13.x testing we have to use the E2E tests from 1.14
297-
# because 1.13 didn't have --storage.testdriver yet, so for that (and only
298-
# that version) we have to define alpha tests differently.
299-
configvar CSI_PROW_E2E_ALPHA_1_13 '\[Feature: \[Testpattern:.Dynamic.PV..block.volmode.\] should.create.and.delete.block.persistent.volumes' "alpha tests for Kubernetes 1.13" # Raw block was an alpha feature in 1.13.
300302
configvar CSI_PROW_E2E_ALPHA_LATEST '\[Feature:' "alpha tests for Kubernetes >= 1.14" # there's no need to update this, adding a new case for CSI_PROW_E2E for a new Kubernetes is enough
301303
configvar CSI_PROW_E2E_ALPHA "$(get_versioned_variable CSI_PROW_E2E_ALPHA "${csi_prow_kubernetes_version_suffix}")" "alpha tests"
302304

@@ -312,12 +314,12 @@ configvar CSI_PROW_E2E_ALPHA "$(get_versioned_variable CSI_PROW_E2E_ALPHA "${csi
312314
# kubernetes-csi components must be updated, either by disabling
313315
# the failing test for "latest" or by updating the test and not running
314316
# it anymore for older releases.
315-
configvar CSI_PROW_E2E_ALPHA_GATES_1_13 'VolumeSnapshotDataSource=true,BlockVolume=true,CSIBlockVolume=true' "alpha feature gates for Kubernetes 1.13"
316317
configvar CSI_PROW_E2E_ALPHA_GATES_1_14 'VolumeSnapshotDataSource=true,ExpandCSIVolumes=true' "alpha feature gates for Kubernetes 1.14"
317318
configvar CSI_PROW_E2E_ALPHA_GATES_1_15 'VolumeSnapshotDataSource=true,ExpandCSIVolumes=true' "alpha feature gates for Kubernetes 1.15"
319+
configvar CSI_PROW_E2E_ALPHA_GATES_1_16 'VolumeSnapshotDataSource=true' "alpha feature gates for Kubernetes 1.16"
318320
# TODO: add new CSI_PROW_ALPHA_GATES_xxx entry for future Kubernetes releases and
319321
# add new gates to CSI_PROW_E2E_ALPHA_GATES_LATEST.
320-
configvar CSI_PROW_E2E_ALPHA_GATES_LATEST 'VolumeSnapshotDataSource=true,ExpandCSIVolumes=true' "alpha feature gates for latest Kubernetes"
322+
configvar CSI_PROW_E2E_ALPHA_GATES_LATEST 'VolumeSnapshotDataSource=true' "alpha feature gates for latest Kubernetes"
321323
configvar CSI_PROW_E2E_ALPHA_GATES "$(get_versioned_variable CSI_PROW_E2E_ALPHA_GATES "${csi_prow_kubernetes_version_suffix}")" "alpha E2E feature gates"
322324

323325
# Some tests are known to be unusable in a KinD cluster. For example,
@@ -723,22 +725,6 @@ install_sanity () (
723725
run_with_go "${CSI_PROW_GO_VERSION_SANITY}" go test -c -o "${CSI_PROW_WORK}/csi-sanity" "${CSI_PROW_SANITY_IMPORT_PATH}/cmd/csi-sanity" || die "building csi-sanity failed"
724726
)
725727

726-
# Whether the hostpath driver supports raw block devices depends on which version
727-
# we are testing. It would be much nicer if we could determine that by querying the
728-
# installed driver's capabilities instead of having to do a version check.
729-
hostpath_supports_block () {
730-
local result
731-
result="$(docker exec csi-prow-control-plane docker image ls --format='{{.Repository}} {{.Tag}} {{.ID}}' | grep hostpath | while read -r repo tag id; do
732-
if [ "$tag" == "v1.0.1" ]; then
733-
# Old version because the revision label is missing: didn't have support yet.
734-
echo "false"
735-
return
736-
fi
737-
done)"
738-
# If not set, then it must be a newer driver with support.
739-
echo "${result:-true}"
740-
}
741-
742728
# The default implementation of this function generates a external
743729
# driver test configuration for the hostpath driver.
744730
#
@@ -755,12 +741,14 @@ SnapshotClass:
755741
DriverInfo:
756742
Name: ${CSI_PROW_HOSTPATH_DRIVER_NAME}
757743
Capabilities:
758-
block: $(hostpath_supports_block)
744+
block: true
759745
persistence: true
760746
dataSource: true
761747
multipods: true
762748
nodeExpansion: true
763749
controllerExpansion: true
750+
snapshotDataSource: true
751+
singleNodeVolume: true
764752
EOF
765753
}
766754

@@ -946,7 +934,7 @@ main () {
946934
images=
947935
if ${CSI_PROW_BUILD_JOB}; then
948936
# A successful build is required for testing.
949-
run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make all || die "'make all' failed"
937+
run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make all "GOFLAGS_VENDOR=${GOFLAGS_VENDOR}" || die "'make all' failed"
950938
# We don't want test failures to prevent E2E testing below, because the failure
951939
# might have been minor or unavoidable, for example when experimenting with
952940
# changes in "release-tools" in a PR (that fails the "is release-tools unmodified"
@@ -956,13 +944,13 @@ main () {
956944
warn "installing 'dep' failed, cannot test vendoring"
957945
ret=1
958946
fi
959-
if ! run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make -k test 2>&1 | make_test_to_junit; then
947+
if ! run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make -k test "GOFLAGS_VENDOR=${GOFLAGS_VENDOR}" 2>&1 | make_test_to_junit; then
960948
warn "'make test' failed, proceeding anyway"
961949
ret=1
962950
fi
963951
fi
964952
# Required for E2E testing.
965-
run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make container || die "'make container' failed"
953+
run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make container "GOFLAGS_VENDOR=${GOFLAGS_VENDOR}" || die "'make container' failed"
966954
fi
967955

968956
if tests_need_kind; then

release-tools/travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ git:
66
depth: false
77
matrix:
88
include:
9-
- go: 1.12.4
9+
- go: 1.13.3
1010
before_script:
1111
- mkdir -p bin
1212
- wget https://github.com/golang/dep/releases/download/v0.5.1/dep-linux-amd64 -O bin/dep
1313
- chmod u+x bin/dep
1414
- export PATH=$PWD/bin:$PATH
1515
script:
16-
- make -k all test
16+
- make -k all test GOFLAGS_VENDOR=$( [ -d vendor ] && echo '-mod=vendor' )
1717
after_success:
1818
- if [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then
1919
docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}" quay.io;
20-
make push;
20+
make push GOFLAGS_VENDOR=$( [ -d vendor ] && echo '-mod=vendor' );
2121
fi

release-tools/update-vendor.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2019 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
if [ -f Gopkg.toml ]; then
18+
echo "Repo uses 'dep' for vendoring."
19+
(set -x; dep ensure)
20+
elif [ -f go.mod ]; then
21+
release-tools/verify-go-version.sh "go"
22+
(set -x; env GO111MODULE=on go mod tidy && env GO111MODULE=on go mod vendor)
23+
fi

release-tools/verify-go-version.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2019 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
GO="$1"
18+
19+
if [ ! "$GO" ]; then
20+
echo >&2 "usage: $0 <path to go binary>"
21+
exit 1
22+
fi
23+
24+
die () {
25+
echo "ERROR: $*"
26+
exit 1
27+
}
28+
29+
version=$("$GO" version) || die "determining version of $GO failed"
30+
# shellcheck disable=SC2001
31+
majorminor=$(echo "$version" | sed -e 's/.*go\([0-9]*\)\.\([0-9]*\).*/\1.\2/')
32+
# shellcheck disable=SC2001
33+
expected=$(grep "^ *- go:" "release-tools/travis.yml" | sed -e 's/.*go: *\([0-9]*\)\.\([0-9]*\).*/\1.\2/')
34+
35+
if [ "$majorminor" != "$expected" ]; then
36+
cat >&2 <<EOF
37+
38+
======================================================
39+
WARNING
40+
41+
This projects is tested with Go v$expected.
42+
Your current Go version is v$majorminor.
43+
This may or may not be close enough.
44+
45+
In particular test-gofmt and test-vendor
46+
are known to be sensitive to the version of
47+
Go.
48+
======================================================
49+
50+
EOF
51+
fi

0 commit comments

Comments
 (0)