...

Text file src/helm.sh/helm/v3/scripts/coverage.sh

Documentation: helm.sh/helm/v3/scripts

     1#!/usr/bin/env bash
     2
     3# Copyright The Helm 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
    17set -euo pipefail
    18
    19covermode=${COVERMODE:-atomic}
    20coverdir=$(mktemp -d /tmp/coverage.XXXXXXXXXX)
    21profile="${coverdir}/cover.out"
    22
    23pushd /
    24hash goveralls 2>/dev/null || go install github.com/mattn/goveralls@v0.0.11
    25popd
    26
    27generate_cover_data() {
    28  for d in $(go list ./...) ; do
    29    (
    30      local output="${coverdir}/${d//\//-}.cover"
    31      go test -coverprofile="${output}" -covermode="$covermode" "$d"
    32    )
    33  done
    34
    35  echo "mode: $covermode" >"$profile"
    36  grep -h -v "^mode:" "$coverdir"/*.cover >>"$profile"
    37}
    38
    39push_to_coveralls() {
    40  goveralls -coverprofile="${profile}" -service=github
    41}
    42
    43generate_cover_data
    44go tool cover -func "${profile}"
    45
    46case "${1-}" in
    47  --html)
    48    go tool cover -html "${profile}"
    49    ;;
    50  --coveralls)
    51    push_to_coveralls
    52    ;;
    53esac
    54

View as plain text