Skip to content

Commit 4bbf417

Browse files
committed
Squashed 'release-tools/' changes from c60f382..a0f195c
a0f195c Merge pull request kubernetes-csi#106 from msau42/fix-canary 7100c12 Only set staging registry when running canary job b3c65f9 Merge pull request kubernetes-csi#99 from msau42/add-release-process e53f3e8 Merge pull request kubernetes-csi#103 from msau42/fix-canary d129462 Document new method for adding CI jobs are new K8s versions e73c2ce Use staging registry for canary tests 2c09846 Add cleanup instructions to release-notes generation 60e1cd3 Merge pull request kubernetes-csi#98 from pohly/kubernetes-1-19-fixes 0979c09 prow.sh: fix E2E suite for Kubernetes >= 1.18 3b4a2f1 prow.sh: fix installing Go for Kubernetes 1.19.0 1fbb636 Merge pull request kubernetes-csi#97 from pohly/go-1.15 82d108a switch to Go 1.15 d8a2530 Merge pull request kubernetes-csi#95 from msau42/add-release-process 843bddc Add steps on promoting release images 0345a83 Merge pull request kubernetes-csi#94 from linux-on-ibm-z/bump-timeout 1fdf2d5 cloud build: bump timeout in Prow job 41ec6d1 Merge pull request kubernetes-csi#93 from animeshk08/patch-1 5a54e67 filter-junit: Fix gofmt error 0676fcb Merge pull request kubernetes-csi#92 from animeshk08/patch-1 36ea4ff filter-junit: Fix golint error f5a4203 Merge pull request kubernetes-csi#91 from cyb70289/arm64 43e50d6 prow.sh: enable building arm64 image 0d5bd84 Merge pull request kubernetes-csi#90 from pohly/k8s-staging-sig-storage 3df86b7 cloud build: k8s-staging-sig-storage c5fd961 Merge pull request kubernetes-csi#89 from pohly/cloud-build-binfmt db0c2a7 cloud build: initialize support for running commands in Dockerfile be902f4 Merge pull request kubernetes-csi#88 from pohly/multiarch-windows-fix 340e082 build.make: optional inclusion of Windows in multiarch images 5231f05 build.make: properly declare push-multiarch 4569f27 build.make: fix push-multiarch ambiguity 17dde9e Merge pull request kubernetes-csi#87 from pohly/cloud-build bd41690 cloud build: initial set of shared files 9084fec Merge pull request kubernetes-csi#81 from msau42/add-release-process 6f2322e Update patch release notes generation command 0fcc3b1 Merge pull request kubernetes-csi#78 from ggriffiths/fix_csi_snapshotter_rbac_version_set d8c76fe Support local snapshot RBAC for pull jobs c1bdf5b Merge pull request kubernetes-csi#80 from msau42/add-release-process ea1f94a update release tools instructions 152396e Merge pull request kubernetes-csi#77 from ggriffiths/snapshotter201_update 7edc146 Update snapshotter to version 2.0.1 4cf843f Merge pull request kubernetes-csi#76 from pohly/build-targets 3863a0f build for multiple platforms only in CI, add s390x 8322a7d Merge pull request kubernetes-csi#72 from pohly/hostpath-update 7c5a89c prow.sh: use 1.3.0 hostpath driver for testing b8587b2 Merge pull request kubernetes-csi#71 from wozniakjan/test-vet fdb3218 Change 'make test-vet' to call 'go vet' d717c8c Merge pull request kubernetes-csi#69 from pohly/test-driver-config a1432bc Merge pull request kubernetes-csi#70 from pohly/kubelet-feature-gates 5f74333 prow.sh: also configure feature gates for kubelet 84f78b1 prow.sh: generic driver installation 3c34b4f Merge pull request kubernetes-csi#67 from windayski/fix-link fa90abd fix incorrect link ff3cc3f Merge pull request kubernetes-csi#54 from msau42/add-release-process ac8a021 Document the process for releasing a new sidecar 23be652 Merge pull request kubernetes-csi#65 from msau42/update-hostpath 6582f2f Update hostpath driver version to get fix for connection-timeout 4cc9174 Merge pull request kubernetes-csi#64 from ggriffiths/snapshotter_2_version_update 8191eab Update snapshotter to version v2.0.0 3c463fb Merge pull request kubernetes-csi#61 from msau42/enable-snapshots 8b0316c Fix overriding of junit results by using unique names for each e2e run 5f444b8 Merge pull request kubernetes-csi#60 from saad-ali/updateHostpathVersion af9549b Update prow hostpath driver version to 1.3.0-rc2 f6c74b3 Merge pull request kubernetes-csi#57 from ggriffiths/version_gt_kubernetes_fix fc80975 Fix version_gt to work with kubernetes prefix 9f1f3dd Merge pull request kubernetes-csi#56 from msau42/enable-snapshots b98b2ae Enable snapshot tests in 1.17 to be run in non-alpha jobs. 9ace020 Merge pull request kubernetes-csi#52 from msau42/update-readme 540599b Merge pull request kubernetes-csi#53 from msau42/fix-make a4e6299 fix syntax for ppc64le build 771ca6f Merge pull request kubernetes-csi#49 from ggriffiths/prowsh_improve_version_gt d7c69d2 Merge pull request kubernetes-csi#51 from msau42/enable-multinode 4ad6949 Improve snapshot pod running checks and improve version_gt 53888ae Improve README by adding an explicit Kubernetes dependency section 9a7a685 Create a kind cluster with two worker nodes so that the topology feature can be tested. Test cases that test accessing volumes from multiple nodes need to be skipped 4ff2f5f Merge pull request kubernetes-csi#50 from darkowlzz/kind-0.6.0 80bba1f Use kind v0.6.0 6d674a7 Merge pull request kubernetes-csi#47 from Pensu/multi-arch 8adde49 Merge pull request kubernetes-csi#45 from ggriffiths/snapshot_beta_crds 003c14b Add snapshotter CRDs after cluster setup a41f386 Merge pull request kubernetes-csi#46 from mucahitkurt/kind-cluster-cleanup 1eaaaa1 Delete kind cluster after tests run. 83a4ef1 Adding build for ppc64le 4fcafec Merge pull request kubernetes-csi#43 from pohly/system-pod-logging f41c135 prow.sh: also log output of system containers ee22a9c Merge pull request kubernetes-csi#42 from pohly/use-vendor-dir 8067845 travis.yml: also use vendor directory 23df4ae prow.sh: use vendor directory if available a53bd4c Merge pull request kubernetes-csi#41 from pohly/go-version c8a1c4a better handling of Go version 5e773d2 update CI to use Go 1.13.3 f419d74 Merge pull request kubernetes-csi#40 from msau42/add-1.16 e0fde8c Add new variables for 1.16 and remove 1.13 adf00fe Merge pull request kubernetes-csi#36 from msau42/full-clone f1697d2 Do full git clones in travis. Shallow clones are causing test-subtree errors when the depth is exactly 50. 2c81919 Merge pull request kubernetes-csi#34 from pohly/go-mod-tidy 518d6af Merge pull request kubernetes-csi#35 from ddebroy/winbld2 2d6b3ce Build Windows only for amd64 c1078a6 go-get-kubernetes.sh: automate Kubernetes dependency handling 194289a update Go mod support 0affdf9 Merge pull request kubernetes-csi#33 from gnufied/enable-hostpath-expansion 6208f6a Enable hostpath expansion 6ecaa76 Merge pull request kubernetes-csi#30 from msau42/fix-windows ea2f1b5 build windows binaries with .exe suffix 2d33550 Merge pull request kubernetes-csi#29 from mucahitkurt/create-2-node-kind-cluster a8ea8bc create 2-node kind cluster since topology support is added to hostpath driver df8530d Merge pull request kubernetes-csi#27 from pohly/dep-vendor-check 35ceaed prow.sh: install dep if needed f85ab5a Merge pull request kubernetes-csi#26 from ddebroy/windows1 9fba09b Add rule for building Windows binaries 0400867 Merge pull request kubernetes-csi#25 from msau42/fix-master-jobs dc0a5d8 Update kind to v0.5.0 aa85b82 Merge pull request kubernetes-csi#23 from msau42/fix-master-jobs f46191d Kubernetes master changed the way that releases are tagged, which needed changes to kind. There are 3 changes made to prow.sh: 1cac3af Merge pull request kubernetes-csi#22 from msau42/add-1.15-jobs 0c0dc30 prow.sh: tag master images with a large version number f4f73ce Merge pull request kubernetes-csi#21 from msau42/add-1.15-jobs 4e31f07 Change default hostpath driver name to hostpath.csi.k8s.io 4b6fa4a Update hostpath version for sidecar testing to v1.2.0-rc2 ecc7918 Update kind to v0.4.0. This requires overriding Kubernetes versions with specific patch versions that kind 0.4.0 supports. Also, feature gate setting is only supported on 1.15+ due to kind.sigs.k8s.io/v1alpha3 and kubeadm.k8s.io/v1beta2 dependencies. a6f21d4 Add variables for 1.15 db8abb6 Merge pull request kubernetes-csi#20 from pohly/test-driver-config b2f4e05 prow.sh: flexible test driver config 0399988 Merge pull request kubernetes-csi#19 from pohly/go-mod-vendor 066143d build.make: allow repos to use 'go mod' for vendoring 0bee749 Merge pull request kubernetes-csi#18 from pohly/go-version e157b6b update to Go 1.12.4 88dc9a4 Merge pull request kubernetes-csi#17 from pohly/prow 0fafc66 prow.sh: skip sanity testing if component doesn't support it bcac1c1 Merge pull request kubernetes-csi#16 from pohly/prow 0b10f6a prow.sh: update csi-driver-host-path 0c2677e Merge pull request kubernetes-csi#15 from pengzhisun/master ff9bce4 Replace 'return' to 'exit' to fix shellcheck error git-subtree-dir: release-tools git-subtree-split: a0f195cc2ddc2a1f07d4d3e46fc08187db358f94
1 parent c60f382 commit 4bbf417

