#!/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" ci_dist="$2" prefix="$3" ansible="$HOME/code/ick/ick2-ansible" rules="$HOME/code/ick/liw-ci" controller="https://ickdev2-controller.vm.liw.fi" tool() { "$HOME/code/ick/ick2/icktool" -c "$controller" --no-verify-tls "$@" } build_status() { tool status | awk -v "p=$1" '$1 == p { print $5 }' } current_log() { tool 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" tool 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_prefix=$prefix" -e "ci_dist=$ci_dist" -e @ci-vars.yml fi tool make-it-so < "${rules}/ickdev.yaml" build notify #build ick_stretch #build ick2