GJL commented on a change in pull request #6642: [FLINK-8819][travis] Rework 
travis script to use stages
URL: https://github.com/apache/flink/pull/6642#discussion_r216167556
 
 

 ##########
 File path: tools/travis_controller.sh
 ##########
 @@ -0,0 +1,211 @@
+#!/usr/bin/env bash
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+CACHE_DIR="$HOME/flink_cache"
+CACHE_BUILD_DIR="$CACHE_DIR/$TRAVIS_BUILD_NUMBER"
+CACHE_FLINK_DIR="$CACHE_BUILD_DIR/flink"
+
+HERE="`dirname \"$0\"`"                                # relative
+HERE="`( cd \"$HERE\" && pwd )`"       # absolutized and normalized
+if [ -z "$HERE" ] ; then
+       # error; for some reason, the path is not accessible
+       # to the script (e.g. permissions re-evaled after suid)
+       exit 1  # fail
+fi
+
+source "${HERE}/travis/fold.sh"
+source "${HERE}/travis/stage.sh"
+source "${HERE}/travis/shade.sh"
+
+function deleteOldCaches() {
+       while read CACHE_DIR; do
+               local old_number="${CACHE_DIR##*/}"
+               if [ "$old_number" -lt "$TRAVIS_BUILD_NUMBER" ]; then
+                       echo "Deleting old cache $CACHE_DIR"
+                       rm -rf "$CACHE_DIR"
+               fi
+       done
+}
+
+# delete leftover caches from previous builds
+find "$CACHE_DIR" -mindepth 1 -maxdepth 1 | grep -v "$TRAVIS_BUILD_NUMBER" | 
deleteOldCaches
+
+function getCurrentStage() {
+       STAGE_NUMBER=$(echo "$TRAVIS_JOB_NUMBER" | cut -d'.' -f 2)
+       case $STAGE_NUMBER in
+               (1)
 
 Review comment:
   It seems to be fragile to rely on the stage number (reordering stages in 
`.travis.yml`, adding stages in the middle). Why not set the stage constants 
(`$STAGE_COMPILE`, `$STAGE_CORE`, etc.) as an env variable, e.g., 
`CURRENT_STAGE`? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to