Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add build in progress status in build page #607

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class ViewController {
final binding = new HashMap(20)
binding.build_id = result.buildId
binding.build_success = result.succeeded()
binding.build_failed = result.exitStatus && result.exitStatus != 0
binding.build_in_progress = result.exitStatus == null
binding.build_exit_status = result.exitStatus
binding.build_user = (result.userName ?: '-') + " (ip: ${result.requestIp})"
binding.build_time = formatTimestamp(result.startTime, result.offsetId) ?: '-'
Expand Down
89 changes: 62 additions & 27 deletions src/main/resources/io/seqera/wave/build-view.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<html>
<head>
<head>
{{#if build_in_progress}}
<meta http-equiv="refresh" content="5">
{{/if}}
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand All @@ -16,17 +19,50 @@
</div>

{{#if build_success}}
<div style="color: #3c763d; background-color: #dff0d8; padding: 15px; border: 1px solid transparent; border-radius: 4px;">
<h4 style="margin-top:0; color: inherit;">
Container build completed successfully!
</h4>
</div>
{{else}}
<div style="color: #a94442; background-color: #f2dede; padding: 15px; border: 1px solid transparent; border-radius: 4px;">
<h4 style="margin-top:0; color: inherit;">
Container build failed
</h4>
</div>
<div style="color: #3c763d; background-color: #dff0d8; padding: 15px; border: 1px solid transparent; border-radius: 4px;">
<h4 style="margin-top:0; color: inherit;">
Container build completed successfully!
</h4>
</div>
{{else build_failed}}
<div style="color: #a94442; background-color: #f2dede; padding: 15px; border: 1px solid transparent; border-radius: 4px;">
<h4 style="margin-top:0; color: inherit;">
Container build failed
</h4>
</div>
{{else build_in_progress}}
{{! build is not completed, show a spinning icon }}
<style>
.lds-dual-ring {
display: inline-block;
width: 50px;
height: 30px;
}
.lds-dual-ring:after {
content: " ";
display: block;
width: 20px;
height: 20px;
margin: 8px;
border-radius: 50%;
border: 6px solid #3c763d;
border-color: #3c763d transparent #3c763d transparent;
animation: lds-dual-ring 1.2s linear infinite;
}
@keyframes lds-dual-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
<div style="color: #3c763d; background-color: #dff0d8; padding: 15px; border: 1px solid transparent; border-radius: 4px;">
<h4 style="margin-top:0; color: inherit;">
<div class="lds-dual-ring"></div> Container build in progress
</h4>
</div>
{{/if}}

<h3>Summary</h3>
Expand Down Expand Up @@ -75,36 +111,35 @@
<td>Exit status</td>
<td>{{build_exit_status}}</td>
</tr>
{{#if scan_url}}
<tr>
<td>Security</td>
<td><a href="{{scan_url}}">Image scan report</a></td>
</tr>
{{/if}}
{{#if scan_url}}
<tr>
<td>Security</td>
<td><a href="{{scan_url}}">Image scan report</a></td>
</tr>
{{/if}}
</table>

<h3>Container file</h3>
<pre style="white-space: pre-wrap; overflow: visible; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px;">{{build_containerfile}}</pre>

{{#if build_condafile}}
<h3>Conda file</h3>
<pre style="white-space: pre-wrap; overflow: visible; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px;">{{build_condafile}}</pre>
<h3>Conda file</h3>
<pre style="white-space: pre-wrap; overflow: visible; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px;">{{build_condafile}}</pre>
{{/if}}

{{#if build_spackfile}}
<h3>Spack file</h3>
<pre style="white-space: pre-wrap; overflow: visible; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px;">{{build_spackfile}}</pre>
<h3>Spack file</h3>
<pre style="white-space: pre-wrap; overflow: visible; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px;">{{build_spackfile}}</pre>
{{/if}}

{{#if build_log_data}}
<h3>Build logs</h3>
<pre style="white-space: pre-wrap; overflow-x: auto; overflow-y: auto; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px;">{{build_log_data}}</pre>
{{#if build_log_truncated}}
<a href="{{build_log_url}}" download>Click here to download the complete build log</a>
{{/if}}
<h3>Build logs</h3>
<pre style="white-space: pre-wrap; overflow-x: auto; overflow-y: auto; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px;">{{build_log_data}}</pre>
{{#if build_log_truncated}}
<a href="{{build_log_url}}" download>Click here to download the complete build log</a>
{{/if}}
{{/if}}


<div class="footer" style="clear:both;width:100%;">
<hr class="footer-hr" style="height:0;overflow:visible;margin-top:30px;border:0;border-top:1px solid #eee;color:#999999;font-size:12px;line-height:18px;margin-bottom:30px;">
<img style="float:right; width: 150px;" src="/assets/seqera-logo.png">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class ViewControllerTest extends Specification {
binding.build_log_data == 'log content'
binding.build_log_truncated == false
binding.build_log_url == 'http://foo.com/v1alpha1/builds/12345/logs'
binding.build_success == true
binding.build_in_progress == false
binding.build_failed == false
}

def 'should render a build page' () {
Expand Down Expand Up @@ -228,4 +231,91 @@ class ViewControllerTest extends Specification {
then:
response.body().contains(token)
}

def 'should render in progress build page' () {
given:
def controller = new ViewController(serverUrl: 'http://foo.com', buildLogService: buildLogService)
and:
def record = new WaveBuildRecord(
buildId: '12345',
dockerFile: 'FROM foo',
condaFile: 'conda::foo',
spackFile: 'some-spack-recipe',
targetImage: 'docker.io/some:image',
userName: 'paolo',
userEmail: 'paolo@seqera.io',
userId: 100,
requestIp: '10.20.30.40',
startTime: Instant.now(),
offsetId: '+02:00',
duration: Duration.ofMinutes(1),
platform: 'linux/amd64' )
when:
def binding = controller.renderBuildView(record)
then:
1 * buildLogService.fetchLogString('12345') >> new BuildLogService.BuildLog('log content', false)
and:
binding.build_id == '12345'
binding.build_containerfile == 'FROM foo'
binding.build_condafile == 'conda::foo'
binding.build_image == 'docker.io/some:image'
binding.build_user == 'paolo (ip: 10.20.30.40)'
binding.build_platform == 'linux/amd64'
binding.build_exit_status == null
binding.build_platform == 'linux/amd64'
binding.build_containerfile == 'FROM foo'
binding.build_condafile == 'conda::foo'
binding.build_spackfile == 'some-spack-recipe'
binding.build_format == 'Docker'
binding.build_log_data == 'log content'
binding.build_log_truncated == false
binding.build_log_url == 'http://foo.com/v1alpha1/builds/12345/logs'
binding.build_success == false
binding.build_in_progress == true
binding.build_failed == false
}

def 'should render in progress build page' () {
given:
def controller = new ViewController(serverUrl: 'http://foo.com', buildLogService: buildLogService)
and:
def record = new WaveBuildRecord(
buildId: '12345',
dockerFile: 'FROM foo',
condaFile: 'conda::foo',
spackFile: 'some-spack-recipe',
targetImage: 'docker.io/some:image',
userName: 'paolo',
userEmail: 'paolo@seqera.io',
userId: 100,
requestIp: '10.20.30.40',
startTime: Instant.now(),
offsetId: '+02:00',
duration: Duration.ofMinutes(1),
exitStatus: 1,
platform: 'linux/amd64' )
when:
def binding = controller.renderBuildView(record)
then:
1 * buildLogService.fetchLogString('12345') >> new BuildLogService.BuildLog('log content', false)
and:
binding.build_id == '12345'
binding.build_containerfile == 'FROM foo'
binding.build_condafile == 'conda::foo'
binding.build_image == 'docker.io/some:image'
binding.build_user == 'paolo (ip: 10.20.30.40)'
binding.build_platform == 'linux/amd64'
binding.build_exit_status == 1
binding.build_platform == 'linux/amd64'
binding.build_containerfile == 'FROM foo'
binding.build_condafile == 'conda::foo'
binding.build_spackfile == 'some-spack-recipe'
binding.build_format == 'Docker'
binding.build_log_data == 'log content'
binding.build_log_truncated == false
binding.build_log_url == 'http://foo.com/v1alpha1/builds/12345/logs'
binding.build_success == false
binding.build_in_progress == false
binding.build_failed == true
}
}