Enable declarative projects.

[?]
Mar 11, 2016, 11:14 PM
6WRGCITDYP7JIBYP25QIWCHWRJWFPDP2D3TJS3WO3KUHQQJAWHMQC

Dependencies

  • [2] NS7SND6R hydra-evaluator: Send statistics to statsd
  • [3] DGHAIZTO Make cloning of jobsets work again.
  • [4] FCTX433O Add buildStarted plugin hook
  • [5] OK4P3AMK Remove the ability to add multiple jobset input alternatives
  • [6] BXHG3HYL When renaming a jobset, add a redirect from the old name
  • [7] 24BMQDZA Start of single-process hydra-queue-runner
  • [8] PCKLFRT5 Support push notification of repository changes
  • [9] T5BIOVJE Add support for tracking custom metrics
  • [10] X27GNHDV * Basic job info in the database.
  • [11] 7ECJWNVX Cleanup Project model
  • [12] W5OAZWPD Drop the errorMsg column in the Jobs table
  • [13] YU6CND7C Remove support for views
  • [14] BMSQD2ZH Indentation
  • [15] XJRJ4J7M Add user registration
  • [16] Y6AHH4TH Remove the logfile and logSize columns from the database
  • [17] HQGXL4MX Add validation for project and jobset names
  • [18] RPTSGIRC Eliminate duplicate getPreviousBuild functions
  • [19] LZVO64YG Merge in the first bits of the API work
  • [20] KSBB33RE Add a dashboard
  • [21] PCD3ZH6Z Partially revert 1c20cfdf2403feb78cef515faf15c04d5c9f17bd
  • [22] JAH3UPWA Support revision control systems via plugins
  • [*] 3HZY24CX * Make jobsets viewable under
  • [*] 4NTIBJ74 Implement DELETE for jobsets and use it in the web interface
  • [*] FPK5LF53 * Put the project-related actions in a separate controller. Put the
  • [*] ODNCGFQ5 * Improved the navigation bar: don't include all projects (since that
  • [*] 7UJ5YV4V * Provide a channel for each project containing all the latest
  • [*] OOQ2D3KC * Refactoring: move fetchInput out of hydra_scheduler into a separate
  • [*] OSVLMLCQ hydra: factored out build restart and
  • [*] VHV6GI4L Add a jobset eval action to restart all aborted/cancelled builds
  • [*] LBNVQXUB * Build the /build stuff in a separate controller.
  • [*] JM3DPYOM generated schema with new dbix class schema loader, grrrrrr
  • [*] V4RNHJNR * Add a link to each project's homepage. Suggested by karltk.
  • [*] SB2V735V Keep track of the database schema version
  • [*] JY7BXXOP Split viewing and editing a project
  • [*] 2G63HKCH Fix some wellformedness issues
  • [*] A6XVP6FE Make the hide/unhide actions a checkbox in the project settings
  • [*] D7PL2VWU Move more actions from the top bar
  • [*] 77BG3TYK Use c.req.captures
  • [*] 7YBYT2LQ
  • [*] N22GPKYT * Put info about logs / build products in the DB.
  • [*] ZDENAYQI * email notification of evaluation errors to project owner (if desired)
  • [*] OVR2RWBI hydra-evaluator: Always pick the jobset that hasn't been evaluated longest
  • [*] FDE3BJAP * Refactoring.
  • [*] IE2PRAQU hydra-queue-runner: Send build notifications
  • [*] KN3VYE5P * Cleaned up the foreign key constraints.
  • [*] D5QIOJGP * Move everything up one directory.

