Initial implementation CI environments

This commit is contained in:
Stepan Strelets 2017-03-23 15:53:24 +03:00 committed by Dmitry Khomutov
commit 047cedaab3
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
21 changed files with 850 additions and 42 deletions

View file

@ -22,18 +22,26 @@
</tr>
<tr>
<th><?php Lang::out('branch'); ?></th>
<th><?php Lang::out('environment'); ?></th>
<td style="text-align: right">
<a target="_blank" href="<?php print $build->getBranchLink(); ?>">
<span class="label label-default"><?php print $build->getBranch(); ?></span>
</a>
<span class="label label-default"><?php print $build->getEnvironment(); ?></span>
</td>
</tr>
<tr>
<th><?php Lang::out('duration'); ?></th>
<td style="text-align: right" class="build-duration duration">
<?php print $build->getDuration(); ?> <?= Lang::get('seconds'); ?>
<th><?php Lang::out('merged_branches'); ?></th>
<td style="text-align: right">
<span class="label label-default"><?php print $build->getBranch() ?></span>
+ <?php
$branches = $build->getExtra('branches');
if (!empty($branches)) {
foreach($branches as $branch) {
?><span class="label label-default"><?php print $branch ?></span><?php
}
} else {
?>&mdash;<?php
}
?>
</td>
</tr>
</table>
@ -51,6 +59,15 @@
<div class="box-body no-padding">
<table class="table">
<tr>
<th><?php Lang::out('branch'); ?></th>
<td style="text-align: right">
<a target="_blank" href="<?php print $build->getBranchLink(); ?>">
<span class="label label-default"><?php print $build->getBranch(); ?></span>
</a>
</td>
</tr>
<tr>
<th><?php Lang::out('commit'); ?></th>
<td style="text-align: right">
@ -107,6 +124,13 @@
<?php print $build->getFinished() ? $build->getFinished()->format('Y-m-d H:i:s') : ''; ?>
</td>
</tr>
<tr>
<th><?php Lang::out('duration'); ?></th>
<td style="text-align: right" class="build-duration duration">
<?php print $build->getDuration(); ?> <?= Lang::get('seconds'); ?>
</td>
</tr>
</table>
</div>
</div>

View file

