Jeff Gaston | 1aadce0d | 2022-01-26 18:28:02 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -e |
| 3 | |
| 4 | buildId="$1" |
| 5 | target="$2" |
Jeff Gaston | 9b7c32c | 2022-03-09 19:00:51 -0500 | [diff] [blame] | 6 | sendUpToDateScan=false |
Jeff Gaston | 1aadce0d | 2022-01-26 18:28:02 -0500 | [diff] [blame] | 7 | |
| 8 | function usage() { |
Jeff Gaston | 9b7c32c | 2022-03-09 19:00:51 -0500 | [diff] [blame] | 9 | echo "usage: $0 <buildId> <target> [--include-up-to-date]" |
Jeff Gaston | 1aadce0d | 2022-01-26 18:28:02 -0500 | [diff] [blame] | 10 | echo |
| 11 | echo "Downloads build scan information for the corresponding build and uploads it to the enterprise server configured in settings.gradle" |
Jeff Gaston | 9b7c32c | 2022-03-09 19:00:51 -0500 | [diff] [blame] | 12 | echo |
| 13 | echo " --include-up-to-date Also upload scan-up-to-date.zip, the scan of the second build which should be mostly UP-TO-DATE" |
Jeff Gaston | 1aadce0d | 2022-01-26 18:28:02 -0500 | [diff] [blame] | 14 | exit 1 |
| 15 | } |
| 16 | |
| 17 | if [ "$buildId" == "" ]; then |
| 18 | usage |
| 19 | fi |
| 20 | |
| 21 | if [ "$target" == "" ]; then |
| 22 | usage |
| 23 | fi |
| 24 | |
Jeff Gaston | 9b7c32c | 2022-03-09 19:00:51 -0500 | [diff] [blame] | 25 | if [ "$3" != "" ]; then |
| 26 | if [ "$3" == "--include-up-to-date" ]; then |
| 27 | sendUpToDateScan=true |
Jeff Gaston | 1aadce0d | 2022-01-26 18:28:02 -0500 | [diff] [blame] | 28 | else |
Jeff Gaston | 9b7c32c | 2022-03-09 19:00:51 -0500 | [diff] [blame] | 29 | usage |
Jeff Gaston | 1aadce0d | 2022-01-26 18:28:02 -0500 | [diff] [blame] | 30 | fi |
Jeff Gaston | 9b7c32c | 2022-03-09 19:00:51 -0500 | [diff] [blame] | 31 | fi |
Jeff Gaston | 1aadce0d | 2022-01-26 18:28:02 -0500 | [diff] [blame] | 32 | # find scan dir |
Aurimas Liutikas | 99548e6 | 2024-12-03 08:40:18 -0800 | [diff] [blame] | 33 | if [ -z "${OUT_DIR+x}" ] ; then |
| 34 | SCRIPT_PATH="$(cd $(dirname $0) && pwd -P)" |
| 35 | export OUT_DIR=$SCRIPT_PATH/../../../out |
Jeff Gaston | 1aadce0d | 2022-01-26 18:28:02 -0500 | [diff] [blame] | 36 | fi |
Aurimas Liutikas | 99548e6 | 2024-12-03 08:40:18 -0800 | [diff] [blame] | 37 | effectiveGradleUserHome="$OUT_DIR/.gradle" |
Jeff Gaston | 1aadce0d | 2022-01-26 18:28:02 -0500 | [diff] [blame] | 38 | scanDir="$effectiveGradleUserHome/build-scan-data" |
| 39 | |
Jeff Gaston | 9b7c32c | 2022-03-09 19:00:51 -0500 | [diff] [blame] | 40 | function downloadScan() { |
| 41 | filename="$1" |
| 42 | echo downloading build scan from $buildId $target |
| 43 | if [ "$target" == "androidx_incremental" ]; then |
| 44 | downloadPath="incremental/$filename" |
| 45 | else |
| 46 | downloadPath="$filename" |
| 47 | fi |
| 48 | cd /tmp |
| 49 | /google/data/ro/projects/android/fetch_artifact --bid $buildId --target $target "$downloadPath" |
| 50 | cd - |
| 51 | } |
| 52 | |
Jeff Gaston | 1aadce0d | 2022-01-26 18:28:02 -0500 | [diff] [blame] | 53 | function unzipScan() { |
Jeff Gaston | 9b7c32c | 2022-03-09 19:00:51 -0500 | [diff] [blame] | 54 | filename="$1" |
Jeff Gaston | 1aadce0d | 2022-01-26 18:28:02 -0500 | [diff] [blame] | 55 | echo |
| 56 | echo unzipping build scan |
| 57 | rm -rf "$scanDir" |
Jeff Gaston | 9b7c32c | 2022-03-09 19:00:51 -0500 | [diff] [blame] | 58 | unzip -q /tmp/"$filename" -d "$scanDir" |
Jeff Gaston | 1aadce0d | 2022-01-26 18:28:02 -0500 | [diff] [blame] | 59 | } |
Jeff Gaston | 1aadce0d | 2022-01-26 18:28:02 -0500 | [diff] [blame] | 60 | |
| 61 | function uploadScan() { |
| 62 | log="$scanDir/upload-failure.log" |
| 63 | rm -f "$log" |
| 64 | echo |
| 65 | echo uploading build scan |
Aurimas Liutikas | 628d3b5 | 2024-01-19 00:56:39 +0000 | [diff] [blame] | 66 | ./gradlew :buildScanPublishPrevious |
Jeff Gaston | 1aadce0d | 2022-01-26 18:28:02 -0500 | [diff] [blame] | 67 | sleep 2 |
| 68 | if cat "$log" 2>/dev/null; then |
| 69 | echo upload failed |
| 70 | fi |
| 71 | } |
Jeff Gaston | 9b7c32c | 2022-03-09 19:00:51 -0500 | [diff] [blame] | 72 | |
| 73 | function sendScan() { |
| 74 | filename="$1" |
| 75 | downloadScan "$filename" |
| 76 | unzipScan "$filename" |
| 77 | uploadScan |
| 78 | } |
| 79 | |
Aurimas Liutikas | cb2e40a | 2025-02-25 08:31:54 -0800 | [diff] [blame] | 80 | sendScan scan.1.zip |
Jeff Gaston | 9b7c32c | 2022-03-09 19:00:51 -0500 | [diff] [blame] | 81 | echo uploaded scan |
| 82 | if [ "$sendUpToDateScan" == "true" ]; then |
| 83 | sendScan scan-up-to-date.zip |
| 84 | echo uploaded scan of second, up-to-date build |
| 85 | fi |