]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/build_tools/cont_integration.sh
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rocksdb / build_tools / cont_integration.sh
1 #!/bin/bash
2 #
3 # Copyright (c) 2016, Facebook. All rights reserved.
4 #
5 # Overall wrapper script for RocksDB continuous builds. The implementation is a
6 # trivial pulling scheme. We loop infinitely, check if any new changes have been
7 # committed, if yes then trigger a Sandcastle run, and finally go to sleep again
8 # for a certain interval.
9 #
10
11 SRC_GIT_REPO=/data/git/rocksdb-public
12 error=0
13
14 function log {
15 DATE=`date +%Y-%m-%d:%H:%M:%S`
16 echo $DATE $@
17 }
18
19 function log_err {
20 log "ERROR: $@ Error code: $error."
21 }
22
23 function update_repo_status {
24 # Update the parent first.
25 pushd $SRC_GIT_REPO
26
27 # This is a fatal error. Something in the environment isn't right and we will
28 # terminate the execution.
29 error=$?
30 if [ ! $error -eq 0 ]; then
31 log_err "Where is $SRC_GIT_REPO?"
32 exit $error
33 fi
34
35 HTTPS_PROXY=fwdproxy:8080 git fetch -f
36
37 error=$?
38 if [ ! $error -eq 0 ]; then
39 log_err "git fetch -f failed."
40 popd
41 return $error
42 fi
43
44 git update-ref refs/heads/master refs/remotes/origin/master
45
46 error=$?
47 if [ ! $error -eq 0 ]; then
48 log_err "git update-ref failed."
49 popd
50 return $error
51 fi
52
53 popd
54
55 # We're back in an instance-specific directory. Get the latest changes.
56 git pull --rebase
57
58 error=$?
59 if [ ! $error -eq 0 ]; then
60 log_err "git pull --rebase failed."
61 return $error
62 fi
63 }
64
65 #
66 # Execution starts here.
67 #
68
69 # Path to the determinator from the root of the RocksDB repo.
70 CONTRUN_DETERMINATOR=./arcanist_util/config/RocksDBCommonHelper.php
71
72 # Value of the previous commit.
73 PREV_COMMIT=
74
75 log "Starting to monitor for new RocksDB changes ..."
76 log "Running under `pwd` as `whoami`."
77
78 # Paranoia. Make sure that we're using the right branch.
79 git checkout master
80
81 error=$?
82 if [ ! $error -eq 0 ]; then
83 log_err "This is not good. Can't checkout master. Bye-bye!"
84 exit 1
85 fi
86
87 # We'll run forever and let the execution environment terminate us if we'll
88 # exceed whatever timeout is set for the job.
89 while true;
90 do
91 # Get the latest changes committed.
92 update_repo_status
93
94 error=$?
95 if [ $error -eq 0 ]; then
96 LAST_COMMIT=`git log -1 | head -1 | grep commit | awk '{ print $2; }'`
97
98 log "Last commit is '$LAST_COMMIT', previous commit is '$PREV_COMMIT'."
99
100 if [ "$PREV_COMMIT" == "$LAST_COMMIT" ]; then
101 log "There were no changes since the last time I checked. Going to sleep."
102 else
103 if [ ! -z "$LAST_COMMIT" ]; then
104 log "New code has been committed or previous commit not known. " \
105 "Will trigger the tests."
106
107 PREV_COMMIT=$LAST_COMMIT
108 log "Updated previous commit to '$PREV_COMMIT'."
109
110 #
111 # This is where we'll trigger the Sandcastle run. The values for
112 # HTTPS_APP_VALUE and HTTPS_APP_VALUE will be set in the container we're
113 # running in.
114 #
115 POST_RECEIVE_HOOK=1 php $CONTRUN_DETERMINATOR
116
117 error=$?
118 if [ $error -eq 0 ]; then
119 log "Sandcastle run successfully triggered."
120 else
121 log_err "Failed to trigger Sandcastle run."
122 fi
123 else
124 log_err "Previous commit not updated. Don't know what the last one is."
125 fi
126 fi
127 else
128 log_err "Getting latest changes failed. Will skip running tests for now."
129 fi
130
131 # Always sleep, even if errors happens while trying to determine the latest
132 # commit. This will prevent us terminating in case of transient errors.
133 log "Will go to sleep for 5 minutes."
134 sleep 5m
135 done