@ -4,6 +4,9 @@
<?php
foreach ($builds as $build):
$environment = $build->getEnvironment();
$branches = $build->getExtra('branches');
switch ($build->getStatus()) {
case \PHPCensor\Model\Build::STATUS_PENDING:
$updated = $build->getCreated();
@ -60,6 +63,7 @@
<a href="<?php print APP_URL; ?>project/view/<?php print $build->getProjectId(); ?>">
<?php print $build->getProject()->getTitle(); ?>
</a>
<span><?php print $environment; ?></span>
-
<a href="<?php print APP_URL; ?>build/view/<?php print $build->getId(); ?>">
Build #<?php print $build->getId(); ?>
@ -69,7 +73,8 @@
</h3>
<div class="timeline-body">
<a href="<?php echo $build->getBranchLink();?>"><?php echo $build->getProject()->getBranch(); ?></a> -
<a href="<?php echo $build->getBranchLink();?>"><?php echo $build->getProject()->getBranch(); ?></a>
<?php print $branches ? ' + '.implode(', ', $branches) : ''; ?> -
<?php
if ($build->getCommitId() !== 'Manual') {
print sprintf(

View file

@ -30,6 +30,9 @@
<?php
foreach ($builds as $build):
$environment = $build->getEnvironment();
$branches = $build->getExtra('branches');
switch ($build->getStatus()) {
case \PHPCensor\Model\Build::STATUS_PENDING:
$updated = $build->getCreated();
@ -86,6 +89,7 @@
<a href="<?php print APP_URL; ?>project/view/<?php print $build->getProjectId(); ?>">
<?php print $build->getProject()->getTitle(); ?>
</a>
<span><?php print $environment; ?></span>
-
<a href="<?php print APP_URL; ?>build/view/<?php print $build->getId(); ?>">
Build #<?php print $build->getId(); ?>
@ -95,7 +99,8 @@
</h3>
<div class="timeline-body">
<a href="<?php echo $build->getBranchLink();?>"><?php echo $build->getProject()->getBranch(); ?></a> -
<a href="<?php echo $build->getBranchLink();?>"><?php echo $build->getProject()->getBranch(); ?></a>
<?php print $branches ? ' + '.implode(', ', $branches) : ''; ?> -
<?php
if ($build->getCommitId() !== 'Manual') {
print sprintf(

View file

@ -36,6 +36,8 @@ switch($build->getStatus())
$status = Lang::get('failed');
break;
}
$branches = $build->getExtra('branches');
?>
<tr>
<td><a href="<?php echo APP_URL ?>build/view/<?php print $build->getId(); ?>">#<?php print str_pad($build->getId(), 6, '0', STR_PAD_LEFT); ?></a></td>
@ -55,7 +57,11 @@ switch($build->getStatus())
?>
</td>
<td><a href="<?php print $build->getBranchLink(); ?>" target="_blank"><?php print $build->getBranch(); ?></a></td>
<td><?php print $build->getEnvironment(); ?></td>
<td>
<a href="<?php print $build->getBranchLink(); ?>" target="_blank"><?php print $build->getBranch(); ?></a>
<?php print $branches ? ' + '.implode(', ', $branches) : ''; ?>
</td>
<td>
<span class='label label-<?php echo $subcls ?>'><?php echo $status ?></span>
</td>

View file

@ -8,6 +8,11 @@
lineWrapping: true,
lineNumbers: true
});
CodeMirror.fromTextArea(document.getElementById('element-environments'), {
mode: "yaml",
lineWrapping: true,
lineNumbers: true
});
setupProjectForm();
});

View file

@ -1,6 +1,7 @@
<?php use PHPCensor\Helper\Lang; ?>
<script>
var PROJECT_ID = <?php print $project->getId(); ?>;
var PROJECT_ENVIRONMENT = '<?php print $environment; ?>';
var PROJECT_BRANCH = '<?php print $branch; ?>';
var PER_PAGE = <?php print $perPage; ?>;
</script>
@ -17,32 +18,97 @@
<div class="pull-right btn-group">
<?php if (!$project->getArchived()): ?>
<?php if($this->User()->getIsAdmin()): ?>
<a class="btn btn-danger" href="<?= APP_URL . 'project/build/' . $project->getId(); ?><?= !empty($branch) ? '/' . urlencode($branch) : '' ?>?debug=1">
<?php Lang::out('build_now_debug'); ?>
</a>
<div class="btn-group build-btn">
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown">
<?php Lang::out('build_now_debug'); ?>&nbsp;&nbsp;<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<?php if(!empty($environments)): ?>
<?php foreach ($environments as $curenvironment) : ?>
<li <?php echo ($curenvironment == $environment) ? 'class="active"' : ''?>>
<a href="<?php echo APP_URL ?>project/build/<?php print $project->getId(); ?>/environment/<?php echo urlencode($curenvironment) ?>?debug=1">
<i class="fa fa-cog"></i><?php echo $curenvironment ?>
</a>
</li>
<?php endforeach; ?>
<li class="divider"></li>
<?php endif; ?>
<?php foreach ($branches as $curbranch) : ?>
<li <?php echo ($curbranch == $branch) ? 'class="active"' : ''?>>
<a href="<?php echo APP_URL ?>project/build/<?php print $project->getId(); ?>/branch/<?php echo urlencode($curbranch) ?>">
<i class="fa fa-code-fork"></i><?php echo $curbranch ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<a class="btn btn-success" href="<?= APP_URL . 'project/build/' . $project->getId(); ?><?= !empty($branch) ? '/' . urlencode($branch) : '' ?>">
<?php Lang::out('build_now'); ?>
</a>
<div class="btn-group build-btn">
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
<?php Lang::out('build_now'); ?>&nbsp;&nbsp;<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<?php if(!empty($environments)): ?>
<?php foreach ($environments as $curenvironment) : ?>
<li <?php echo ($curenvironment == $environment) ? 'class="active"' : ''?>>
<a href="<?php echo APP_URL ?>project/build/<?php print $project->getId(); ?>/environment/<?php echo urlencode($curenvironment) ?>">
<i class="fa fa-cog"></i><?php echo $curenvironment ?>
</a>
</li>
<?php endforeach; ?>
<li class="divider"></li>
<?php endif; ?>
<?php foreach ($branches as $curbranch) : ?>
<li <?php echo ($curbranch == $branch) ? 'class="active"' : ''?>>
<a href="<?php echo APP_URL ?>project/build/<?php print $project->getId(); ?>/branch/<?php echo urlencode($curbranch) ?>">
<i class="fa fa-code-fork"></i><?php echo $curbranch ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<div class="btn-group branch-btn pull-right">
<div class="btn-group environment-btn pull-right">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<?php print !empty($branch) ? Lang::get('branch_x', $branch) : Lang::get('branch'); ?>&nbsp;&nbsp;<span class="caret"></span>
<?php
if (!empty($environment)) {
print Lang::get('environment_x', $environment);
} elseif (!empty($branch)) {
print Lang::get('branch_x', $branch);
} else {
print Lang::get('All');
}
?>&nbsp;&nbsp;<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="<?php echo APP_URL ?>project/view/<?php print $project->getId(); ?>"><?php Lang::out('all'); ?></a></li>
<li class="divider"></li>
<?php if(!empty($environments)): ?>
<?php foreach ($environments as $curenvironment) : ?>
<li <?php echo ($curenvironment == $environment) ? 'class="active"' : ''?>>
<a href="<?php echo APP_URL ?>project/view/<?php print $project->getId(); ?>?environment=<?php echo urlencode($curenvironment) ?>">
<i class="fa fa-cog"></i><?php echo $curenvironment ?>
</a>
</li>
<?php endforeach; ?>
<li class="divider"></li>
<?php endif; ?>
<?php foreach ($branches as $curbranch) : ?>
<li <?php echo ($curbranch == $branch) ? 'class="active"' : ''?>>
<a href="<?php echo APP_URL ?>project/view/<?php print $project->getId(); ?>?branch=<?php echo urlencode($curbranch) ?>">
<?php echo $curbranch ?>
<i class="fa fa-code-fork"></i><?php echo $curbranch ?>
</a>
</li>
<?php endforeach; ?>
<li class="divider"></li>
<li><a href="<?php echo APP_URL ?>project/view/<?php print $project->getId(); ?>"><?php Lang::out('all_branches'); ?></a></li>
</ul>
</div>
</div>
@ -61,6 +127,7 @@
<th><?php Lang::out('id'); ?></th>
<th><?php Lang::out('date'); ?></th>
<th class="hidden-md hidden-sm hidden-xs"><?php Lang::out('commit'); ?></th>
<th><?php Lang::out('environment'); ?></th>
<th><?php Lang::out('branch'); ?></th>
<th><?php Lang::out('status'); ?></th>
<th><?php Lang::out('duration'); ?></th>