mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 05:36:12 +00:00
Rework hack/ and build/ directories.
* Rewrite a bunch of the hack/ directory with modular reusable bash libraries. * Have 'build/*' build on 'hack/*'. The stuff in build now just runs hack/* in a docker container. * Use a docker data container to enable faster incremental builds. * Standardize output to _output/{local,dockerized}/bin/OS/ARCH/*. This regularized placement makes cross compilation work. * Move travis specific scripts under hack/travis With new dockerized incremental builds, I can do a no-op `make quick-release` in ~30s. This is a significant improvement.
This commit is contained in:
@@ -25,6 +25,10 @@ ENV GOARCH amd64
|
||||
# Get the code coverage tool and godep
|
||||
RUN go get code.google.com/p/go.tools/cmd/cover github.com/tools/godep
|
||||
|
||||
# We use rsync to copy some binaries around. It is faster (0.3s vs. 1.1s) on my
|
||||
# machine vs. `install`
|
||||
RUN apt-get update && apt-get install -y rsync
|
||||
|
||||
# Download and symlink etcd. We need this for our integration tests.
|
||||
RUN mkdir -p /usr/local/src/etcd &&\
|
||||
cd /usr/local/src/etcd &&\
|
||||
@@ -39,6 +43,10 @@ WORKDIR /go/src/github.com/GoogleCloudPlatform/kubernetes
|
||||
|
||||
# Propagate the git tree version into the build image
|
||||
ADD kube-version-defs /kube-version-defs
|
||||
ENV KUBE_GIT_VERSION_FILE /kube-version-defs
|
||||
|
||||
# Make output from the dockerized build go someplace else
|
||||
ENV KUBE_OUTPUT_SUBPATH _output/dockerized
|
||||
|
||||
# Upload Kubernetes source
|
||||
ADD kube-source.tar.gz /go/src/github.com/GoogleCloudPlatform/kubernetes
|
||||
|
@@ -1,81 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# This script sets up a go workspace locally and builds all go components.
|
||||
# You can 'source' this file if you want to set up GOPATH in your local shell.
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||
cd "${KUBE_ROOT}"
|
||||
|
||||
readonly KUBE_TARGET="${KUBE_ROOT}/_output/build"
|
||||
readonly KUBE_GO_PACKAGE=github.com/GoogleCloudPlatform/kubernetes
|
||||
|
||||
server_targets=(
|
||||
cmd/proxy
|
||||
cmd/apiserver
|
||||
cmd/controller-manager
|
||||
cmd/kubelet
|
||||
plugin/cmd/scheduler
|
||||
)
|
||||
|
||||
client_targets=(
|
||||
cmd/kubecfg
|
||||
cmd/kubectl
|
||||
cmd/e2e
|
||||
)
|
||||
|
||||
mkdir -p "${KUBE_TARGET}"
|
||||
|
||||
if [[ ! -f "/kube-build-image" ]]; then
|
||||
echo "WARNING: This script should be run in the kube-build container image!" >&2
|
||||
fi
|
||||
|
||||
if [[ -f "/kube-version-defs" ]]; then
|
||||
source "/kube-version-defs"
|
||||
else
|
||||
echo "WARNING: No version information provided in build image"
|
||||
fi
|
||||
|
||||
function kube::build::make_binary() {
|
||||
local -r gopkg=$1
|
||||
local -r bin=${gopkg##*/}
|
||||
|
||||
echo "+++ Building ${bin} for ${GOOS}/${GOARCH}"
|
||||
pushd "${KUBE_ROOT}" >/dev/null
|
||||
godep go build -ldflags "${KUBE_LD_FLAGS-}" -o "${ARCH_TARGET}/${bin}" "${gopkg}"
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
function kube::build::make_binaries() {
|
||||
[[ $# -gt 0 ]] || {
|
||||
echo "!!! Internal error. kube::build::make_binaries called with no targets."
|
||||
}
|
||||
|
||||
local -a targets=("$@")
|
||||
local -a binaries=()
|
||||
local target
|
||||
for target in "${targets[@]}"; do
|
||||
binaries+=("${KUBE_GO_PACKAGE}/${target}")
|
||||
done
|
||||
|
||||
ARCH_TARGET="${KUBE_TARGET}/${GOOS}/${GOARCH}"
|
||||
mkdir -p "${ARCH_TARGET}"
|
||||
|
||||
local b
|
||||
for b in "${binaries[@]}"; do
|
||||
kube::build::make_binary "$b"
|
||||
done
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||
source "${KUBE_ROOT}/build/build-image/common.sh"
|
||||
|
||||
platforms=(linux/amd64 $KUBE_CROSSPLATFORMS)
|
||||
targets=("${client_targets[@]}")
|
||||
|
||||
if [[ $# -gt 0 ]]; then
|
||||
targets=("$@")
|
||||
fi
|
||||
|
||||
for platform in "${platforms[@]}"; do
|
||||
(
|
||||
# Subshell to contain these exports
|
||||
export GOOS=${platform%/*}
|
||||
export GOARCH=${platform##*/}
|
||||
|
||||
kube::build::make_binaries "${targets[@]}"
|
||||
)
|
||||
done
|
@@ -1,29 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||
source "${KUBE_ROOT}/build/build-image/common.sh"
|
||||
|
||||
targets=("${server_targets[@]}")
|
||||
if [[ $# -gt 0 ]]; then
|
||||
targets=("$@")
|
||||
fi
|
||||
|
||||
kube::build::make_binaries "${targets[@]}"
|
@@ -1,38 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||
source "${KUBE_ROOT}/build/build-image/common.sh"
|
||||
|
||||
kube::build::make_binaries "./cmd/integration"
|
||||
|
||||
readonly ETCD_DIR="${KUBE_ROOT}/_output/etcd"
|
||||
mkdir -p "${ETCD_DIR}"
|
||||
|
||||
echo "+++ Running integration test"
|
||||
|
||||
etcd -name test -data-dir ${ETCD_DIR} > "${KUBE_ROOT}/_output/etcd.log" &
|
||||
readonly ETCD_PID=$!
|
||||
|
||||
sleep 5
|
||||
|
||||
"${KUBE_TARGET}/linux/amd64/integration"
|
||||
|
||||
kill $ETCD_PID
|
@@ -1,31 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||
source "${KUBE_ROOT}/build/build-image/common.sh"
|
||||
|
||||
echo "+++ Running unit tests"
|
||||
|
||||
if [[ -n "${1-}" ]]; then
|
||||
godep go test -cover -coverprofile=tmp.out "$KUBE_GO_PACKAGE/$1"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
godep go test ./...
|
Reference in New Issue
Block a user