Jeff Gaston | c58f315 | 2021-04-09 12:45:53 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -e |
| 3 | |
| 4 | echo "Starting $0 at $(date)" |
| 5 | |
| 6 | cd "$(dirname $0)" |
| 7 | |
| 8 | CHECKOUT_DIR="$(cd ../../.. && pwd)" |
| 9 | OUT_DIR="$CHECKOUT_DIR/out" |
| 10 | if [ "$DIST_DIR" == "" ]; then |
| 11 | DIST_DIR="$OUT_DIR/dist" |
| 12 | fi |
Jeff Gaston | e18bf2a | 2021-05-11 12:31:42 -0400 | [diff] [blame] | 13 | # move OUT_DIR and DIST_DIR into subdirectories so that if diagnose-build-failure deletes them, it doesn't interfere with any files generated by buildbot code |
| 14 | export OUT_DIR="$OUT_DIR/incremental" |
| 15 | mkdir -p "$OUT_DIR" |
| 16 | export DIST_DIR="$DIST_DIR/incremental" |
| 17 | mkdir -p "$DIST_DIR" |
Jeff Gaston | c58f315 | 2021-04-09 12:45:53 -0400 | [diff] [blame] | 18 | |
Jeff Gaston | 436e8d6 | 2021-09-24 11:44:09 -0400 | [diff] [blame] | 19 | if echo "$BUILD_NUMBER" | grep "P" >/dev/null; then |
| 20 | PRESUBMIT=true |
| 21 | else |
| 22 | PRESUBMIT=false |
| 23 | fi |
| 24 | |
Jeff Gaston | c58f315 | 2021-04-09 12:45:53 -0400 | [diff] [blame] | 25 | function hashOutDir() { |
| 26 | hashFile=out.hashes |
| 27 | echo "hashing out dir and saving into $DIST_DIR/$hashFile" |
| 28 | # We hash files in parallel for more performance (-P <number>) |
| 29 | # We limit the number of files hashed by any one process (-n <number>) to lower the risk of one |
| 30 | # process having to do much more work than the others. |
| 31 | # We do allow each process to hash multiple files (also -n <number>) to avoid spawning too many processes |
| 32 | # It would be nice to copy all files, but that takes a while |
| 33 | time (cd $OUT_DIR && find -type f | grep -v "$hashFile" | xargs --no-run-if-empty -P 32 -n 64 sha1sum > $DIST_DIR/$hashFile) |
| 34 | echo "done hashing out dir" |
| 35 | } |
| 36 | hashOutDir |
| 37 | |
Jeff Gaston | 0591886 | 2021-05-19 16:57:42 -0400 | [diff] [blame] | 38 | # diagnostics to hopefully help us figure out b/188565660 |
| 39 | function zipKotlinMetadata() { |
| 40 | zipFile=kotlinMetadata.zip |
| 41 | echo "zipping kotlin metadata" |
Jeff Gaston | ba5a22a | 2021-06-14 11:38:00 -0400 | [diff] [blame] | 42 | rm -f "$DIST_DIR/$zipFile" |
Jeff Gaston | 0e05630 | 2021-07-16 15:19:41 -0400 | [diff] [blame] | 43 | (cd $OUT_DIR && find -name "*kotlin_module" | xargs zip -q -u "$DIST_DIR/$zipFile") |
Jeff Gaston | 0591886 | 2021-05-19 16:57:42 -0400 | [diff] [blame] | 44 | echo done zipping kotlin metadata |
| 45 | } |
| 46 | |
Jeff Gaston | 436e8d6 | 2021-09-24 11:44:09 -0400 | [diff] [blame] | 47 | # If we encounter a failure in postsubmit, we try a few things to determine if the failure is |
| 48 | # reproducible |
| 49 | DIAGNOSE_ARG="" |
| 50 | if [ "$PRESUBMIT" == "false" ]; then |
| 51 | DIAGNOSE_ARG="--diagnose" |
| 52 | fi |
| 53 | |
Jeff Gaston | c58f315 | 2021-04-09 12:45:53 -0400 | [diff] [blame] | 54 | # Run Gradle |
Jeff Gaston | 07d7d69 | 2021-06-14 10:50:04 -0400 | [diff] [blame] | 55 | EXIT_VALUE=0 |
Jeff Gaston | 436e8d6 | 2021-09-24 11:44:09 -0400 | [diff] [blame] | 56 | if impl/build.sh $DIAGNOSE_ARG buildOnServer checkExternalLicenses listTaskOutputs validateAllProperties \ |
Jeff Gaston | 0591886 | 2021-05-19 16:57:42 -0400 | [diff] [blame] | 57 | --profile "$@"; then |
| 58 | echo build succeeded |
Jeff Gaston | 07d7d69 | 2021-06-14 10:50:04 -0400 | [diff] [blame] | 59 | EXIT_VALUE=0 |
Jeff Gaston | 0591886 | 2021-05-19 16:57:42 -0400 | [diff] [blame] | 60 | else |
| 61 | zipKotlinMetadata |
| 62 | echo build failed |
Jeff Gaston | 436e8d6 | 2021-09-24 11:44:09 -0400 | [diff] [blame] | 63 | if [ "$PRESUBMIT" == "true" ]; then |
Jeff Gaston | 5243749 | 2021-09-08 15:29:41 -0400 | [diff] [blame] | 64 | echo androidx_incremental ignoring presubmit failure |
| 65 | else |
| 66 | EXIT_VALUE=1 |
| 67 | fi |
Jeff Gaston | 0591886 | 2021-05-19 16:57:42 -0400 | [diff] [blame] | 68 | fi |
Jeff Gaston | c58f315 | 2021-04-09 12:45:53 -0400 | [diff] [blame] | 69 | |
| 70 | # Parse performance profile reports (generated with the --profile option above) and re-export the metrics in an easily machine-readable format for tracking |
| 71 | impl/parse_profile_htmls.sh |
| 72 | |
| 73 | echo "Completing $0 at $(date)" |
Jeff Gaston | 07d7d69 | 2021-06-14 10:50:04 -0400 | [diff] [blame] | 74 | |
| 75 | exit "$EXIT_VALUE" |