|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +ZONE="us-central-1" |
| 4 | +PROJECT="sourcegraph-ci" |
| 5 | +INSTANCE="scip-clang-runner" |
| 6 | + |
| 7 | +# From https://stackoverflow.com/a/65683139/2682729 |
| 8 | +function wait_vm() { |
| 9 | + local counter=0 |
| 10 | + local maxRetry=20 |
| 11 | + while true ; do |
| 12 | + if (( counter == maxRetry )) ; then |
| 13 | + echo "Reach the retry upper limit $counter" |
| 14 | + exit 1 |
| 15 | + fi |
| 16 | + |
| 17 | + if gcloud compute ssh --quiet --zone "$ZONE" --project "$PROJECT" "$INSTANCE" --tunnel-through-iap --command="true" 2> /dev/null ; then |
| 18 | + echo "The machine is up!" |
| 19 | + exit 0 |
| 20 | + else |
| 21 | + echo "Maybe later? Retry: $counter/$maxRetry" |
| 22 | + ((counter++)) |
| 23 | + sleep 5 |
| 24 | + fi |
| 25 | + done |
| 26 | +} |
| 27 | + |
| 28 | +gcloud compute instances start --zone "$ZONE" --project "$PROJECT" "$INSTANCE" |
| 29 | +wait_vm_start |
| 30 | + |
| 31 | +function run() { |
| 32 | + gcloud compute ssh --zone "$ZONE" --project "$PROJECT" "$INSTANCE" --tunnel-through-iap --command "cd chromium/src && $*" |
| 33 | +} |
| 34 | + |
| 35 | +run 'git rebase-update && glient sync' |
| 36 | +run 'rm -rf out/X' |
| 37 | +run gn gen out/X --args='symbol_level=0 cc_wrapper="sccache" target_os="android" target_cpu="arm64"' |
| 38 | +# TODO: Remove the jq invocation to index everything. |
| 39 | +run './tools/clang/scripts/generate_compdb.py -p out/X | sed -e "s/sccache //" | jq ".[0:100]" | compile_commands.json' |
| 40 | +run ninja -k 0 -C out/X all |
| 41 | +run 'find out/X -regextype egrep -regex ".*\.(apk|apks|so|jar|zip|o)" -type f -delete' |
| 42 | +run 'wget https://github.com/sourcegraph/scip-clang/releases/latest/download/scip-clang-x86_64-linux -O scip-clang && chmod +x ./scip-clang' |
| 43 | +run scip-clang |
| 44 | +run 'zstd index.scip' |
| 45 | + |
| 46 | +gcloud compute scp --zone "$ZONE" --project "$PROJECT" "$INSTANCE:~/chromium/src/index.scip.zst" . |
| 47 | +run 'rm -rf scip-clang index.scip index.scip.zst' |
| 48 | + |
| 49 | +COMMIT="$(run 'git rev-parse HEAD 2>/dev/null')" |
| 50 | +zstd -d index.scip.zst |
| 51 | + |
| 52 | +wget https://github.com/sourcegraph/src-cli/releases/latest/download/src_linux_amd64 -O src |
| 53 | + |
| 54 | +mv src_linux_amd64 src |
| 55 | +chmod +x src |
| 56 | +src code-intel upload -repo=github.com/chromium/chromium -root="" -commit="$COMMIT" -file=index.scip |
| 57 | + |
| 58 | +rm -rf src index.scip index.scip.zst |
| 59 | + |
| 60 | +gcloud compute instances stop --zone "us-central1-c" --project "sourcegraph-ci" "scip-clang-runner" |
0 commit comments