#!/bin/sh # # This is a helper script to make it easier for me to test all ick # compontents together. # # This script optionally installs (based on first arg: yes or no) ick # on a cluster, and then sets up a couple of test projects, and builds # those. # # See the run-cluster.sh file for how the cluster is set up. # # The ci-vars.yaml file has the variables for setting up the test # instance. # # See ickdev.yaml for the ick projects that are set up: ick_streatch # and ick2. If you change the project names, you need to edit this # file. # # This script assume you have icktool installed and configured, and # that the ick2-ansible repository is checked out at a given location # (see below). Also the ick rules are checked out (liw-ci repo). Also, # the cluster hostnames are listed in hosts.ickdev. All of the various # values work for me. If you'd like to make this more general, that'd # be fantastic: please submit patches. # # Lars Wirzenius set -eu run_ansible="$1" ansible="$HOME/code/ick/ick2-ansible" rules="$HOME/code/ick/liw-ci" controller="https://ickdev-controller.vm.liw.fi" build_status() { icktool -c "$controller" status | awk -v "p=$1" '$1 == p { print $5 }' } current_log() { icktool -c "$controller" status | awk -v "p=$1" '$1 == p { print $7 }' } wait_for_build_to_start() { local project="$1" local prevlog="$2" echo "Waiting for build of $project to start" while true do log="$(current_log "$project")" [ "$log" != "" ] [ "$prevlog" != "" ] if [ "$log" = "$prevlog" ] then # Build hasn't started sleep 5 continue fi break done echo "Project $project build has started" } wait_for_build_to_finish() { local project="$1" echo "Waiting for build of $project to finish" while true do bs="$(build_status "$project")" case "$bs" in OK) echo "Build is finished"; break ;; building) sleep 5; continue ;; FAILED*) echo "Build failed: $bs" 1>&2 ; exit 1 ;; *) echo "Don't understand build status $bs" 1>&2 ; exit 1 ;; esac done } build() { local project="$1" local log="$(current_log "$project")" echo "Triggering $project" icktool -c "$controller" trigger "$project" wait_for_build_to_start "$project" "$log" wait_for_build_to_finish "$project" } if [ "$run_ansible" = yes ] then cd "$ansible" ./run-cluster.sh hosts.ickdev -e @ci-vars.yml fi icktool -c "$controller" make-it-so < "${rules}/ickdev.yaml" build ick_stretch build ick2