Add buildStarted plugin hook

[?]
Mar 12, 2016, 2:48 AM
FCTX433OH7QIVWHXL23DKVSUKBQSLQTRK3PFCKKSMLX6A634456QC

Dependencies

  • [2] B2L4T3X6 Sync with Nix
  • [3] HJOEIMLR Refactor
  • [4] MHVIT4JY Split hydra-queue-runner.cc more
  • [5] K5G5GZY7 Guard against concurrent invocations of hydra-queue-runner
  • [6] BG6PEOB2 Make the output size limit configurable
  • [7] NKQOEVVP Get rid of "will retry" messages after "maybe cancelling..."
  • [8] 7VHPMFAG Use /usr/bin/env to find perl
  • [9] DKJFD6JN Process Nix API changes
  • [10] BRAESISH Warn if PostgreSQL appears stalled
  • [11] X6FOUYFJ int2String -> std::to_string
  • [12] IE2PRAQU hydra-queue-runner: Send build notifications
  • [13] UYUVQWXQ Fix hydra-queue-runner --build-one
  • [*] 24BMQDZA Start of single-process hydra-queue-runner
  • [*] PHNLYPKB Call buildFinished when a cached build is added
  • [*] 5EQYVRWE Add a plugin mechanism

Change contents

  • replacement in src/hydra-queue-runner/builder.cc at line 87
    [3.3048][3.3048:3165]()
    for (auto build2 : dependents)
    if (build2->drvPath == step->drvPath) { build = build2; break; }
    [3.3048]
    [3.3165]
    for (auto build2 : dependents) {
    if (build2->drvPath == step->drvPath) {
    build = build2;
    {
    auto notificationSenderQueue_(notificationSenderQueue.lock());
    notificationSenderQueue_->push(NotificationItem{NotificationItem::Type::Started, build->id});
    }
    notificationSenderWakeup.notify_one();
    }
    }
  • replacement in src/hydra-queue-runner/builder.cc at line 259
    [3.8345][3.8345:8439]()
    notificationSenderQueue_->push(NotificationItem(id, std::vector<BuildID>()));
    [3.8345]
    [3.8439]
    notificationSenderQueue_->push(NotificationItem{NotificationItem::Type::Finished, id});
  • replacement in src/hydra-queue-runner/builder.cc at line 379
    [3.14020][3.14020:14107]()
    notificationSenderQueue_->push(NotificationItem(build->id, dependentIDs));
    [3.14020]
    [3.14107]
    notificationSenderQueue_->push(NotificationItem{NotificationItem::Type::Finished, build->id, dependentIDs});
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 485
    [3.1802][3.1802:1896]()
    printMsg(lvlChatty, format("sending notification about build %1%") % item.first);
    [3.1802]
    [3.1896]
    printMsg(lvlChatty, format("sending notification about build %1%") % item.id);
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 488
    [3.1940][3.70:155](),[3.155][3.2021:2065](),[3.2021][3.2021:2065]()
    Strings argv({"hydra-notify", "build", std::to_string(item.first)});
    for (auto id : item.second)
    [3.1940]
    [3.156]
    Strings argv({"hydra-notify", item.type == NotificationItem::Type::Started ? "build-started" : "build-finished", std::to_string(item.id)});
    for (auto id : item.dependentIds)
  • replacement in src/hydra-queue-runner/hydra-queue-runner.cc at line 499
    [3.2464][3.2464:2505]()
    % res % item.first);
    [3.2464]
    [3.2505]
    % res % item.id);
  • replacement in src/hydra-queue-runner/state.hh at line 321
    [3.6498][3.6498:6569]()
    typedef std::pair<BuildID, std::vector<BuildID>> NotificationItem;
    [3.6498]
    [2.2097]
    struct NotificationItem
    {
    enum class Type : char {
    Started,
    Finished
    };
    Type type;
    BuildID id;
    std::vector<BuildID> dependentIds;
    };
  • edit in src/lib/Hydra/Helper/PluginHooks.pm at line 8
    [16.414]
    [16.414]
    notifyBuildStarted
  • edit in src/lib/Hydra/Helper/PluginHooks.pm at line 11
    [16.441]
    [16.441]
    sub notifyBuildStarted {
    my ($plugins, $build) = @_;
    foreach my $plugin (@{$plugins}) {
    eval {
    $plugin->buildStarted($build);
    };
    if ($@) {
    print STDERR "$plugin->buildStarted: $@\n":
    }
    }
    }
  • edit in src/lib/Hydra/Plugin.pm at line 23
    [17.6015]
    [17.6078]
    # Called when build $build has started.
    sub buildStarted {
    my ($self, $build) = @_;
    }
  • replacement in src/script/hydra-notify at line 18
    [3.3327][3.3327:3412]()
    my $cmd = shift @ARGV or die "Syntax: hydra-notify build BUILD-ID [BUILD-IDs...]\n";
    [3.3327]
    [3.3412]
    my $cmd = shift @ARGV or die "Syntax: hydra-notify CMD BUILD-ID [BUILD-IDs...]\n";
  • replacement in src/script/hydra-notify at line 20
    [3.3413][3.3413:3581]()
    if ($cmd eq "build") {
    my $buildId = shift @ARGV or die;
    my $build = $db->resultset('Builds')->find($buildId)
    or die "build $buildId does not exist\n";
    [3.3413]
    [3.3581]
    my $buildId = shift @ARGV or die;
    my $build = $db->resultset('Builds')->find($buildId)
    or die "build $buildId does not exist\n";
    if ($cmd eq "build-finished") {
  • edit in src/script/hydra-notify at line 31
    [3.3830]
    [3.3830]
    } elsif ($cmd eq "build-started") {
    notifyBuildStarted(\@plugins, $build);