docker_run.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. # Copyright 2016 The gRPC Authors
  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. #
  16. # This script is invoked by build_and_run_docker.sh inside a docker
  17. # container. You should never need to call this script on your own.
  18. set -e
  19. if [ "${RELATIVE_COPY_PATH}" == "" ]
  20. then
  21. mkdir -p /var/local/git
  22. git clone "${EXTERNAL_GIT_ROOT}" /var/local/git/grpc
  23. # clone gRPC submodules, use data from locally cloned submodules where possible
  24. # TODO: figure out a way to eliminate this following shellcheck suppressions
  25. # shellcheck disable=SC2016,SC1004
  26. (cd "${EXTERNAL_GIT_ROOT}" && git submodule foreach 'git clone ${EXTERNAL_GIT_ROOT}/${name} /var/local/git/grpc/${name}')
  27. (cd /var/local/git/grpc && git submodule init)
  28. else
  29. mkdir -p "/var/local/git/grpc/${RELATIVE_COPY_PATH}"
  30. cp -r "${EXTERNAL_GIT_ROOT}/${RELATIVE_COPY_PATH}"/* "/var/local/git/grpc/${RELATIVE_COPY_PATH}"
  31. fi
  32. cd /var/local/git/grpc
  33. # ensure the "reports" directory exists
  34. mkdir -p reports
  35. exit_code=0
  36. ${DOCKER_RUN_SCRIPT_COMMAND} || exit_code=$?
  37. # copy reports/ dir and files matching one of the patterns to the well-known
  38. # location of report dir mounted to the docker container.
  39. # --parents preserves the directory structure for files matched by find.
  40. cp -r reports/ /var/local/report_dir
  41. find . -name report.xml -exec cp --parents {} /var/local/report_dir \;
  42. find . -name sponge_log.xml -exec cp --parents {} /var/local/report_dir \;
  43. find . -name 'report_*.xml' -exec cp --parents {} /var/local/report_dir \;
  44. chmod -R ugo+r /var/local/report_dir || true
  45. # Move contents of OUTPUT_DIR from under the workspace to a directory that will be visible to the docker host.
  46. if [ "${OUTPUT_DIR}" != "" ]
  47. then
  48. # create the directory if it doesn't exist yet.
  49. mkdir -p "${OUTPUT_DIR}"
  50. mv "${OUTPUT_DIR}" /var/local/output_dir || exit_code=$?
  51. chmod -R ugo+r /var/local/output_dir || true
  52. fi
  53. if [ -x "$(command -v ccache)" ]
  54. then
  55. ccache --show-stats || true
  56. fi
  57. exit $exit_code