Change contents

  • edit in src/lib/Hydra/Controller/Jobset.pm at line 57
    [5.7955]
    [5.7955]
    if (length($c->stash->{project}->declfile)) {
    error($c, "can't modify jobset of declarative project", 403);
    }
  • edit in src/lib/Hydra/Controller/Jobset.pm at line 94
    [25.108]
    [25.108]
    if (length($c->stash->{project}->declfile)) {
    error($c, "can't modify jobset of declarative project", 403);
    }
  • edit in src/lib/Hydra/Controller/Project.pm at line 157
    [27.6175]
    [27.6175]
    , declfile => trim($c->stash->{params}->{declfile})
    , decltype => trim($c->stash->{params}->{decltype})
    , declvalue => trim($c->stash->{params}->{declvalue})
  • edit in src/lib/Hydra/Controller/Project.pm at line 161
    [27.6187]
    [28.49]
    if (length($project->declfile)) {
    $project->jobsets->update_or_create(
    { name=> ".jobsets"
    , nixexprinput => ""
    , nixexprpath => ""
    , emailoverride => ""
    , triggertime => time
    });
    }
  • replacement in src/lib/Hydra/Helper/AddBuilds.pm at line 25
    [5.624][5.19625:19660]()
    restartBuild getPrevJobsetEval
    [5.624]
    [5.156]
    restartBuild getPrevJobsetEval updateDeclarativeJobset
    handleDeclarativeJobsetBuild
  • edit in src/lib/Hydra/Helper/AddBuilds.pm at line 471
    [30.589]
    [31.667]
    sub updateDeclarativeJobset {
    my ($db, $project, $jobsetName, $declSpec) = @_;
    my @allowed_keys = qw(
    enabled
    hidden
    description
    nixexprinput
    nixexprpath
    checkinterval
    schedulingshares
    enableemail
    emailoverride
    keepnr
    );
    my %update = ( name => $jobsetName );
    foreach my $key (@allowed_keys) {
    $update{$key} = $declSpec->{$key};
    delete $declSpec->{$key};
    }
    txn_do($db, sub {
    my $jobset = $project->jobsets->update_or_create(\%update);
    $jobset->jobsetinputs->delete;
    while ((my $name, my $data) = each %{$declSpec->{"inputs"}}) {
    my $input = $jobset->jobsetinputs->create(
    { name => $name,
    type => $data->{type},
    emailresponsible => $data->{emailresponsible}
    });
    $input->jobsetinputalts->create({altnr => 0, value => $data->{value}});
    }
    delete $declSpec->{"inputs"};
    die "invalid keys in declarative specification file\n" if (%{$declSpec});
    });
    };
    sub handleDeclarativeJobsetBuild {
    my ($db, $project, $build) = @_;
    eval {
    my $id = $build->id;
    die "Declarative jobset build $id failed" unless $build->buildstatus == 0;
    my $declPath = ($build->buildoutputs)[0]->path;
    my $declText = read_file($declPath)
    or die "Couldn't read declarative specification file $declPath: $!";
    my $declSpec = decode_json($declText);
    txn_do($db, sub {
    my @kept = keys %$declSpec;
    push @kept, ".jobsets";
    $project->jobsets->search({ name => { "not in" => \@kept } })->update({ enabled => 0, hidden => 1 });
    while ((my $jobsetName, my $spec) = each %$declSpec) {
    updateDeclarativeJobset($db, $project, $jobsetName, $spec);
    }
    });
    };
    $project->jobsets->find({ name => ".jobsets" })->update({ errormsg => $@, errortime => time, fetcherrormsg => undef })
    if defined $@;
    };
  • replacement in src/lib/Hydra/Helper/CatalystUtils.pm at line 267
    [5.1700][5.1700:1793]()
    $s =~ /^($projectNameRE):($jobsetNameRE)$/ or die "invalid jobset specifier ‘$s’\n";
    [5.1700]
    [5.1793]
    $s =~ /^($projectNameRE):(\.?$jobsetNameRE)$/ or die "invalid jobset specifier ‘$s’\n";
  • edit in src/lib/Hydra/Schema/Projects.pm at line 75
    [33.20433]
    [33.20447]
    =head2 declfile
  • edit in src/lib/Hydra/Schema/Projects.pm at line 78
    [33.20448]
    [33.20448]
    data_type: 'text'
    is_nullable: 1
    =head2 decltype
    data_type: 'text'
    is_nullable: 1
    =head2 declvalue
    data_type: 'text'
    is_nullable: 1
  • edit in src/lib/Hydra/Schema/Projects.pm at line 107
    [34.1710]
    [35.24322]
    { data_type => "text", is_nullable => 1 },
    "declfile",
    { data_type => "text", is_nullable => 1 },
    "decltype",
    { data_type => "text", is_nullable => 1 },
    "declvalue",
  • replacement in src/lib/Hydra/Schema/Projects.pm at line 306
    [5.7308][5.7749:7891]()
    # Created by DBIx::Class::Schema::Loader v0.07043 @ 2015-07-30 16:52:20
    # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:67kWIE0IGmEJTvOIATAKaw
    [5.7308]
    [5.171]
    # Created by DBIx::Class::Schema::Loader v0.07043 @ 2016-03-11 10:39:17
    # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1ats3brIVhRTWLToIYSoaQ
  • edit in src/root/edit-project.tt at line 53
    [37.3095]
    [38.2117]
    </div>
    </div>
    <div class="control-group">
    <label class="control-label">Declarative spec file</label>
    <div class="controls">
    <div class="input-append">
    <input type="text" class="span3" name="declfile" [% HTML.attributes(value => project.declfile) %]/>
    </div>
    <span class="help-inline">(Leave blank for non-declarative project configuration)</span>
  • edit in src/root/edit-project.tt at line 66
    [36.1480]
    [38.2142]
    <div class="control-group">
    <label class="control-label">Declarative input type</label>
    <div class="controls">
    [% INCLUDE renderSelection param="decltype" options=inputTypes edit=1 curValue=project.decltype %]
    value
    <input style="width: 70%" type="text" [% HTML.attributes(value => project.declvalue, name => "declvalue") %]/>
    </div>
    </div>
  • edit in src/root/jobset.tt at line 52
    [39.283]
    [40.0]
    [% UNLESS project.declfile %]
  • edit in src/root/jobset.tt at line 56
    [3.222]
    [25.1020]
    [% END %]
  • edit in src/root/project.tt at line 14
    [25.1993]
    [40.542]
    [% UNLESS project.declfile %]
  • edit in src/root/project.tt at line 16
    [40.695]
    [40.695]
    [% END %]
  • edit in src/script/hydra-evaluator at line 17
    [2.67]
    [43.418]
    use JSON;
    use File::Slurp;
  • edit in src/script/hydra-evaluator at line 105
    [44.171]
    [45.3668]
    my $jobsetsJobset = length($project->declfile) && $jobset->name eq ".jobsets";
    if ($jobsetsJobset) {
    my @declInputs = fetchInput($plugins, $db, $project, $jobset, "decl", $project->decltype, $project->declvalue, 0);
    my $declInput = @declInputs[0] or die "cannot find the input containing the declarative project specification\n";
    die "multiple alternatives for the input containing the declarative project specificaiton are not supported\n"
    if scalar @declInputs != 1;
    my $declFile = $declInput->{storePath} . "/" . $project->declfile;
    my $declText = read_file($declFile)
    or die "Couldn't read declarative specification file $declFile: $!\n";
    my $declSpec;
    eval {
    $declSpec = decode_json($declText);
    };
    die "Declarative specification file $declFile not valid JSON: $@\n" if $@;
    updateDeclarativeJobset($db, $project, ".jobsets", $declSpec);
    $jobset->discard_changes;
    }
  • edit in src/script/hydra-evaluator at line 165
    [2.586]
    [2.586]
    if ($jobsetsJobset) {
    my @keys = keys %$jobs;
    die "The .jobsets jobset must only have a single job named 'jobsets'"
    unless (scalar @keys) == 1 && $keys[0] eq "jobsets";
    }
  • edit in src/script/hydra-notify at line 8
    [46.3128]
    [46.3128]
    use Hydra::Helper::AddBuilds;
  • edit in src/script/hydra-notify at line 25
    [4.1823]
    [46.3581]
    my $project = $build->project;
    my $jobset = $build->jobset;
    if (length($project->declfile) && $jobset->name eq ".jobsets" && $build->iscurrent) {
    handleDeclarativeJobsetBuild($db, $project, $build);
    }
  • edit in src/sql/hydra.sql at line 33
    [47.4689]
    [47.4689]
    declfile text, -- File containing declarative jobset specification
    decltype text, -- Type of the input containing declarative jobset specification
    declvalue text, -- Value of the input containing declarative jobset specification
  • file addition: upgrade-48.sql (----------)
    [48.3004]
    -- Add declarative fields to Projects
    alter table Projects add column declfile text;
    alter table Projects add column decltype text;
    alter table Projects add column declvalue text;