diff --git a/.circleci/Makefile b/.circleci/Makefile new file mode 100644 index 000000000..fa45be54a --- /dev/null +++ b/.circleci/Makefile @@ -0,0 +1,20 @@ +VERSION := 0.1 +DOCKER_REGISTRY := helmpack +SHORT_NAME := ci +IMAGE := ${DOCKER_REGISTRY}/${SHORT_NAME}:${VERSION} + +.PHONY: image +image: + docker build -t "${IMAGE}" ./image + +.PHONY: push +push: + docker push "${IMAGE}" + +.PHONY: run +run: + docker run --rm -it \ + -v ${GOPATH}:${GOPATH} \ + -w ${PWD} \ + --entrypoint /bin/bash \ + "${IMAGE}" diff --git a/.circleci/bootstrap.sh b/.circleci/bootstrap.sh index 978464efe..c9d4fd6cc 100755 --- a/.circleci/bootstrap.sh +++ b/.circleci/bootstrap.sh @@ -15,5 +15,4 @@ # limitations under the License. set -euo pipefail -apt-get update -y && apt-get install -yq zip make bootstrap diff --git a/.circleci/config.yml b/.circleci/config.yml index df9786d82..e5abbc465 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ jobs: working_directory: /go/src/k8s.io/helm parallelism: 3 docker: - - image: golang:1.10 + - image: helmpack/ci:0.1 environment: PROJECT_NAME: "kubernetes-helm" steps: diff --git a/.circleci/deploy.sh b/.circleci/deploy.sh index 6ad91109d..01e477477 100755 --- a/.circleci/deploy.sh +++ b/.circleci/deploy.sh @@ -13,7 +13,7 @@ # 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 -euo pipefail +set -exuo pipefail # Skip on pull request builds if [[ -n "${CIRCLE_PR_NUMBER:-}" ]]; then @@ -33,21 +33,10 @@ else exit fi -echo "Install docker client" -VER="17.09.0-ce" -curl -L -o /tmp/docker-$VER.tgz https://download.docker.com/linux/static/stable/x86_64/docker-$VER.tgz -tar -xz -C /tmp -f /tmp/docker-$VER.tgz -mv /tmp/docker/* /usr/bin - -echo "Install gcloud components" -export CLOUDSDK_CORE_DISABLE_PROMPTS=1 -curl https://sdk.cloud.google.com | bash -${HOME}/google-cloud-sdk/bin/gcloud --quiet components update - echo "Configuring gcloud authentication" -echo "${GCLOUD_SERVICE_KEY}" | base64 --decode > "${HOME}/gcloud-service-key.json" -${HOME}/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file "${HOME}/gcloud-service-key.json" -${HOME}/google-cloud-sdk/bin/gcloud config set project "${PROJECT_NAME}" +echo "${GCLOUD_SERVICE_KEY}" | base64 --decode >"${HOME}/gcloud-service-key.json" +gcloud auth activate-service-account --key-file "${HOME}/gcloud-service-key.json" +gcloud config set project "${PROJECT_NAME}" docker login -u _json_key -p "$(cat ${HOME}/gcloud-service-key.json)" https://gcr.io echo "Building the tiller image" @@ -61,4 +50,4 @@ make build-cross make dist checksum VERSION="${VERSION}" echo "Pushing binaries to gs bucket" -${HOME}/google-cloud-sdk/bin/gsutil cp ./_dist/* "gs://${PROJECT_NAME}" +gsutil cp ./_dist/* "gs://${PROJECT_NAME}" diff --git a/.circleci/image/Dockerfile b/.circleci/image/Dockerfile new file mode 100644 index 000000000..e267f27f8 --- /dev/null +++ b/.circleci/image/Dockerfile @@ -0,0 +1,32 @@ +# Copyright 2016 The Kubernetes Authors. +# +# 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. + +FROM circleci/golang:1.10 + +USER root + +RUN apt-get update -y && \ + apt-get install -yq zip && \ + apt-get clean + +# install gcloud +ARG GCLOUD_VERSION=193.0.0 +RUN curl -Lo gcloud.tgz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${GCLOUD_VERSION}-linux-x86_64.tar.gz && \ + tar xf gcloud.tgz && \ + google-cloud-sdk/install.sh && \ + rm -rf gcloud.tgz +ENV PATH "/go/google-cloud-sdk/bin:${PATH}" + +# install go depenencies +RUN go get -u github.com/Masterminds/glide github.com/mitchellh/gox diff --git a/.circleci/test.sh b/.circleci/test.sh index e0faf9c18..d61da1146 100755 --- a/.circleci/test.sh +++ b/.circleci/test.sh @@ -16,7 +16,7 @@ # Bash 'Strict Mode' # http://redsymbol.net/articles/unofficial-bash-strict-mode -set -euo pipefail +set -exuo pipefail IFS=$'\n\t' HELM_ROOT="${BASH_SOURCE[0]%/*}/.." @@ -47,7 +47,7 @@ echo "Running 'make build'" make build case "${CIRCLE_NODE_INDEX-0}" in - 0) run_unit_test ;; + 0) run_unit_test ;; 1) run_style_check ;; - 2) run_docs_check ;; + 2) run_docs_check ;; esac diff --git a/scripts/coverage.sh b/scripts/coverage.sh index 1863d5835..2f7c799c3 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -13,33 +13,14 @@ # 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 -euo pipefail +set -exuo pipefail covermode=${COVERMODE:-atomic} -coverdir=$(mktemp -d /tmp/coverage.XXXXXXXXXX) -profile="${coverdir}/cover.out" +profile=$(mktemp /tmp/coverage.XXXX) hash goveralls 2>/dev/null || go get github.com/mattn/goveralls -hash godir 2>/dev/null || go get github.com/Masterminds/godir - -generate_cover_data() { - for d in $(godir) ; do - ( - local output="${coverdir}/${d//\//-}.cover" - go test -coverprofile="${output}" -covermode="$covermode" "$d" - ) - done - - echo "mode: $covermode" >"$profile" - grep -h -v "^mode:" "$coverdir"/*.cover >>"$profile" -} -push_to_coveralls() { - goveralls -coverprofile="${profile}" -service=circle-ci -} - -generate_cover_data +go test -coverprofile "${profile}" -covermode "$covermode" ./... go tool cover -func "${profile}" case "${1-}" in @@ -47,7 +28,6 @@ case "${1-}" in go tool cover -html "${profile}" ;; --coveralls) - push_to_coveralls + goveralls -coverprofile "${profile}" -service circle-ci ;; esac - diff --git a/scripts/update-docs.sh b/scripts/update-docs.sh index e014b537e..d492f9b07 100755 --- a/scripts/update-docs.sh +++ b/scripts/update-docs.sh @@ -13,7 +13,6 @@ # 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 -euo pipefail source scripts/util.sh @@ -46,7 +45,7 @@ ${SED} -i -e "s:${HOME}:~:" ${FILES} for i in ${FILES}; do ret=0 truepath=$(echo ${i} | ${SED} "s:${KUBE_TEMP}/::") - diff -NauprB -I 'Auto generated' "${i}" "${truepath}" > /dev/null || ret=$? + diff -NauprB -I 'Auto generated' "${i}" "${truepath}" >/dev/null || ret=$? if [[ $ret -ne 0 ]]; then echo "${truepath} changed. Updating.." cp "${i}" "${truepath}" diff --git a/scripts/util.sh b/scripts/util.sh index 09caaf972..14f832ece 100644 --- a/scripts/util.sh +++ b/scripts/util.sh @@ -13,7 +13,6 @@ # 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 -euo pipefail # Example: kube::util::trap_add 'echo "in trap DEBUG"' DEBUG @@ -28,7 +27,7 @@ kube::util::trap_add() { local new_cmd # Grab the currently defined trap commands for this trap - existing_cmd=`trap -p "${trap_add_name}" | awk -F"'" '{print $2}'` + existing_cmd=$(trap -p "${trap_add_name}" | awk -F"'" '{print $2}') if [[ -z "${existing_cmd}" ]]; then new_cmd="${trap_add_cmd}" diff --git a/scripts/validate-go.sh b/scripts/validate-go.sh index 2ecf5dfb3..e874dcd50 100755 --- a/scripts/validate-go.sh +++ b/scripts/validate-go.sh @@ -13,11 +13,11 @@ # 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 -euo pipefail +set -exuo pipefail exit_code=0 -if ! hash gometalinter.v1 2>/dev/null ; then +if ! hash gometalinter.v1 2>/dev/null; then go get -u gopkg.in/alecthomas/gometalinter.v1 gometalinter.v1 --install fi diff --git a/scripts/validate-license.sh b/scripts/validate-license.sh index fe7ec481b..695e21efb 100755 --- a/scripts/validate-license.sh +++ b/scripts/validate-license.sh @@ -13,7 +13,7 @@ # 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 -euo pipefail +set -exuo pipefail IFS=$'\n\t' find_files() { @@ -28,7 +28,7 @@ find_files() { } failed=($(find_files | xargs grep -L 'Licensed under the Apache License, Version 2.0 (the "License");')) -if (( ${#failed[@]} > 0 )); then +if ((${#failed[@]} > 0)); then echo "Some source files are missing license headers." for f in "${failed[@]}"; do echo " $f" diff --git a/scripts/verify-docs.sh b/scripts/verify-docs.sh index b0b799eac..a1398f527 100755 --- a/scripts/verify-docs.sh +++ b/scripts/verify-docs.sh @@ -13,8 +13,7 @@ # 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 -euo pipefail +set -exuo pipefail source scripts/util.sh @@ -39,7 +38,6 @@ mkdir -p ${KUBE_TEMP}/docs/helm bin/helm docs --dir ${KUBE_TEMP}/docs/helm HELM_HOME=$OLD_HELM_HOME - FILES=$(find ${KUBE_TEMP} -type f) ${SED} -i -e "s:${HOME}:~:" ${FILES}