diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-10-05 20:36:37 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-10-05 20:36:37 +0300 |
commit | 1ae3f85a195c2e01b6852e65ad7eee740ffdb221 (patch) | |
tree | 8340379fd938debfea408853ba32d163d029697c | |
parent | 16e832ebc0cb0e8fb95d8b02eeceff00dde9215c (diff) | |
download | gitlab-ci-1ae3f85a195c2e01b6852e65ad7eee740ffdb221.tar.gz |
Build page. Status methods for build
-rw-r--r-- | app.rb | 7 | ||||
-rw-r--r-- | lib/build.rb | 28 | ||||
-rw-r--r-- | lib/helper.rb | 14 | ||||
-rw-r--r-- | lib/project.rb | 2 | ||||
-rw-r--r-- | lib/runner.rb | 7 | ||||
-rw-r--r-- | public/custom.css | 5 | ||||
-rw-r--r-- | views/build.haml | 28 | ||||
-rw-r--r-- | views/project.haml | 24 |
8 files changed, 92 insertions, 23 deletions
@@ -64,6 +64,13 @@ class GitlabCi < Sinatra::Base haml :edit end + get '/builds/:id' do + @build = Build.find(params[:id]) + @project = @build.project + + haml :build + end + post '/projects' do @project = Project.new(params[:project]) diff --git a/lib/build.rb b/lib/build.rb index b6a4377..c004425 100644 --- a/lib/build.rb +++ b/lib/build.rb @@ -1,3 +1,31 @@ class Build < ActiveRecord::Base belongs_to :project + + def failed? + status == 'fail' + end + + def success? + status == 'success' + end + + def running? + status == 'running' + end + + def success! + update_status 'success' + end + + def fail! + update_status 'fail' + end + + def running! + update_status 'running' + end + + def update_status status + update_attributes(status: status) + end end diff --git a/lib/helper.rb b/lib/helper.rb index f4b05ad..9660f21 100644 --- a/lib/helper.rb +++ b/lib/helper.rb @@ -10,11 +10,21 @@ module Helper end def build_status_class build - if build.status == 'success' + if build.success? 'label-success' - elsif build.status == 'fail' + elsif build.failed? 'label-important' else + 'label-inverse' + end + end + + def build_status_alert_class build + if build.success? + 'alert-success' + elsif build.failed? + 'alert-error' + else '' end end diff --git a/lib/project.rb b/lib/project.rb index 962b3c5..727246e 100644 --- a/lib/project.rb +++ b/lib/project.rb @@ -10,7 +10,7 @@ class Project < ActiveRecord::Base def register_build opts={} default_opts = { project_id: self.id, - status: 'runing' + status: 'running' } allowed_opts = {} diff --git a/lib/runner.rb b/lib/runner.rb index 557b596..bb76a2a 100644 --- a/lib/runner.rb +++ b/lib/runner.rb @@ -21,15 +21,12 @@ class Runner Dir.chdir(path) do commands.each_line do |line| unless command(line, path) - build.update_attributes(status: 'fail') + build.failed! end end end - build.update_attributes( - trace: @output, - status: 'success' - ) + build.success! end def command(cmd, path) diff --git a/public/custom.css b/public/custom.css index 8339a57..3104d09 100644 --- a/public/custom.css +++ b/public/custom.css @@ -1,5 +1,6 @@ body { color:#666; + margin-bottom:10px; } .right { @@ -34,3 +35,7 @@ pre.trace { color:#fff; } .navbar .navbar-inner { border-radius: 0; } + +.builds .build.alert{ + margin-bottom: 6px; +} diff --git a/views/build.haml b/views/build.haml new file mode 100644 index 0000000..eadeb2b --- /dev/null +++ b/views/build.haml @@ -0,0 +1,28 @@ +%h3 + Project: #{@project.name} + .right + %a.btn.btn-small{href: project_path(@project)} Builds + %a.btn.btn-small{href: run_project_path(@project)} Run + %a.btn.btn-small{href: edit_project_path(@project)} + %i.icon-edit + Edit Project + +.alert{class: build_status_alert_class(@build)} + %h4 + Build ##{@build.id} + %small= @build.commit_ref + .right + %span= @build.updated_at.stamp('19:00 Aug 27') + = @build.status +.clearfix +%pre.trace + = preserve do + = @build.trace + +%br +.right + %a.btn.btn-small{href: project_path(@project)} Builds + %a.btn.btn-small{href: run_project_path(@project)} Run + %a.btn.btn-small{href: edit_project_path(@project)} + %i.icon-edit + Edit Project diff --git a/views/project.haml b/views/project.haml index f8bd1a0..c5ac165 100644 --- a/views/project.haml +++ b/views/project.haml @@ -5,22 +5,16 @@ %a.btn.btn-small{href: edit_project_path(@project)} %i.icon-edit Edit -#accordion2.accordion +.builds - @builds.each do |build| - .accordion-group - .accordion-heading - %a.accordion-toggle{"data-parent" => "#accordion2", "data-toggle" => "collapse", :href => "#build_#{build.id}"} - %span.label{class: build_status_class(build)}= build.status - → - %strong Build #{build.id} - = build.commit_ref - .right - %span= build.updated_at.stamp('19:00 Aug 27') - .accordion-body.collapse{id: "build_#{build.id}"} - .accordion-inner - %pre.trace - = preserve do - = build.trace + .build.alert{class: build_status_alert_class(build)} + %span.label{class: build_status_class(build)}= build.status + → + %a{href: "/builds/#{build.id}"} + %strong Build #{build.id} + %small= build.commit_ref + .right + %span= build.updated_at.stamp('19:00 Aug 27') = will_paginate @builds - if @builds.empty? |