github.com/shashidharatd/test-infra@v0.0.0-20171006011030-71304e1ca560/triage/update_summaries.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2017 The Kubernetes Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  set -exu
    18  cd $(dirname $0)
    19  
    20  if [[ -e ${GOOGLE_APPLICATION_CREDENTIALS-} ]]; then
    21    gcloud auth activate-service-account --key-file="${GOOGLE_APPLICATION_CREDENTIALS}"
    22    gcloud config set project k8s-gubernator
    23    bq show <<< $'\n'
    24  fi
    25  
    26  date
    27  # cat << '#'
    28  table_mtime=$(bq --format=json show 'k8s-gubernator:build.week' | jq -r '(.lastModifiedTime|tonumber)/1000|floor' )
    29  if [[ ! -e triage_builds.json ]] || [ $(stat -c%Y triage_builds.json) -lt $table_mtime ]; then
    30    echo "UPDATING" $table_mtime
    31    bq --headless --format=json query -n 1000000 'select path, timestamp_to_sec(started) started, elapsed, tests_run, tests_failed, result, executor, job, number from [k8s-gubernator:build.week]' > triage_builds.json
    32    bq --headless --format=json query -n 10000000 'select path build, test.name name, test.failure_text failure_text from [k8s-gubernator:build.week] where test.failed' > triage_tests.json
    33    rm -f failed*.json
    34  fi
    35  #
    36  
    37  gsutil cp gs://k8s-gubernator/triage/failure_data.json failure_data_previous.json
    38  curl -sO --retry 6 https://raw.githubusercontent.com/kubernetes/kubernetes/master/test/test_owners.json
    39  
    40  mkdir -p slices
    41  
    42  pypy summarize.py triage_builds.json triage_tests.json \
    43    --previous failure_data_previous.json --owners test_owners.json \
    44    --output failure_data.json --output_slices slices/failure_data_PREFIX.json
    45  
    46  gsutil_cp() {
    47    gsutil -h 'Cache-Control: no-store, must-revalidate' -m cp -Z -a public-read "$@"
    48  }
    49  
    50  gsutil_cp failure_data.json gs://k8s-gubernator/triage/
    51  gsutil_cp slices/*.json gs://k8s-gubernator/triage/slices/
    52  gsutil_cp failure_data.json "gs://k8s-gubernator/triage/history/$(date -u +%Y%m%d).json"