12 files changed

+1002
-187
lines changed

README.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ on what is enabled in Prow, see
8181
https://github.com/kubernetes/test-infra/tree/master/config/jobs/kubernetes-csi
8282

8383
Test results for periodic jobs are visible in
84-
https://testgrid.k8s.io/sig-storage-csi
84+
https://testgrid.k8s.io/sig-storage-csi-ci
8585

8686
It is possible to reproduce the Prow testing locally on a suitable machine:
8787
- Linux host
@@ -106,3 +106,61 @@ Kubernetes releases:
106106

107107
CSI_PROW_KUBERNETES_VERSION=1.13.3 ./.prow.sh
108108
CSI_PROW_KUBERNETES_VERSION=latest ./.prow.sh
109+
110+
Dependencies and vendoring
111+
--------------------------
112+
113+
Most projects will (eventually) use `go mod` to manage
114+
dependencies. `dep` is also still supported by `csi-release-tools`,
115+
but not documented here because it's not recommended anymore.
116+
117+
The usual instructions for using [go
118+
modules](https://github.com/golang/go/wiki/Modules) apply. Here's a cheat sheet
119+
for some of the relevant commands:
120+
- list available updates: `GO111MODULE=on go list -u -m all`
121+
- update or add a single dependency: `GO111MODULE=on go get <package>`
122+
- update all dependencies to their next minor or patch release:
123+
`GO111MODULE=on go get ./...` (add `-u=patch` to limit to patch
124+
releases)
125+
- lock onto a specific version: `GO111MODULE=on go get <package>@<version>`
126+
- clean up `go.mod`: `GO111MODULE=on go mod tidy`
127+
- update vendor directory: `GO111MODULE=on go mod vendor`
128+
129+
`GO111MODULE=on` can be left out when using Go >= 1.13 or when the
130+
source is checked out outside of `$GOPATH`.
131+
132+
`go mod tidy` must be used to ensure that the listed dependencies are
133+
really still needed. Changing import statements or a tentative `go
134+
get` can result in stale dependencies.
135+
136+
The `test-vendor` verifies that it was used when run locally or in a
137+
pre-merge CI job. If a `vendor` directory is present, it will also
138+
verify that it's content is up-to-date.
139+
140+
The `vendor` directory is optional. It is still present in projects
141+
because it avoids downloading sources during CI builds. If this is no
142+
longer deemed necessary, then a project can also remove the directory.
143+
144+
Conversion of a repository that uses `dep` to `go mod` can be done with:
145+
146+
GO111MODULE=on go mod init
147+
release-tools/go-get-kubernetes.sh <current Kubernetes version from Gopkg.toml>
148+
GO111MODULE=on go mod tidy
149+
GO111MODULE=on go mod vendor
150+
git rm -f Gopkg.toml Gopkg.lock
151+
git add go.mod go.sum vendor
152+
153+
### Updating Kubernetes dependencies
154+
155+
When using packages that are part of the Kubernetes source code, the
156+
commands above are not enough because the [lack of semantic
157+
versioning](https://github.com/kubernetes/kubernetes/issues/72638)
158+
prevents `go mod` from finding newer releases. Importing directly from
159+
`kubernetes/kubernetes` also needs `replace` statements to override
160+
the fake `v0.0.0` versions
161+
(https://github.com/kubernetes/kubernetes/issues/79384). The
162+
`go-get-kubernetes.sh` script can be used to update all packages in
163+
lockstep to a different Kubernetes version. Example usage:
164+
```
165+
$ ./release-tools/go-get-kubernetes.sh 1.16.4
166+
```

SIDECAR_RELEASE_PROCESS.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Sidecar Release Process
2+
3+
This page describes the process for releasing a kubernetes-csi sidecar.
4+
5+
## Prerequisites
6+
7+
The release manager must:
8+
9+
* Be a member of the kubernetes-csi organization. Open an
10+
[issue](https://github.com/kubernetes/org/issues/new?assignees=&labels=area%2Fgithub-membership&template=membership.md&title=REQUEST%3A+New+membership+for+%3Cyour-GH-handle%3E) in
11+
kubernetes/org to request membership
12+
* Be a top level approver for the repository. To become a top level approver,
13+
the candidate must demonstrate ownership and deep knowledge of the repository
14+
through active maintainence, responding to and fixing issues, reviewing PRs,
15+
test triage.
16+
* Be part of the maintainers or admin group for the repository. admin is a
17+
superset of maintainers, only maintainers level is required for cutting a
18+
release. Membership can be requested by submitting a PR to kubernetes/org.
19+
[Example](https://github.com/kubernetes/org/pull/1467)
20+
21+
## Updating CI Jobs
22+
Whenever a new Kubernetes minor version is released, our kubernetes-csi CI jobs
23+
must be updated.
24+
25+
[Our CI jobs](https://k8s-testgrid.appspot.com/sig-storage-csi-ci) have the
26+
naming convention `<hostpath-deployment-version>-on-<kubernetes-version>`.
27+
28+
1. Jobs should be actively monitored to find and fix failures in sidecars and
29+
infrastructure changes early in the development cycle. Test failures are sent
30+
31+
1. "-on-master" jobs are the closest reflection to the new Kubernetes version.
32+
1. Fixes to our prow.sh CI script can be tested in the [CSI hostpath
33+
repo](https://github.com/kubernetes-csi/csi-driver-host-path) by modifying
34+
[prow.sh](https://github.com/kubernetes-csi/csi-driver-host-path/blob/master/release-tools/prow.sh)
35+
along with any overrides in
36+
[.prow.sh](https://github.com/kubernetes-csi/csi-driver-host-path/blob/master/.prow.sh)
37+
to mirror the failing environment. Once e2e tests are passing (verify-unit tests
38+
will fail), then the prow.sh changes can be submitted to [csi-release-tools](https://github.com/kubernetes-csi/csi-release-tools).
39+
1. Changes can then be updated in all the sidecar repos and hostpath driver repo
40+
by following the [update
41+
instructions](https://github.com/kubernetes-csi/csi-release-tools/blob/master/README.md#sharing-and-updating).
42+
1. New pull and CI jobs are configured by adding new K8s versions to the top of
43+
[gen-jobs.sh](https://github.com/kubernetes/test-infra/blob/master/config/jobs/kubernetes-csi/gen-jobs.sh).
44+
New pull jobs that have been unverified should be initially made optional by
45+
setting the new K8s version as
46+
[experimental](https://github.com/kubernetes/test-infra/blob/a1858f46d6014480b130789df58b230a49203a64/config/jobs/kubernetes-csi/gen-jobs.sh#L40).
47+
1. Once new pull and CI jobs have been verified, and the new Kubernetes version
48+
is released, we can make the optional jobs required, and also remove the
49+
Kubernetes versions that are no longer supported.
50+
51+
## Release Process
52+
1. Identify all issues and ongoing PRs that should go into the release, and
53+
drive them to resolution.
54+
1. Download v2.8+ [K8s release notes
55+
generator](https://github.com/kubernetes/release/tree/master/cmd/release-notes)
56+
1. Generate release notes for the release. Replace arguments with the relevant
57+
information.
58+
* Clean up old cached information (also needed if you are generating release
59+
notes for multiple repos)
60+
```bash
61+
rm -rf /tmp/k8s-repo
62+
```
63+
* For new minor releases on master:
64+
```bash
65+
GITHUB_TOKEN=<token> release-notes --discover=mergebase-to-latest
66+
--github-org=kubernetes-csi --github-repo=external-provisioner
67+
--required-author="" --output out.md
68+
```
69+
* For new patch releases on a release branch:
70+
```bash
71+
GITHUB_TOKEN=<token> release-notes --discover=patch-to-latest --branch=release-1.1
72+
--github-org=kubernetes-csi --github-repo=external-provisioner
73+
--required-author="" --output out.md
74+
```
75+
1. Compare the generated output to the new commits for the release to check if
76+
any notable change missed a release note.
77+
1. Reword release notes as needed. Make sure to check notes for breaking
78+
changes and deprecations.
79+
1. If release is a new major/minor version, create a new `CHANGELOG-<major>.<minor>.md`
80+
file. Otherwise, add the release notes to the top of the existing CHANGELOG
81+
file for that minor version.
82+
1. Submit a PR for the CHANGELOG changes.
83+
1. Submit a PR for README changes, in particular, Compatibility, Feature status,
84+
and any other sections that may need updating.
85+
1. Check that all [canary CI
86+
jobs](https://k8s-testgrid.appspot.com/sig-storage-csi-ci) are passing,
87+
and that test coverage is adequate for the changes that are going into the release.
88+
1. Make sure that no new PRs have merged in the meantime, and no PRs are in
89+
flight and soon to be merged.
90+
1. Create a new release following a previous release as a template. Be sure to select the correct
91+
branch. This requires Github release permissions as required by the prerequisites.
92+
[external-provisioner example](https://github.com/kubernetes-csi/external-provisioner/releases/new)
93+
1. If release was a new major/minor version, create a new `release-<minor>`
94+
branch at that commit.
95+
1. Check [image build status](https://k8s-testgrid.appspot.com/sig-storage-image-build).
96+
1. Promote images from k8s-staging-sig-storage to k8s.gcr.io/sig-storage. From
97+
the [k8s image
98+
repo](https://github.com/kubernetes/k8s.io/tree/master/k8s.gcr.io/images/k8s-staging-sig-storage),
99+
run `./generate.sh > images.yaml`, and send a PR with the updated images.
100+
Once merged, the image promoter will copy the images from staging to prod.
101+
1. Update [kubernetes-csi/docs](https://github.com/kubernetes-csi/docs) sidecar
102+
and feature pages with the new released version.
103+
1. After all the sidecars have been released, update
104+
CSI hostpath driver with the new sidecars in the [CSI repo](https://github.com/kubernetes-csi/csi-driver-host-path/tree/master/deploy)
105+
and [k/k
106+
in-tree](https://github.com/kubernetes/kubernetes/tree/master/test/e2e/testing-manifests/storage-csi/hostpath/hostpath)

build.make

Lines changed: 132 additions & 13 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
@@ -60,14 +63,27 @@ endif
6063
# Specific packages can be excluded from each of the tests below by setting the *_FILTER_CMD variables
6164
# to something like "| grep -v 'github.com/kubernetes-csi/project/pkg/foobar'". See usage below.
6265

63-
build-%:
66+
# BUILD_PLATFORMS contains a set of <os> <arch> <suffix> triplets,
67+
# separated by semicolon. An empty variable or empty entry (= just a
68+
# semicolon) builds for the default platform of the current Go
69+
# toolchain.
70+
BUILD_PLATFORMS =
71+
72+
# This builds each command (= the sub-directories of ./cmd) for the target platform(s)
73+
# defined by BUILD_PLATFORMS.
74+
$(CMDS:%=build-%): build-%: check-go-version-go
6475
mkdir -p bin
65-
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./bin/$* ./cmd/$*
76+
echo '$(BUILD_PLATFORMS)' | tr ';' '\n' | while read -r os arch suffix; do \
77+
if ! (set -x; CGO_ENABLED=0 GOOS="$$os" GOARCH="$$arch" go build $(GOFLAGS_VENDOR) -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o "./bin/$*$$suffix" ./cmd/$*); then \
78+
echo "Building $* for GOOS=$$os GOARCH=$$arch failed, see error(s) above."; \
79+
exit 1; \
80+
fi; \
81+
done
6682

67-
container-%: build-%
83+
$(CMDS:%=container-%): container-%: build-%
6884
docker build -t $*:latest -f $(shell if [ -e ./cmd/$*/Dockerfile ]; then echo ./cmd/$*/Dockerfile; else echo Dockerfile; fi) --label revision=$(REV) .
6985

70-
push-%: container-%
86+
$(CMDS:%=push-%): push-%: container-%
7187
set -ex; \
7288
push_image () { \
7389
docker tag $*:latest $(IMAGE_NAME):$$tag; \
@@ -89,22 +105,93 @@ build: $(CMDS:%=build-%)
89105
container: $(CMDS:%=container-%)
90106
push: $(CMDS:%=push-%)
91107

108+
# Additional parameters are needed when pushing to a local registry,
109+
# see https://github.com/docker/buildx/issues/94.
110+
# However, that then runs into https://github.com/docker/cli/issues/2396.
111+
#
112+
# What works for local testing is:
113+
# make push-multiarch PULL_BASE_REF=master REGISTRY_NAME=<your account on dockerhub.io> BUILD_PLATFORMS="linux amd64; windows amd64 .exe; linux ppc64le -ppc64le; linux s390x -s390x"
114+
DOCKER_BUILDX_CREATE_ARGS ?=
115+
116+
# This target builds a multiarch image for one command using Moby BuildKit builder toolkit.
117+
# Docker Buildx is included in Docker 19.03.
118+
#
119+
# ./cmd/<command>/Dockerfile[.Windows] is used if found, otherwise Dockerfile[.Windows].
120+
# It is currently optional: if no such file exists, Windows images are not included,
121+
# even when Windows is listed in BUILD_PLATFORMS. That way, projects can test that
122+
# Windows binaries can be built before adding a Dockerfile for it.
123+
#
124+
# BUILD_PLATFORMS determines which individual images are included in the multiarch image.
125+
# PULL_BASE_REF must be set to 'master', 'release-x.y', or a tag name, and determines
126+
# the tag for the resulting multiarch image.
127+
$(CMDS:%=push-multiarch-%): push-multiarch-%: check-pull-base-ref build-%
128+
set -ex; \
129+
DOCKER_CLI_EXPERIMENTAL=enabled; \
130+
export DOCKER_CLI_EXPERIMENTAL; \
131+
docker buildx create $(DOCKER_BUILDX_CREATE_ARGS) --use --name multiarchimage-buildertest; \
132+
trap "docker buildx rm multiarchimage-buildertest" EXIT; \
133+
dockerfile_linux=$$(if [ -e ./cmd/$*/Dockerfile ]; then echo ./cmd/$*/Dockerfile; else echo Dockerfile; fi); \
134+
dockerfile_windows=$$(if [ -e ./cmd/$*/Dockerfile.Windows ]; then echo ./cmd/$*/Dockerfile.Windows; else echo Dockerfile.Windows; fi); \
135+
if [ '$(BUILD_PLATFORMS)' ]; then build_platforms='$(BUILD_PLATFORMS)'; else build_platforms="linux amd64"; fi; \
136+
if ! [ -f "$$dockerfile_windows" ]; then \
137+
build_platforms="$$(echo "$$build_platforms" | sed -e 's/windows *[^ ]* *.exe//g' -e 's/; *;/;/g')"; \
138+
fi; \
139+
pushMultiArch () { \
140+
tag=$$1; \
141+
echo "$$build_platforms" | tr ';' '\n' | while read -r os arch suffix; do \
142+
docker buildx build --push \
143+
--tag $(IMAGE_NAME):$$arch-$$os-$$tag \
144+
--platform=$$os/$$arch \
145+
--file $$(eval echo \$${dockerfile_$$os}) \
146+
--build-arg binary=./bin/$*$$suffix \
147+
--label revision=$(REV) \
148+
.; \
149+
done; \
150+
images=$$(echo "$$build_platforms" | tr ';' '\n' | while read -r os arch suffix; do echo $(IMAGE_NAME):$$arch-$$os-$$tag; done); \
151+
docker manifest create --amend $(IMAGE_NAME):$$tag $$images; \
152+
docker manifest push -p $(IMAGE_NAME):$$tag; \
153+
}; \
154+
if [ $(PULL_BASE_REF) = "master" ]; then \
155+
: "creating or overwriting canary image"; \
156+
pushMultiArch canary; \
157+
elif echo $(PULL_BASE_REF) | grep -q -e 'release-*' ; then \
158+
: "creating or overwriting canary image for release branch"; \
159+
release_canary_tag=$$(echo $(PULL_BASE_REF) | cut -f2 -d '-')-canary; \
160+
pushMultiArch $$release_canary_tag; \
161+
elif docker pull $(IMAGE_NAME):$(PULL_BASE_REF) 2>&1 | tee /dev/stderr | grep -q "manifest for $(IMAGE_NAME):$(PULL_BASE_REF) not found"; then \
162+
: "creating release image"; \
163+
pushMultiArch $(PULL_BASE_REF); \
164+
else \
165+
: "ERROR: release image $(IMAGE_NAME):$(PULL_BASE_REF) already exists: a new tag is required!"; \
166+
exit 1; \
167+
fi
168+
169+
.PHONY: check-pull-base-ref
170+
check-pull-base-ref:
171+
if ! [ "$(PULL_BASE_REF)" ]; then \
172+
echo >&2 "ERROR: PULL_BASE_REF must be set to 'master', 'release-x.y', or a tag name."; \
173+
exit 1; \
174+
fi
175+
176+
.PHONY: push-multiarch
177+
push-multiarch: $(CMDS:%=push-multiarch-%)
178+
92179
clean:
93180
-rm -rf bin
94181

95-
test:
182+
test: check-go-version-go
96183

97184
.PHONY: test-go
98185
test: test-go
99186
test-go:
100187
@ echo; echo "### $@:"
101-
go test `go list ./... | grep -v -e 'vendor' -e '/test/e2e$$' $(TEST_GO_FILTER_CMD)` $(TESTARGS)
188+
go test $(GOFLAGS_VENDOR) `go list $(GOFLAGS_VENDOR) ./... | grep -v -e 'vendor' -e '/test/e2e$$' $(TEST_GO_FILTER_CMD)` $(TESTARGS)
102189

103190
.PHONY: test-vet
104191
test: test-vet
105192
test-vet:
106193
@ echo; echo "### $@:"
107-
go vet `go list ./... | grep -v vendor $(TEST_VET_FILTER_CMD)`
194+
go vet $(GOFLAGS_VENDOR) `go list $(GOFLAGS_VENDOR) ./... | grep -v vendor $(TEST_VET_FILTER_CMD)`
108195

109196
.PHONY: test-fmt
110197
test: test-fmt
@@ -118,14 +205,38 @@ test-fmt:
118205
fi
119206

120207
# This test only runs when dep >= 0.5 is installed, which is the case for the CI setup.
208+
# When using 'go mod', we allow the test to be skipped in the Prow CI under some special
209+
# circumstances, because it depends on accessing all remote repos and thus
210+
# running it all the time would defeat the purpose of vendoring:
211+
# - not handling a PR or
212+
# - the fabricated merge commit leaves go.mod, go.sum and vendor dir unchanged
213+
# - release-tools also didn't change (changing rules or Go version might lead to
214+
# a different result and thus must be tested)
215+
# - import statements not changed (because if they change, go.mod might have to be updated)
216+
#
217+
# "git diff" is intelligent enough to annotate changes inside the "import" block in
218+
# the start of the diff hunk:
219+
#
220+
# diff --git a/rpc/common.go b/rpc/common.go
221+
# index bb4a5c4..5fa4271 100644
222+
# --- a/rpc/common.go
223+
# +++ b/rpc/common.go
224+
# @@ -21,7 +21,6 @@ import (
225+
# "fmt"
226+
# "time"
227+
#
228+
# - "google.golang.org/grpc"
229+
# "google.golang.org/grpc/codes"
230+
# "google.golang.org/grpc/status"
231+
#
232+
# We rely on that to find such changes.
233+
#
234+
# Vendoring is optional when using go.mod.
121235
.PHONY: test-vendor
122236
test: test-vendor
123237
test-vendor:
124238
@ echo; echo "### $@:"
125-
@ case "$$(dep version 2>/dev/null | grep 'version *:')" in \
126-
*v0.[56789]*) dep check && echo "vendor up-to-date" || false;; \
127-
*) echo "skipping check, dep >= 0.5 required";; \
128-
esac
239+
@ ./release-tools/verify-vendor.sh
129240

130241
.PHONY: test-subtree
131242
test: test-subtree
@@ -143,11 +254,19 @@ test-shellcheck:
143254
@ ret=0; \
144255
if ! command -v docker; then \
145256
echo "skipped, no Docker"; \
146-
return 0; \
257+
exit 0; \
147258
fi; \
148259
for dir in $(abspath $(TEST_SHELLCHECK_DIRS)); do \
149260
echo; \
150261
echo "$$dir:"; \
151262
./release-tools/verify-shellcheck.sh "$$dir" || ret=1; \
152263
done; \
153-
return $$ret
264+
exit $$ret
265+
266+
# Targets in the makefile can depend on check-go-version-<path to go binary>
267+
# to trigger a warning if the x.y version of that binary does not match
268+
# what the project uses. Make ensures that this is only checked once per
269+
# invocation.
270+
.PHONY: check-go-version-%
271+
check-go-version-%:
272+
./release-tools/verify-go-version.sh "$*"

cloudbuild.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#! /bin/bash
2+
3+
# shellcheck disable=SC1091
4+
. release-tools/prow.sh
5+
6+
gcr_cloud_build

0 commit comments

Comments
 (0)