From 7c1d891d814aed89c7100455984f300cf6b34678 Mon Sep 17 00:00:00 2001 From: Zhen Wang Date: Thu, 7 Feb 2019 17:07:37 -0800 Subject: [PATCH] Add script for presubmit and CI jobs --- .gitignore | 2 + test/build.sh | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100755 test/build.sh diff --git a/.gitignore b/.gitignore index 996592ea..3524906a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /bin/ /Dockerfile /*.tar.gz +ci.env +pr.env diff --git a/test/build.sh b/test/build.sh new file mode 100755 index 00000000..7a42261f --- /dev/null +++ b/test/build.sh @@ -0,0 +1,118 @@ +#!/bin/bash + +# Copyright 2019 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. + +# This script build node problem detector for presubmit and CI jobs and push to +# staging, so that kubernetes E2E tests have access to the build. + +set -o errexit +set -o nounset +set -o pipefail + + +NPD_STAGING_PATH=${NPD_STAGING_PATH:-"gs://node-problem-detector-staging"} +NPD_STAGING_REGISTRY=${NPD_STAGING_REGISTRY:-"gcr.io/node-problem-detector-staging"} +PR_ENV_FILENAME=${PR_ENV_FILENAME:-"pr.env"} +CI_ENV_FILENAME=${CI_ENV_FILENAME:-"ci.env"} +ROOT_PATH=$(git rev-parse --show-toplevel) + +function print-help() { + echo "Usage: build.sh [args...]" + echo "Available arguments:" + echo " pr [pull_refs]: Build node-problem-detector for presubmit jobs and push to staging." + echo " ci: Build node-problem-detector for CI jobs and push to staging." + echo " get-ci-env: Download environment variable file from staging for CI job." +} + +function get-version() { + if [ -d .git ]; then + echo `git describe --tags --dirty` + else + echo "UNKNOWN" + fi +} + +function write-env-file() { + local -r env_file="${1}" + if [[ -z "${env_file}" ]]; then + echo "ERROR: env_file is missing." + exit 1 + fi + + cat > ${ROOT_PATH}/${env_file} <