collect_metrics.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env bash
  2. # Copyright 2019 Google
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # USAGE: ./collect_metrics.sh workspace scheme
  16. #
  17. # Collects project health metrics and uploads them to a database. Currently just collects code
  18. # coverage for the provided workspace and scheme. Assumes that those tests have already been
  19. # executed.
  20. set -euo pipefail
  21. if [[ $# -ne 2 ]]; then
  22. cat 1>&2 <<EOF
  23. USAGE: $0 workspace scheme
  24. Collects project health metrics and uploads them to a database. Currently just collects code
  25. coverage for the provided workspace and scheme. Assumes that those tests have already been
  26. executed.
  27. EOF
  28. exit 1
  29. fi
  30. if [[ "${TRAVIS_PULL_REQUEST}" != "false" ]]; then
  31. WORKSPACE="$1"
  32. SCHEME="$2"
  33. gem install xcov
  34. xcov --workspace "${WORKSPACE}" --scheme "${SCHEME}" --output_directory Metrics --json_report
  35. cd Metrics
  36. swift build
  37. .build/debug/Metrics -c report.json -p "${TRAVIS_PULL_REQUEST}"
  38. cd ..
  39. fi