diff --git a/prow/cluster/jobs/istio/enhancements/istio.enhancements.master.gen.yaml b/prow/cluster/jobs/istio/enhancements/istio.enhancements.master.gen.yaml new file mode 100644 index 00000000000..ec2dae7bfd3 --- /dev/null +++ b/prow/cluster/jobs/istio/enhancements/istio.enhancements.master.gen.yaml @@ -0,0 +1,48 @@ +# THIS FILE IS AUTOGENERATED. See prow/config/README.md +presubmits: + istio/enhancements: + - always_run: true + annotations: + testgrid-dashboards: istio_enhancements + branches: + - ^master$ + decorate: true + extra_refs: + - base_ref: master + org: istio + path_alias: istio.io/test-infra + repo: test-infra + - base_ref: master + org: istio + path_alias: istio.io/tools + repo: tools + name: validate-features_enhancements + path_alias: istio.io/enhancements + spec: + containers: + - command: + - ../test-infra/scripts/validate_schema.sh + - --document-path ./features.yaml + - --schema-path ./features_schema.yaml + image: gcr.io/istio-testing/build-tools:master-2021-05-07T04-05-01 + name: "" + resources: + limits: + cpu: "3" + memory: 24Gi + requests: + cpu: "1" + memory: 3Gi + securityContext: + privileged: true + volumeMounts: + - mountPath: /home/prow/go/pkg + name: build-cache + subPath: gomod + nodeSelector: + testing: test-pool + volumes: + - hostPath: + path: /tmp/prow/cache + type: DirectoryOrCreate + name: build-cache diff --git a/prow/config/jobs/enhancements.yaml b/prow/config/jobs/enhancements.yaml new file mode 100644 index 00000000000..503ac805f72 --- /dev/null +++ b/prow/config/jobs/enhancements.yaml @@ -0,0 +1,14 @@ +org: istio +repo: enhancements +branches: [master] +support_release_branching: true +image: gcr.io/istio-testing/build-tools:master-2021-05-07T04-05-01 +jobs: +- name: validate-features + types: [presubmit] + optional: true + command: + - ../test-infra/scripts/validate_schema.sh + - --document-path ./features.yaml + - --schema-path ./features_schema.yaml + repos: [istio/test-infra@master,istio/tools@master] diff --git a/scripts/validate_schema.sh b/scripts/validate_schema.sh new file mode 100755 index 00000000000..dbe02628335 --- /dev/null +++ b/scripts/validate_schema.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash + +# Copyright Istio 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. +set -e + +print_error() { + local last_return="$?" + + { + echo + echo "${1:-unknown error}" + echo + } >&2 + + return "${2:-$last_return}" +} + +print_error_and_exit() { + print_error "${1:-unknown error}" + exit "${2:-1}" +} + +get_opts() { + if opt="$(getopt -o '' -l document-path:,schema-path:,repo-path: -n "$(basename "$0")" -- "$@")"; then + eval set -- "$opt" + else + print_error_and_exit "unable to parse options" + fi + + while true; do + case "$1" in + --document-path) + DOCUMENT_PATH="$2" + shift 2 + ;; + --schema-path) + SCHEMA_PATH="$2" + shift 2 + ;; + --) + shift + break + ;; + *) + print_error_and_exit "unknown option: $1" + ;; + esac + done +} + +validate_opts() { + if [ -z "${DOCUMENT_PATH:-}" ]; then + print_error_and_exit "DOCUMENT_PATH is a required option. It must be the path to the document to validate." + exit 1 + fi + + if [ -z "${SCHEMA_PATH:-}" ]; then + print_error_and_exit "SCHEMA_PATH is a required option. It must be the path to the schema to validate against." + exit 1 + fi +} + +# Curl the GitHub API to get a list of files for the specified PR. If files are +# found, exit. We might eventually want to validate the data here. +validate_schema() { + echo "Validating ${DOCUMENT_PATH} against ${SCHEMA_PATH}" + + pushd "${REPO_PATH}" + + VALIDATE_SCHEMA_PATH=../tools/cmd/schema-validator + pushd ${VALIDATE_SCHEMA_PATH} + go build + popd + + set +e + "${VALIDATE_SCHEMA_PATH}"/schema-validator --documentPath "${DOCUMENT_PATH}" --schemaPath "${SCHEMA_PATH}" + returnCode=$? + set -e + + exit "${returnCode}" +} + +main() { + get_opts "$@" + validate_opts + + validate_schema + return 1 +} + +main "$@" diff --git a/testgrid/config.yaml b/testgrid/config.yaml index ad76b4c0334..88bff18a944 100644 --- a/testgrid/config.yaml +++ b/testgrid/config.yaml @@ -13,6 +13,7 @@ dashboards: - name: istio_common-files_postsubmit - name: istio_community - name: istio_community_postsubmit +- name: istio_enhancements - name: istio_envoy - name: istio_envoy_periodic - name: istio_gogo-genproto