summaryrefslogtreecommitdiffstats
path: root/kick_pifr.php
blob: b472acde68bbfaa31d0c512d4754010921e400c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

ini_set('display_errors', TRUE);

include(DRUPAL_ROOT . '/includes/xmlrpc.inc');

// Need to trim whitespace, or the key doesn't match up to a client
$key = trim(file_get_contents('key.txt'));

  $batch = array(
    'branches' => array(),
    'files' => array(),
    'projects' => array(),
  );

  $batch['projects'][] = array(
    'client_identifier' => 3060,
    'name' => 'Drupal core (security testing)',
    'repository_type' => 'git',
    'repository_url' => 'git://git.drupal.org/project/drupal.git',
    'link' => 'http://code.example.com',
  );

  $batch['branches'][] = array(
    // Project identifier represents the Project NID on drupal.org
    'project_identifier' => 3060,
    // Client identifier represents the Release NID on drupal.org
    //'client_identifier' => 572834,      // 8.x-dev
    'client_identifier' => 156281,        // 7.x-dev
    //'client_identifier' => 97386,       // 6.x-dev
    // VCS identifier represents the actual branch / tag name to checkout
    'vcs_identifier' => '7.x',
    'plugin_argument' => array(
      // 'drupal.core.version' => '8',
      'drupal.core.version' => '7',
      // 'drupal.core.version' => '6',
    ),
    'test' => FALSE,
    'link' => 'http://code.example.com/example-branch',
  );

  $batch['files'][] = array(
    // Branch identifier is the same as 'client identifier' above
    'branch_identifier' => 156281,
    // Client identifier is a unique identifier for this file (fid)
    'client_identifier' => 19487298,
    'file_url' => 'http://drupal.org/files/dropbutton-1799498-45.patch',
  );

echo "Sending request to http://qa.staging.devdrupal.org/xmlrpc.php\n";
// Need to prefix http auth username/password for staging
// Modified to use D6 xmlrpc function signature
if ($response = xmlrpc('http://drupal:drupal@qa.staging.devdrupal.org/xmlrpc.php', 'pifr.queue', $key, $batch)) {

  foreach (array_merge($response['branches'], $response['files']) as $test) {
    $tests[] = l('#' . $test, 'pifr/test/' . $test);
  }

  if ($tests) {
    echo theme('item_list', $tests);
  }
  else {
    echo 'No test(s) queued. The tests are most likely already queued.';
  }
}
else {
  echo("XMLRPC Call Failed");
}

// The response is something like this,
// http://qa.drupal.org/pifr/test/377058
// Array
// (
//     [branches] => Array
//         (
//             [716] => 377053
//         )
//
//     [files] => Array
//         (
//             [19487298] => 377058
//         )
//
// )