pull_request_in_docker.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. #
  3. # This is the script that runs inside Docker, once the image has been built,
  4. # to execute all tests for the "pull request" project.
  5. WORKSPACE_BASE=`pwd`
  6. MY_DIR="$(dirname "$0")"
  7. TEST_SCRIPT=$MY_DIR/../tests.sh
  8. BUILD_DIR=/tmp/protobuf
  9. set -e # exit immediately on error
  10. set -x # display all commands
  11. # The protobuf repository is mounted into our Docker image, but read-only.
  12. # We clone into a directory inside Docker (this is faster than cp).
  13. rm -rf $BUILD_DIR
  14. mkdir -p $BUILD_DIR
  15. cd $BUILD_DIR
  16. git clone /var/local/jenkins/protobuf
  17. cd protobuf
  18. # Set up the directory where our test output is going to go.
  19. OUTPUT_DIR=`mktemp -d`
  20. LOG_OUTPUT_DIR=$OUTPUT_DIR/logs
  21. mkdir -p $LOG_OUTPUT_DIR/1/cpp
  22. ################################################################################
  23. # cpp build needs to run first, non-parallelized, so that protoc is available
  24. # for other builds.
  25. # Output filenames to follow the overall scheme used by parallel, ie:
  26. # $DIR/logs/1/cpp/stdout
  27. # $DIR/logs/1/cpp/stderr
  28. # $DIR/logs/1/csharp/stdout
  29. # $DIR/logs/1/csharp/stderr
  30. # $DIR/logs/1/java_jdk7/stdout
  31. # $DIR/logs/1/java_jdk7/stderr
  32. CPP_STDOUT=$LOG_OUTPUT_DIR/1/cpp/stdout
  33. CPP_STDERR=$LOG_OUTPUT_DIR/1/cpp/stderr
  34. # Time the C++ build, so we can put this info in the test output.
  35. # It's important that we get /usr/bin/time (which supports -f and -o) and not
  36. # the bash builtin "time" which doesn't.
  37. TIME_CMD="/usr/bin/time -f %e -o $LOG_OUTPUT_DIR/1/cpp/build_time"
  38. $TIME_CMD $TEST_SCRIPT cpp > >(tee $CPP_STDOUT) 2> >(tee $CPP_STDERR >&2)
  39. # Other tests are run in parallel.
  40. parallel --results $LOG_OUTPUT_DIR --joblog $OUTPUT_DIR/joblog $TEST_SCRIPT ::: \
  41. csharp \
  42. java_jdk7 \
  43. javanano_jdk7 \
  44. java_oracle7 \
  45. javanano_oracle7 \
  46. python \
  47. python_cpp \
  48. ruby21 \
  49. || true # Process test results even if tests fail.
  50. cat $OUTPUT_DIR/joblog
  51. # The directory that is copied from Docker back into the Jenkins workspace.
  52. COPY_FROM_DOCKER=/var/local/git/protobuf/testoutput
  53. mkdir -p $COPY_FROM_DOCKER
  54. TESTOUTPUT_XML_FILE=$COPY_FROM_DOCKER/testresults.xml
  55. # Process all the output files from "parallel" and package them into a single
  56. # .xml file with detailed, broken-down test output.
  57. python $MY_DIR/make_test_output.py $OUTPUT_DIR > $TESTOUTPUT_XML_FILE
  58. ls -l $TESTOUTPUT_XML_FILE