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