rastrillo / fiesta Public

Clone
git clone https://amadan.net/rastrillo/fiesta

Plain git — no account needed to clone.

Download

Download this file

1#!/bin/sh
2# Runs the suite's roles (the Makefile's SUITE, passed as arguments).
3#
4# amadan sets AMADAN_SHARD and AMADAN_SHARD_COUNT on every step, 0 and 1
5# when the step is not sharded, so those two numbers are the whole
6# decision:
7#
8# - unset, or a count of 1: every role, in order, stopping at the
9# first failure. That is `make ci` by hand, the single-script
10# .amadan/ci fallback, and a suite step that lost its @N.
11# - a count equal to the number of roles: this shard's role, alone.
12# - any other count: a refusal. A count above the roles would leave
13# shards with nothing to do reporting green; one below would leave
14# roles that run nowhere while every shard still says ok.
15set -eu
16
17make=${MAKE:-make}
18roles=$#
19count=${AMADAN_SHARD_COUNT:-1}
20shard=${AMADAN_SHARD:-0}
21
22if [ "$count" -eq 1 ]; then
23 for role; do
24 echo "==> make $role"
25 $make --no-print-directory "$role"
26 done
27 exit 0
28fi
29
30if [ "$count" -ne "$roles" ]; then
31 echo "suite: started as $count shards, but the Makefile's SUITE has $roles roles."
32 echo "suite: rename .amadan/ci.d's suite step to end in @$roles, or every role"
33 echo "suite: past shard $count runs nowhere while each shard still reports ok"
34 exit 1
35fi
36
37# A shard says how long its role took and how much CPU it used, the
38# second line of times being what the role ran: on a shared box the wall
39# time says how busy the box was as much as how heavy the role is, and
40# the CPU is what hack/test-weights.txt and the slice counts are judged
41# by on a box of another size.
42i=0
43for role; do
44 if [ "$i" -eq "$shard" ]; then
45 echo "==> shard $shard of $count: make $role"
46 start=$(date +%s)
47 status=0
48 $make --no-print-directory "$role" || status=$?
49 echo "suite: $role took $(($(date +%s) - start))s; CPU, user then system, of this shell and then of the role:"
50 times
51 exit "$status"
52 fi
53 i=$((i + 1))
54done
55echo "suite: shard $shard is outside 0..$((count - 1))"
56exit 1
57