diff --git a/.golangci.yml b/.golangci.yml index c648c2cb478..d80586400ff 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,4 +14,3 @@ linters: - goimports - gosec - gocritic - - unparam diff --git a/Gopkg.lock b/Gopkg.lock index 55de2e039d2..0a200abcae3 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -590,11 +590,11 @@ [[projects]] branch = "master" - digest = "1:52353264b6df3bd5c5da47f84904456a0c81f7f59d224b4da9675d0dc78bbf3e" + digest = "1:e2155887812e57c490cb743ec4d388681253f69965fd1203d9bbc75c9e512b6d" name = "github.com/tektoncd/plumbing" packages = ["scripts"] pruneopts = "UT" - revision = "933f0722e02cf10a891027381ba8a01ac4c8530e" + revision = "ea00721be13d2549caf5550db5de50b9902f1075" [[projects]] digest = "1:b7d98c64e9467a8e5e67509031cd6baee81fba090ba2c3d30df1ff3d02d1d035" @@ -1294,6 +1294,7 @@ "logging/testing", "metrics", "metrics/metricskey", + "metrics/metricstest", "profiling", "reconciler/testing", "signals", @@ -1348,6 +1349,7 @@ "github.com/knative/test-infra/tools/dep-collector", "github.com/mitchellh/go-homedir", "github.com/mohae/deepcopy", + "github.com/pkg/errors", "github.com/tektoncd/plumbing/scripts", "go.opencensus.io/stats", "go.opencensus.io/stats/view", @@ -1364,7 +1366,6 @@ "k8s.io/apimachinery/pkg/api/errors", "k8s.io/apimachinery/pkg/api/resource", "k8s.io/apimachinery/pkg/apis/meta/v1", - "k8s.io/apimachinery/pkg/fields", "k8s.io/apimachinery/pkg/labels", "k8s.io/apimachinery/pkg/runtime", "k8s.io/apimachinery/pkg/runtime/schema", @@ -1415,6 +1416,7 @@ "knative.dev/pkg/logging/logkey", "knative.dev/pkg/logging/testing", "knative.dev/pkg/metrics", + "knative.dev/pkg/metrics/metricstest", "knative.dev/pkg/reconciler/testing", "knative.dev/pkg/signals", "knative.dev/pkg/test", diff --git a/cmd/bash/main.go b/cmd/bash/main.go index 7471e798177..d986ddb91ca 100644 --- a/cmd/bash/main.go +++ b/cmd/bash/main.go @@ -55,6 +55,7 @@ var ( args = flag.String("args", "", "space separated arguments for shell") ) +// nolint: gosec func main() { flag.Parse() logger, _ := logging.NewLogger("", "shell_command") diff --git a/vendor/github.com/tektoncd/plumbing/pipelinerun-logs/cmd/http/kodata/templates b/vendor/github.com/tektoncd/plumbing/pipelinerun-logs/cmd/http/kodata/templates new file mode 120000 index 00000000000..0e4c94ff6fb --- /dev/null +++ b/vendor/github.com/tektoncd/plumbing/pipelinerun-logs/cmd/http/kodata/templates @@ -0,0 +1 @@ +../../../templates \ No newline at end of file diff --git a/vendor/github.com/tektoncd/plumbing/scripts/library.sh b/vendor/github.com/tektoncd/plumbing/scripts/library.sh index 1d216fe6739..bff86025641 100755 --- a/vendor/github.com/tektoncd/plumbing/scripts/library.sh +++ b/vendor/github.com/tektoncd/plumbing/scripts/library.sh @@ -33,8 +33,8 @@ fi # Useful environment variables [[ -n "${PROW_JOB_ID:-}" ]] && IS_PROW=1 || IS_PROW=0 readonly IS_PROW -readonly REPO_ROOT_DIR="$(git rev-parse --show-toplevel)" -readonly REPO_NAME="$(basename ${REPO_ROOT_DIR})" +readonly REPO_ROOT_DIR="${REPO_ROOT_DIR:-$(git rev-parse --show-toplevel 2> /dev/null)}" +readonly REPO_NAME="${REPO_NAME:-$(basename ${REPO_ROOT_DIR} 2> /dev/null)}" # Set ARTIFACTS to an empty temp dir if unset if [[ -z "${ARTIFACTS:-}" ]]; then @@ -438,3 +438,96 @@ function get_canonical_path() { readonly _PLUMBING_SCRIPTS_DIR="$(dirname $(get_canonical_path ${BASH_SOURCE[0]}))" readonly REPO_NAME_FORMATTED="Tekton $(capitalize ${REPO_NAME//-/})" + +# Helper functions to run YAML tests +# Taken from tektoncd/pipeline test/e2e-common.sh +function validate_run() { + local tests_finished=0 + for i in {1..60}; do + local finished="$(kubectl get $1.tekton.dev --output=jsonpath='{.items[*].status.conditions[*].status}')" + if [[ ! "$finished" == *"Unknown"* ]]; then + tests_finished=1 + break + fi + sleep 10 + done + + return ${tests_finished} +} + +function check_results() { + local failed=0 + results="$(kubectl get $1.tekton.dev --output=jsonpath='{range .items[*]}{.metadata.name}={.status.conditions[*].type}{.status.conditions[*].status}{" "}{end}')" + for result in ${results}; do + if [[ ! "${result,,}" == *"=succeededtrue" ]]; then + echo "ERROR: test ${result} but should be succeededtrue" + failed=1 + fi + done + + return ${failed} +} + +function create_resources() { + local resource=$1 + echo ">> Creating resources ${resource}" + + # Applying the resources, either *taskruns or * *pipelineruns + for file in $(find ${REPO_ROOT_DIR}/examples/${resource}s/ -name *.yaml | sort); do + perl -p -e 's/gcr.io\/christiewilson-catfactory/$ENV{KO_DOCKER_REPO}/g' ${file} | ko apply -f - || return 1 + done +} + +function run_tests() { + local resource=$1 + + # Wait for tests to finish. + echo ">> Waiting for tests to finish for ${resource}" + if validate_run $resource; then + echo "ERROR: tests timed out" + fi + + # Check that tests passed. + echo ">> Checking test results for ${resource}" + if check_results $resource; then + echo ">> All YAML tests passed" + return 0 + fi + return 1 +} + +function run_yaml_tests() { + echo ">> Starting tests for the resource ${1}" + create_resources ${1} + if ! run_tests ${1}; then + return 1 + fi + return 0 +} + +function output_yaml_test_results() { + # If formatting fails for any reason, use yaml as a fall back. + kubectl get $1.tekton.dev -o=custom-columns-file=${REPO_ROOT_DIR}/test/columns.txt || \ + kubectl get $1.tekton.dev -oyaml +} + +function output_pods_logs() { + echo ">>> $1" + kubectl get $1.tekton.dev -o yaml + local runs=$(kubectl get $1.tekton.dev --output=jsonpath="{.items[*].metadata.name}") + set +e + for run in ${runs}; do + echo ">>>> $1 ${run}" + case "$1" in + "taskrun") + tkn taskrun logs ${run} + ;; + "pipelinerun") + tkn pipelinerun logs ${run} + ;; + esac + done + set -e + echo ">>>> Pods" + kubectl get pods -o yaml +} diff --git a/vendor/github.com/tektoncd/plumbing/scripts/presubmit-tests.sh b/vendor/github.com/tektoncd/plumbing/scripts/presubmit-tests.sh index 742240b8b13..df3209b8b25 100755 --- a/vendor/github.com/tektoncd/plumbing/scripts/presubmit-tests.sh +++ b/vendor/github.com/tektoncd/plumbing/scripts/presubmit-tests.sh @@ -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 + githubhelper -list-changed-files } # Initialize flags and context for presubmit tests: