pod_test_code_coverage_report.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Copyright 2021 Google LLC
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # https://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. set -ex
  15. # Loop through arguments and process them
  16. for arg in "$@"
  17. do
  18. case $arg in
  19. --sdk=*)
  20. SDK="${arg#*=}"
  21. shift # Remove --sdk= from processing
  22. ;;
  23. --platform=*)
  24. PLATFORM="${arg#*=}"
  25. shift
  26. ;;
  27. --test_spec=*)
  28. TEST_SPEC="${arg#*=}"
  29. shift
  30. ;;
  31. --output_path=*)
  32. OUTPUT_PATH="${arg#*=}"
  33. shift
  34. ;;
  35. esac
  36. done
  37. DEFAULT_OUTPUT_PATH="/Users/runner/${SDK}-${PLATFORM}.xcresult"
  38. DEFAULT_TEST_SPEC="unit"
  39. OUTPUT_PATH="${OUTPUT_PATH:-${DEFAULT_OUTPUT_PATH}}"
  40. TEST_SPEC="${TEST_SPEC:-${DEFAULT_TEST_SPEC}}"
  41. [[ -z "$SDK" ]] && { echo "Parameter --sdk should be specified, e.g. --sdk=FirebaseStorage" ; exit 1; }
  42. [[ -z "$PLATFORM" ]] && { echo "Parameter --platform should be specified, e.g. --platform=ios" ; exit 1; }
  43. echo "SDK: ${SDK}"
  44. echo "PLATFORM: ${PLATFORM}"
  45. echo "OUTPUT_PATH: ${OUTPUT_PATH}"
  46. echo "TEST_SPEC: ${TEST_SPEC}"
  47. if [ -d "/Users/runner/Library/Developer/Xcode/DerivedData" ]; then
  48. rm -r /Users/runner/Library/Developer/Xcode/DerivedData/*
  49. fi
  50. # Setup for pod unit tests
  51. if [ $SDK == "FirebasePerformance" ]; then
  52. scripts/setup_bundler.sh
  53. scripts/third_party/travis/retry.sh scripts/build.sh Performance ${PLATFORM} unit
  54. elif [ $SDK == "FirebaseFirestore" ]; then
  55. scripts/install_prereqs.sh Firestore ${PLATFORM} xcodebuild
  56. scripts/third_party/travis/retry.sh scripts/build.sh Firestore ${PLATFORM} xcodebuild
  57. else
  58. # Run unit tests of pods and put xcresult bundles into OUTPUT_PATH, which
  59. # should be a targeted dir of actions/upload-artifact in workflows.
  60. # In code coverage workflow, files under OUTPUT_PATH will be uploaded to
  61. # GitHub Actions.
  62. scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb "${SDK}".podspec --platforms="$(tr '[:upper:]' '[:lower:]'<<<${PLATFORM})" --test-specs="${TEST_SPEC}"
  63. fi
  64. find /Users/runner/Library/Developer/Xcode/DerivedData -type d -regex ".*/.*\.xcresult" -execdir cp -R '{}' "${OUTPUT_PATH}" \;