diff --git a/Gopkg.lock b/Gopkg.lock index b37a1dd37..e7254cb1a 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -456,14 +456,14 @@ [[projects]] branch = "master" - digest = "1:68050b4ce26531655bac0f6e109d04eb0a4550ead73e320119ed3c628ced4a0a" + digest = "1:5299d75a2b08a91c54ffb8b76afe21eb5f1ecf7bc4d67b859fc081f9415452bc" name = "knative.dev/test-infra" packages = [ "scripts", "tools/dep-collector", ] pruneopts = "UT" - revision = "17f2331e80ad0d3e170ea2bae45c3922744f83af" + revision = "89cde81f6a2bba89d07b85fec67086cafac6ce26" [solve-meta] analyzer-name = "dep" diff --git a/test/presubmit-link-check.sh b/test/presubmit-link-check.sh new file mode 100755 index 000000000..e71f04732 --- /dev/null +++ b/test/presubmit-link-check.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Copyright 2019 The Knative 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 runs the presubmit tests, in the right order. +# It is started by prow for each PR. +# For convenience, it can also be executed manually. + +source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/presubmit-tests.sh + +initialize_environment +if (( IS_PRESUBMIT_EXEMPT_PR )) || (( ! IS_DOCUMENTATION_PR )); then + header "Commit only contains changes that don't require link checks, skipping" + exit 0 +fi + +# Force presubmit link checking only. +export DISABLE_MD_LINTING=1 +$(dirname $0)/presubmit-tests.sh --build-tests diff --git a/test/presubmit-tests.sh b/test/presubmit-tests.sh index b68a57058..87fc3b239 100755 --- a/test/presubmit-tests.sh +++ b/test/presubmit-tests.sh @@ -29,4 +29,4 @@ source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/presubmit-tests.sh # TODO(#67): Add more build tests. # TODO(#66): Add more unit tests. -main $@ +main "$@" diff --git a/vendor/knative.dev/test-infra/scripts/README.md b/vendor/knative.dev/test-infra/scripts/README.md index 549a540ca..b3d8d9515 100644 --- a/vendor/knative.dev/test-infra/scripts/README.md +++ b/vendor/knative.dev/test-infra/scripts/README.md @@ -61,7 +61,7 @@ This is a helper script to run the presubmit tests. To use it: the integration tests (either your custom one or the default action) and will cause the test to fail if they don't return success. -1. Call the `main()` function passing `$@` (without quotes). +1. Call the `main()` function passing `"$@"` (with quotes). Running the script without parameters, or with the `--all-tests` flag causes all tests to be executed, in the right order (i.e., build, then unit, then @@ -72,6 +72,11 @@ specific set of tests. The flag `--emit-metrics` is used to emit metrics when running the tests, and is automatically handled by the default action for integration tests (see above). +To run a specific program as a test, use the `--run-test` flag, and provide the +program as the argument. If arguments are required for the program, pass +everything as a single quotes argument. For example, +`./presubmit-tests.sh --run-test "test/my/test data"`. + The script will automatically skip all presubmit tests for PRs where all changed files are exempt of tests (e.g., a PR changing only the `OWNERS` file). @@ -99,7 +104,7 @@ function pre_integration_tests() { # We use the default integration test runner. -main $@ +main "$@" ``` ## Using the `e2e-tests.sh` helper script @@ -224,6 +229,64 @@ kubectl get pods || fail_test success ``` +## Using the `performance-tests.sh` helper script + +This is a helper script for Knative performance test scripts. In combination +with specific Prow jobs, it can automatically manage the environment for running +benchmarking jobs for each repo. To use it: + +1. Source the script. + +1. [optional] Customize GCP project settings for the benchmarks. Set the + following environment variables if the default value doesn't fit your needs: + + - `PROJECT_NAME`: GCP project name for keeping the clusters that run the + benchmarks. Defaults to `knative-performance`. + - `SERVICE_ACCOUNT_NAME`: Service account name for controlling GKE clusters + and interacting with [Mako](https://github.com/google/mako) server. It MUST + have `Kubernetes Engine Admin` and `Storage Admin` role, and be + [whitelisted](https://github.com/google/mako/blob/master/docs/ACCESS.md) by + Mako admin. Defaults to `mako-job`. + +1. [optional] Customize root path of the benchmarks. This root folder should + contain and only contain all benchmarks you want to run continuously. Set the + following environment variable if the default value doesn't fit your needs: + + - `BENCHMARK_ROOT_PATH`: Benchmark root path, defaults to + `test/performance/benchmarks`. Each repo can decide which folder to put its + benchmarks in, and override this environment variable to be the path of + that folder. + +1. [optional] Write the `update_knative` function, which will update your system + under test (e.g. Knative Serving). + +1. [optional] Write the `update_benchmark` function, which will update the + underlying resources for the benchmark (usually Knative resources and + Kubernetes cronjobs for benchmarking). This function accepts a parameter, + which is the benchmark name in the current repo. + +1. Call the `main()` function with all parameters (e.g. `$@`). + +### Sample performance test script + +This script will update `Knative serving` and the given benchmark. + +```bash +source vendor/knative.dev/test-infra/scripts/performance-tests.sh + +function update_knative() { + echo ">> Updating serving" + ko apply -f config/ || abort "failed to apply serving" +} + +function update_benchmark() { + echo ">> Updating benchmark $1" + ko apply -f ${BENCHMARK_ROOT_PATH}/$1 || abort "failed to apply benchmark $1" +} + +main $@ +``` + ## Using the `release.sh` helper script This is a helper script for Knative release scripts. To use it: diff --git a/vendor/knative.dev/test-infra/scripts/e2e-tests.sh b/vendor/knative.dev/test-infra/scripts/e2e-tests.sh index 5483547c4..131ca54dc 100755 --- a/vendor/knative.dev/test-infra/scripts/e2e-tests.sh +++ b/vendor/knative.dev/test-infra/scripts/e2e-tests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2019 The Knative Authors # @@ -93,13 +93,32 @@ function dump_cluster_state() { echo "*** E2E TEST FAILED ***" echo "*** Start of information dump ***" echo "***************************************" - echo ">>> All resources:" - kubectl get all --all-namespaces - echo ">>> Services:" - kubectl get services --all-namespaces - echo ">>> Events:" - kubectl get events --all-namespaces - function_exists dump_extra_cluster_state && dump_extra_cluster_state + + local output="${ARTIFACTS}/k8s.dump.txt" + echo ">>> The dump is located at ${output}" + + for crd in $(kubectl api-resources --verbs=list -o name | sort); do + local count="$(kubectl get $crd --all-namespaces --no-headers 2>/dev/null | wc -l)" + echo ">>> ${crd} (${count} objects)" + if [[ "${count}" > "0" ]]; then + echo ">>> ${crd} (${count} objects)" >> ${output} + + echo ">>> Listing" >> ${output} + kubectl get ${crd} --all-namespaces >> ${output} + + echo ">>> Details" >> ${output} + if [[ "${crd}" == "secrets" ]]; then + echo "Secrets are ignored for security reasons" >> ${output} + else + kubectl get ${crd} --all-namespaces -o yaml >> ${output} + fi + fi + done + + if function_exists dump_extra_cluster_state; then + echo ">>> Extra dump" >> ${output} + dump_extra_cluster_state >> ${output} + fi echo "***************************************" echo "*** E2E TEST FAILED ***" echo "*** End of information dump ***" @@ -226,7 +245,7 @@ function create_test_cluster() { local test_wrapper="${kubedir}/e2e-test.sh" mkdir ${kubedir}/cluster ln -s "$(which kubectl)" ${kubedir}/cluster/kubectl.sh - echo "#!/bin/bash" > ${test_wrapper} + echo "#!/usr/bin/env bash" > ${test_wrapper} echo "cd $(pwd) && set -x" >> ${test_wrapper} echo "${E2E_SCRIPT} ${test_cmd_args}" >> ${test_wrapper} chmod +x ${test_wrapper} @@ -292,6 +311,7 @@ function create_test_cluster_with_retries() { [[ -z "$(grep -Fo 'does not have enough resources available to fulfill' ${cluster_creation_log})" \ && -z "$(grep -Fo 'ResponseError: code=400, message=No valid versions with the prefix' ${cluster_creation_log})" \ && -z "$(grep -Po 'ResponseError: code=400, message=Master version "[0-9a-z\-\.]+" is unsupported' ${cluster_creation_log})" ]] \ + && -z "$(grep -Po 'only \d+ nodes out of \d+ have registered; this is likely due to Nodes failing to start correctly' ${cluster_creation_log})" ]] \ && return 1 done done @@ -310,7 +330,8 @@ function setup_test_cluster() { # Set the actual project the test cluster resides in # It will be a project assigned by Boskos if test is running on Prow, # otherwise will be ${GCP_PROJECT} set up by user. - readonly export E2E_PROJECT_ID="$(gcloud config get-value project)" + export E2E_PROJECT_ID="$(gcloud config get-value project)" + readonly E2E_PROJECT_ID # Save some metadata about cluster creation for using in prow and testgrid save_metadata @@ -322,10 +343,9 @@ function setup_test_cluster() { abort "kubeconfig context set to ${k8s_cluster}, which is forbidden" # If cluster admin role isn't set, this is a brand new cluster - # Setup the admin role and also KO_DOCKER_REPO - if [[ -z "$(kubectl get clusterrolebinding cluster-admin-binding 2> /dev/null)" ]]; then + # Setup the admin role and also KO_DOCKER_REPO if it is a GKE cluster + if [[ -z "$(kubectl get clusterrolebinding cluster-admin-binding 2> /dev/null)" && "${k8s_cluster}" =~ ^gke_.* ]]; then acquire_cluster_admin_role ${k8s_user} ${E2E_CLUSTER_NAME} ${E2E_CLUSTER_REGION} ${E2E_CLUSTER_ZONE} - kubectl config set-context ${k8s_cluster} --namespace=default # Incorporate an element of randomness to ensure that each run properly publishes images. export KO_DOCKER_REPO=gcr.io/${E2E_PROJECT_ID}/${E2E_BASE_NAME}-e2e-img/${RANDOM} fi @@ -334,9 +354,12 @@ function setup_test_cluster() { is_protected_gcr ${KO_DOCKER_REPO} && \ abort "\$KO_DOCKER_REPO set to ${KO_DOCKER_REPO}, which is forbidden" - echo "- Project is ${E2E_PROJECT_ID}" + # Use default namespace for all subsequent kubectl commands in this context + kubectl config set-context ${k8s_cluster} --namespace=default + + echo "- gcloud project is ${E2E_PROJECT_ID}" + echo "- gcloud user is ${k8s_user}" echo "- Cluster is ${k8s_cluster}" - echo "- User is ${k8s_user}" echo "- Docker is ${KO_DOCKER_REPO}" export KO_DATA_PATH="${REPO_ROOT_DIR}/.git" diff --git a/vendor/knative.dev/test-infra/scripts/library.sh b/vendor/knative.dev/test-infra/scripts/library.sh index 9570831e6..cf7874c27 100755 --- a/vendor/knative.dev/test-infra/scripts/library.sh +++ b/vendor/knative.dev/test-infra/scripts/library.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2018 The Knative Authors # @@ -283,9 +283,9 @@ function acquire_cluster_admin_role() { local key=$(mktemp) echo "Certificate in ${cert}, key in ${key}" gcloud --format="value(masterAuth.clientCertificate)" \ - container clusters describe $2 ${geoflag} | base64 -d > ${cert} + container clusters describe $2 ${geoflag} | base64 --decode > ${cert} gcloud --format="value(masterAuth.clientKey)" \ - container clusters describe $2 ${geoflag} | base64 -d > ${key} + container clusters describe $2 ${geoflag} | base64 --decode > ${key} kubectl config set-credentials cluster-admin \ --client-certificate=${cert} --client-key=${key} fi @@ -311,12 +311,26 @@ function capture_output() { return ${failed} } +# Create a temporary file with the given extension in a way that works on both Linux and macOS. +# Parameters: $1 - file name without extension (e.g. 'myfile_XXXX') +# $2 - file extension (e.g. 'xml') +function mktemp_with_extension() { + local nameprefix + local fullname + + nameprefix="$(mktemp $1)" + fullname="${nameprefix}.$2" + mv ${nameprefix} ${fullname} + + echo ${fullname} +} + # Create a JUnit XML for a test. # Parameters: $1 - check class name as an identifier (e.g. BuildTests) # $2 - check name as an identifier (e.g., GoBuild) # $3 - failure message (can contain newlines), optional (means success) function create_junit_xml() { - local xml="$(mktemp ${ARTIFACTS}/junit_XXXXXXXX.xml)" + local xml="$(mktemp_with_extension ${ARTIFACTS}/junit_XXXXXXXX xml)" local failure="" if [[ "$3" != "" ]]; then # Transform newlines into HTML code. @@ -352,7 +366,7 @@ function report_go_test() { echo "Finished run, return code is ${failed}" # Install go-junit-report if necessary. run_go_tool github.com/jstemmer/go-junit-report go-junit-report --help > /dev/null 2>&1 - local xml=$(mktemp ${ARTIFACTS}/junit_XXXXXXXX.xml) + local xml="$(mktemp_with_extension ${ARTIFACTS}/junit_XXXXXXXX xml)" cat ${report} \ | go-junit-report \ | sed -e "s#\"\(github\.com/knative\|knative\.dev\)/${REPO_NAME}/#\"#g" \ @@ -529,19 +543,24 @@ function get_canonical_path() { echo "$(cd ${path%/*} && echo $PWD/${path##*/})" } -# Returns the URL to the latest manifest for the given Knative project. -# Parameters: $1 - repository name of the given project -# $2 - name of the yaml file, without extension -function get_latest_knative_yaml_source() { +# Returns whether the current branch is a release branch. +function is_release_branch() { local branch_name="" - local repo_name="$1" - local yaml_name="$2" # Get the branch name from Prow's env var, see https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md. # Otherwise, try getting the current branch from git. (( IS_PROW )) && branch_name="${PULL_BASE_REF:-}" [[ -z "${branch_name}" ]] && branch_name="$(git rev-parse --abbrev-ref HEAD)" + [[ ${branch_name} =~ ^release-[0-9\.]+$ ]] +} + +# Returns the URL to the latest manifest for the given Knative project. +# Parameters: $1 - repository name of the given project +# $2 - name of the yaml file, without extension +function get_latest_knative_yaml_source() { + local repo_name="$1" + local yaml_name="$2" # If it's a release branch, the yaml source URL should point to a specific version. - if [[ ${branch_name} =~ ^release-[0-9\.]+$ ]]; then + if is_release_branch; then # Get the latest tag name for the current branch, which is likely formatted as v0.5.0 local tag_name="$(git describe --tags --abbrev=0)" # The given repo might not have this tag, so we need to find its latest release manifest with the same major&minor version. @@ -565,5 +584,5 @@ readonly REPO_NAME_FORMATTED="Knative $(capitalize ${REPO_NAME//-/ })" # Public latest nightly or release yaml files. readonly KNATIVE_SERVING_RELEASE="$(get_latest_knative_yaml_source "serving" "serving")" -readonly KNATIVE_BUILD_RELEASE="$(get_latest_knative_yaml_source "build" "build")" readonly KNATIVE_EVENTING_RELEASE="$(get_latest_knative_yaml_source "eventing" "release")" +readonly KNATIVE_MONITORING_RELEASE="$(get_latest_knative_yaml_source "serving" "monitoring")" diff --git a/vendor/knative.dev/test-infra/scripts/performance-tests.sh b/vendor/knative.dev/test-infra/scripts/performance-tests.sh new file mode 100755 index 000000000..551587676 --- /dev/null +++ b/vendor/knative.dev/test-infra/scripts/performance-tests.sh @@ -0,0 +1,150 @@ +#!/bin/bash + +# Copyright 2019 The Knative 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 is a helper script for Knative performance test scripts. +# See README.md for instructions on how to use it. + +source $(dirname ${BASH_SOURCE})/library.sh + +# Configurable parameters. +# If not provided, they will fall back to the default values. +readonly BENCHMARK_ROOT_PATH=${BENCHMARK_ROOT_PATH:-test/performance/benchmarks} +readonly PROJECT_NAME=${PROJECT_NAME:-knative-performance} +readonly SERVICE_ACCOUNT_NAME=${SERVICE_ACCOUNT_NAME:-mako-job@knative-performance.iam.gserviceaccount.com} + +# Setup env vars. +export KO_DOCKER_REPO="gcr.io/${PROJECT_NAME}" +# Constants +readonly GOOGLE_APPLICATION_CREDENTIALS="/etc/performance-test/service-account.json" +readonly GITHUB_TOKEN="/etc/performance-test/github-token" +readonly SLACK_READ_TOKEN="/etc/performance-test/slack-read-token" +readonly SLACK_WRITE_TOKEN="/etc/performance-test/slack-write-token" + +# Set up the user for cluster operations. +function setup_user() { + echo ">> Setting up user" + echo "Using gcloud user ${SERVICE_ACCOUNT_NAME}" + gcloud config set core/account ${SERVICE_ACCOUNT_NAME} + echo "Using gcloud project ${PROJECT_NAME}" + gcloud config set core/project ${PROJECT_NAME} +} + +# Update resources installed on the cluster. +# Parameters: $1 - cluster name +# $2 - cluster region/zone +function update_cluster() { + # --zone option can work with both region and zone, (e.g. us-central1 and + # us-central1-a), so we don't need to add extra check here. + gcloud container clusters get-credentials $1 --zone=$2 --project=${PROJECT_NAME} || abort "failed to get cluster creds" + # Set up the configmap to run benchmarks in production + echo ">> Setting up 'prod' config-mako on cluster $1 in zone $2" + cat <> Creating secrets on cluster $1 in zone $2" + kubectl create secret generic mako-secrets \ + --from-file=robot.json=${GOOGLE_APPLICATION_CREDENTIALS} \ + --from-file=github-token=${GITHUB_TOKEN} \ + --from-file=slack-read-token=${SLACK_READ_TOKEN} \ + --from-file=slack-write-token=${SLACK_WRITE_TOKEN} + # Delete all benchmark jobs to avoid noise in the update process + echo ">> Deleting all cronjobs and jobs on cluster $1 in zone $2" + kubectl delete cronjob --all + kubectl delete job --all + + if function_exists update_knative; then + update_knative || abort "failed to update knative" + fi + # get benchmark name from the cluster name + local benchmark_name=$(get_benchmark_name $1) + if function_exists update_benchmark; then + update_benchmark ${benchmark_name} || abort "failed to update benchmark" + fi +} + +# Get benchmark name from the cluster name. +# Parameters: $1 - cluster name +function get_benchmark_name() { + # get benchmark_name by removing the prefix from cluster name, e.g. get "load-test" from "serving--load-test" + echo ${1#$REPO_NAME"--"} +} + +# Update the clusters related to the current repo. +function update_clusters() { + header "Updating all clusters for ${REPO_NAME}" + local all_clusters=$(gcloud container clusters list --project="${PROJECT_NAME}" --format="csv[no-heading](name,zone)") + echo ">> Project contains clusters:" ${all_clusters} + for cluster in ${all_clusters}; do + local name=$(echo "${cluster}" | cut -f1 -d",") + # the cluster name is prefixed with "${REPO_NAME}--", here we should only handle clusters belonged to the current repo + [[ ! ${name} =~ ^${REPO_NAME}-- ]] && continue + local zone=$(echo "${cluster}" | cut -f2 -d",") + + # Update all resources installed on the cluster + update_cluster ${name} ${zone} + done + header "Done updating all clusters" +} + +# Delete the old clusters belonged to the current repo, and recreate them with the same configuration. +function recreate_clusters() { + header "Recreating clusters for ${REPO_NAME}" + go run ${REPO_ROOT_DIR}/vendor/knative.dev/pkg/testutils/clustermanager/perf-tests \ + --recreate \ + --gcp-project=${PROJECT_NAME} --repository=${REPO_NAME} --benchmark-root=${BENCHMARK_ROOT_PATH} + header "Done recreating clusters" + # Update all clusters after they are recreated + update_clusters +} + +# Try to reconcile clusters for benchmarks in the current repo. +# This function will be run as postsubmit jobs. +function reconcile_benchmark_clusters() { + header "Reconciling clusters for ${REPO_NAME}" + go run ${REPO_ROOT_DIR}/vendor/knative.dev/pkg/testutils/clustermanager/perf-tests \ + --reconcile \ + --gcp-project=${PROJECT_NAME} --repository=${REPO_NAME} --benchmark-root=${BENCHMARK_ROOT_PATH} + header "Done reconciling clusters" + # For now, do nothing after reconciling the clusters, and the next update_clusters job will automatically + # update them. So there will be a period that the newly created clusters are being idle, and the duration + # can be as long as . +} + +# Parse flags and excute the command. +function main() { + if (( ! IS_PROW )); then + abort "this script should only be run by Prow since it needs secrets created on Prow cluster" + fi + + # Set up the user credential for cluster operations + setup_user || abort "failed to set up user" + + # Try parsing the first flag as a command. + case $1 in + --recreate-clusters) recreate_clusters ;; + --update-clusters) update_clusters ;; + --reconcile-benchmark-clusters) reconcile_benchmark_clusters ;; + *) abort "unknown command $1, must be --recreate-clusters, --update-clusters or --reconcile_benchmark_clusters" + esac + shift +} diff --git a/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh b/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh index e0cf9d199..0f95529ba 100755 --- a/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh +++ b/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2018 The Knative Authors # @@ -49,7 +49,7 @@ function pr_only_contains() { # List changed files in the current PR. # This is implemented as a function so it can be mocked in unit tests. function list_changed_files() { - /workspace/githubhelper -list-changed-files + /workspace/githubhelper -list-changed-files -github-token /etc/repoview-token/token } # Initialize flags and context for presubmit tests: @@ -172,14 +172,19 @@ function default_build_test_runner() { # Get all build tags in go code (ignore /vendor) local tags="$(grep -r '// +build' . \ | grep -v '^./vendor/' | cut -f3 -d' ' | sort | uniq | tr '\n' ' ')" - if [[ -n "${tags}" ]]; then - errors="" - if ! capture_output "${report}" go test -run=^$ -tags="${tags}" ./... ; then + local tagged_pkgs="$(grep -r '// +build' . \ + | grep -v '^./vendor/' | grep ":// +build " | cut -f1 -d: | xargs dirname | sort | uniq | tr '\n' ' ')" + for pkg in ${tagged_pkgs}; do + # `go test -c` lets us compile the tests but do not run them. + if ! capture_output "${report}" go test -c -tags="${tags}" ${pkg} ; then failed=1 # Consider an error message everything that's not a successful test result. - errors_go2="$(grep -v '^\(ok\|\?\)\s\+\(github\.com\|knative\.dev\)/' "${report}")" + errors_go2+="$(grep -v '^\(ok\|\?\)\s\+\(github\.com\|knative\.dev\)/' "${report}")" fi - fi + # Remove unused generated binary, if any. + rm -f e2e.test + done + local errors_go="$(echo -e "${errors_go1}\n${errors_go2}" | uniq)" create_junit_xml _build_tests Build_Go "${errors_go}" if [[ -f ./hack/verify-codegen.sh ]]; then @@ -299,7 +304,7 @@ function main() { go version echo ">> git version" git version - echo ">> ko built from commit" + echo ">> ko version" [[ -f /ko_version ]] && cat /ko_version || echo "unknown" echo ">> bazel version" [[ -f /bazel_version ]] && cat /bazel_version || echo "unknown" @@ -337,7 +342,7 @@ function main() { --run-test) shift [[ $# -ge 1 ]] || abort "missing executable after --run-test" - TEST_TO_RUN=$1 + TEST_TO_RUN="$1" ;; *) abort "error: unknown option ${parameter}" ;; esac diff --git a/vendor/knative.dev/test-infra/scripts/release.sh b/vendor/knative.dev/test-infra/scripts/release.sh index 20aa8fa33..6c5a8c384 100755 --- a/vendor/knative.dev/test-infra/scripts/release.sh +++ b/vendor/knative.dev/test-infra/scripts/release.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Copyright 2018 The Knative Authors # @@ -165,8 +165,8 @@ function prepare_auto_release() { PUBLISH_RELEASE=1 git fetch --all || abort "error fetching branches/tags from remote" - local tags="$(git tag | cut -d 'v' -f2 | cut -d '.' -f1-2 | sort | uniq)" - local branches="$( { (git branch -r | grep upstream/release-) ; (git branch | grep release-); } | cut -d '-' -f2 | sort | uniq)" + local tags="$(git tag | cut -d 'v' -f2 | cut -d '.' -f1-2 | sort -V | uniq)" + local branches="$( { (git branch -r | grep upstream/release-) ; (git branch | grep release-); } | cut -d '-' -f2 | sort -V | uniq)" echo "Versions released (from tags): [" ${tags} "]" echo "Versions released (from branches): [" ${branches} "]" @@ -485,7 +485,9 @@ function main() { parse_flags $@ # Log what will be done and where. banner "Release configuration" - echo "- gcloud user: $(gcloud config get-value core/account)" + if which gcloud &>/dev/null ; then + echo "- gcloud user: $(gcloud config get-value core/account)" + fi echo "- Go path: ${GOPATH}" echo "- Repository root: ${REPO_ROOT_DIR}" echo "- Destination GCR: ${KO_DOCKER_REPO}"