Thomas Vachuska | 21112ad | 2018-08-06 14:28:10 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Tool to perform a cell-based remote bazel build using a borrowed test cell. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | # Check environment |
| 7 | [ -z "$OCN" ] && echo "Cell environment not established" && exit 1 |
| 8 | |
| 9 | # Check arguments and environment |
| 10 | baseCommit=${1:-$(git log | grep origin/master | head -n1 | cut -d\ -f2)} |
| 11 | |
| 12 | # Create a patch file |
Thomas Vachuska | 19bd0c3 | 2018-08-06 15:13:12 -0700 | [diff] [blame] | 13 | git diff $baseCommit > /tmp/$baseCommit.patch |
Thomas Vachuska | 21112ad | 2018-08-06 14:28:10 -0700 | [diff] [blame] | 14 | |
| 15 | # Copy patch file to the remote build machine |
| 16 | scp /tmp/$baseCommit.patch $ONOS_USER@$OCN:/tmp |
| 17 | |
| 18 | ssh -t -t $ONOS_USER@$OCN " |
| 19 | source ~/.bash_aliases |
| 20 | cd \$ONOS_ROOT |
| 21 | |
Thomas Vachuska | 6be3068 | 2018-08-06 14:37:43 -0700 | [diff] [blame] | 22 | # Clean-up the workspace and stash away any changes. |
| 23 | git clean -f |
| 24 | git stash |
| 25 | |
Thomas Vachuska | bf6739d | 2018-08-06 20:09:53 -0700 | [diff] [blame^] | 26 | # Make sure the remote build machine is on the same commit hash as the local one |
| 27 | remoteCommit=\$(git log -n 1 | head -n1 | cut -d\ -f2) |
Thomas Vachuska | 21112ad | 2018-08-06 14:28:10 -0700 | [diff] [blame] | 28 | if [ "\$remoteCommit" != "$baseCommit" ]; then |
| 29 | git checkout master |
| 30 | git pull |
| 31 | git checkout $baseCommit |
| 32 | fi |
| 33 | |
Thomas Vachuska | bf6739d | 2018-08-06 20:09:53 -0700 | [diff] [blame^] | 34 | # Apply the patch if necessary |
| 35 | [ -s /tmp/$baseCommit.patch ] && git apply /tmp/$baseCommit.patch |
Thomas Vachuska | 21112ad | 2018-08-06 14:28:10 -0700 | [diff] [blame] | 36 | |
Thomas Vachuska | 19bd0c3 | 2018-08-06 15:13:12 -0700 | [diff] [blame] | 37 | # Run the build (neutralizing known environment mutations in SSH sessions) |
Thomas Vachuska | 6be3068 | 2018-08-06 14:37:43 -0700 | [diff] [blame] | 38 | SHLVL=1 SSH_CLIENT=0 SSH_CONNECTION=0 bazel build onos |
Thomas Vachuska | 21112ad | 2018-08-06 14:28:10 -0700 | [diff] [blame] | 39 | " |