Skip to content

Instantly share code, notes, and snippets.

@petehamilton
Last active March 31, 2020 18:18
Show Gist options
  • Select an option

  • Save petehamilton/5494590 to your computer and use it in GitHub Desktop.

Select an option

Save petehamilton/5494590 to your computer and use it in GitHub Desktop.

Revisions

  1. petehamilton revised this gist Mar 7, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion circle_ci_list.scss
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ $background-pending-color: #47bbb3;
    $title-color: rgba(255, 255, 255, 1);
    $label-color: rgba(255, 255, 255, 0.7);

    .widget.widget-circle-ci_list{
    .widget.widget-circle-ci-list{

    background-color: $background-color;
    padding: 0px;
  2. petehamilton revised this gist Aug 30, 2013. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -17,3 +17,5 @@ OR `dashing install 5494590`
    Then copy the CircleCI logo below into your assets folder

    ![screen shot 2013-05-01 at 11 14 01](https://f.cloud.github.com/assets/510845/448488/2c0b0012-b248-11e2-9c8a-a9382e007785.png)

    There is also another version for displaying one tile per project which you can see [here](https://gist.github.com/petehamilton/5494978)
  3. petehamilton revised this gist Aug 30, 2013. 3 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -14,6 +14,6 @@ Then:

    OR `dashing install 5494590`

    Then copy the [CircleCI Logo](https://f.cloud.github.com/assets/510845/448516/6e8d2842-b249-11e2-91b6-9a2ffcd08bb0.png into `assets/images`) into your assets folder
    Then copy the CircleCI logo below into your assets folder

    ![screen shot 2013-05-01 at 11 14 01](https://f.cloud.github.com/assets/510845/448488/2c0b0012-b248-11e2-9c8a-a9382e007785.png)
    2 changes: 1 addition & 1 deletion circle_ci_list.html
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    <h1 class="title" data-bind="title"></h1>

    <img class="background" src="/assets/circle-ci-logo.png">
    <img class="background" src="/assets/logo-circle-ci.png">

    <ul class="items list-nostyle">
    <li class="item" data-foreach-item="items" data-bind-class="item.widget_class">
    Binary file added logo-circle-ci.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  4. Peter Hamilton revised this gist May 21, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,7 @@

    - Get a Circle API Token from your [Account Dashboard](https://circleci.com/account/api) and set it in your environment as `CIRCLE_CI_AUTH_TOKEN`
    - Add the `httparty` to your Gemfile and run `bundle install`

    Then:

    1. Copy the below coffee/scss/html files into a widget folder named `circle_ci_list`
  5. Peter Hamilton revised this gist May 21, 2013. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -4,10 +4,9 @@

    ## Usage

    Get a Circle API Token from your [Account Dashboard](https://circleci.com/account/api) and set it in your environment as `CIRCLE_CI_AUTH_TOKEN`

    Add the `httparty` to your Gemfile and run `bundle install`

    - Get a Circle API Token from your [Account Dashboard](https://circleci.com/account/api) and set it in your environment as `CIRCLE_CI_AUTH_TOKEN`
    - Add the `httparty` to your Gemfile and run `bundle install`
    Then:

    1. Copy the below coffee/scss/html files into a widget folder named `circle_ci_list`
    2. Copy the `circle_ci_list.rb` file into the `jobs` folder
  6. Peter Hamilton revised this gist May 21, 2013. 2 changed files with 5 additions and 2 deletions.
    3 changes: 3 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,9 @@

    Get a Circle API Token from your [Account Dashboard](https://circleci.com/account/api) and set it in your environment as `CIRCLE_CI_AUTH_TOKEN`

    Add the `httparty` to your Gemfile and run `bundle install`


    1. Copy the below coffee/scss/html files into a widget folder named `circle_ci_list`
    2. Copy the `circle_ci_list.rb` file into the `jobs` folder

    4 changes: 2 additions & 2 deletions circle_ci_list.rb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    require 'httparty'
    require 'digest/md5'

    PROJECTS = [
    projects = [
    { user: 'MY_GITHUB_USER_OR_ORG', repo: 'XXX', branch: 'master' },
    { user: 'MY_GITHUB_USER_OR_ORG', repo: 'YYY', branch: 'dev' },
    ]
    @@ -36,6 +36,6 @@ def update_builds(project, auth_token)
    end

    SCHEDULER.every '10s', :first_in => 0 do
    items = PROJECTS.map{ |p| update_builds(p, ENV['CIRCLE_CI_AUTH_TOKEN']) }
    items = projects.map{ |p| update_builds(p, ENV['CIRCLE_CI_AUTH_TOKEN']) }
    send_event('circle-ci-list', { items: items })
    end
  7. Peter Hamilton revised this gist May 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,6 @@ Get a Circle API Token from your [Account Dashboard](https://circleci.com/accoun

    OR `dashing install 5494590`

    Then copy the [CircleCI Logo](https://f.cloud.github.com/assets/510845/448516/6e8d2842-b249-11e2-91b6-9a2ffcd08bb0.png into `assets/images`)
    Then copy the [CircleCI Logo](https://f.cloud.github.com/assets/510845/448516/6e8d2842-b249-11e2-91b6-9a2ffcd08bb0.png into `assets/images`) into your assets folder

    ![screen shot 2013-05-01 at 11 14 01](https://f.cloud.github.com/assets/510845/448488/2c0b0012-b248-11e2-9c8a-a9382e007785.png)
  8. Peter Hamilton revised this gist May 1, 2013. 1 changed file with 2 additions and 8 deletions.
    10 changes: 2 additions & 8 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -6,17 +6,11 @@

    Get a Circle API Token from your [Account Dashboard](https://circleci.com/account/api) and set it in your environment as `CIRCLE_CI_AUTH_TOKEN`

    THEN

    1. Copy the below coffee/scss/html files into a widget folder named `circle_ci_list`
    2. Copy the `circle_ci_list.rb` file into the `jobs` folder

    OR

    1. `dashing install 5494590`

    FINALLY
    OR `dashing install 5494590`

    Copy the [CircleCI Logo](https://f.cloud.github.com/assets/510845/448516/6e8d2842-b249-11e2-91b6-9a2ffcd08bb0.png into `assets/images`)
    Then copy the [CircleCI Logo](https://f.cloud.github.com/assets/510845/448516/6e8d2842-b249-11e2-91b6-9a2ffcd08bb0.png into `assets/images`)

    ![screen shot 2013-05-01 at 11 14 01](https://f.cloud.github.com/assets/510845/448488/2c0b0012-b248-11e2-9c8a-a9382e007785.png)
  9. Peter Hamilton revised this gist May 1, 2013. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion circle_ci_list.scss
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,6 @@ $background-pending-color: #47bbb3;

    $title-color: rgba(255, 255, 255, 1);
    $label-color: rgba(255, 255, 255, 0.7);
    $moreinfo-color: rgba(255, 255, 255, 0.7);

    .widget.widget-circle-ci_list{

  10. Peter Hamilton revised this gist May 1, 2013. 1 changed file with 92 additions and 0 deletions.
    92 changes: 92 additions & 0 deletions circle_ci_list.scss
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,92 @@
    $value-color: #FFF;
    $background-color: #444;
    $background-error-color: #A31F1F;
    $background-passed-color: #8fb347;
    $background-pending-color: #47bbb3;

    $title-color: rgba(255, 255, 255, 1);
    $label-color: rgba(255, 255, 255, 0.7);
    $moreinfo-color: rgba(255, 255, 255, 0.7);

    .widget.widget-circle-ci_list{

    background-color: $background-color;
    padding: 0px;
    vertical-align: top;

    img.background {
    width: 100% !important;
    position: absolute;
    left: 0;
    top: 30px;
    opacity: 0.05;
    }

    .title {
    color: $title-color;
    }

    ol, ul {
    margin: 0px;
    text-align: left;
    color: $label-color;
    }

    ol {
    list-style-position: inside;
    }

    li {
    margin-bottom: 5px;
    }

    .list-nostyle {
    }

    .items{
    list-style: none;

    li {
    margin-top: 5px;

    &.failed {
    background-color: $background-error-color;
    }

    &.pending {
    background-color: $background-pending-color;
    }

    &.passed {
    background-color: $background-passed-color;
    }

    .label {
    display: block;
    color: $label-color;
    font-size: 20px;
    word-wrap: break-word;

    &.repo {
    float: left;
    text-align: left;
    padding: 5px 0px 5px 10px;
    }

    &.branch {
    float: left;
    text-align: left;
    padding-top: 10px;
    font-size: 14px;
    padding: 11px 0px 5px 5px;
    }
    }

    .avatar {
    float: right;
    text-align: right;
    width: 40px;
    }
    }
    }
    }
  11. Peter Hamilton revised this gist May 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,6 @@ OR

    FINALLY

    Copy the CircleCI image from https://f.cloud.github.com/assets/510845/448516/6e8d2842-b249-11e2-91b6-9a2ffcd08bb0.png into `assets/images`
    Copy the [CircleCI Logo](https://f.cloud.github.com/assets/510845/448516/6e8d2842-b249-11e2-91b6-9a2ffcd08bb0.png into `assets/images`)

    ![screen shot 2013-05-01 at 11 14 01](https://f.cloud.github.com/assets/510845/448488/2c0b0012-b248-11e2-9c8a-a9382e007785.png)
  12. Peter Hamilton revised this gist May 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ## Description

    [Dashing](http://shopify.github.io/dashing/) widget to show the status of builds from CircleCI
    [Dashing](http://shopify.github.io/dashing/) widget to show the status of builds from CircleCI. Also shows the avatar of the person who is running/breaking/passing the current build.

    ## Usage

  13. Peter Hamilton revised this gist May 1, 2013. 1 changed file with 11 additions and 7 deletions.
    18 changes: 11 additions & 7 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -4,15 +4,19 @@

    ## Usage

    1. Get a Circle API Token from your [Account Dashboard](https://circleci.com/account/api) and set it in your environment as `CIRCLE_CI_AUTH_TOKEN`
    2. Copy the below coffee/scss/html files into a widget folder named `circle_ci_list`
    3. Copy the `circle_ci_list.rb` file into the `jobs` folder
    4. Copy the CircleCI image from https://f.cloud.github.com/assets/510845/448516/6e8d2842-b249-11e2-91b6-9a2ffcd08bb0.png into `assets/images`
    Get a Circle API Token from your [Account Dashboard](https://circleci.com/account/api) and set it in your environment as `CIRCLE_CI_AUTH_TOKEN`

    THEN

    1. Copy the below coffee/scss/html files into a widget folder named `circle_ci_list`
    2. Copy the `circle_ci_list.rb` file into the `jobs` folder

    OR

    1. Get a Circle API Token from your [Account Dashboard](https://circleci.com/account/api) and set it in your environment as `CIRCLE_CI_AUTH_TOKEN`
    2. `dashing install 5494590`
    3. Copy the CircleCI image from https://f.cloud.github.com/assets/510845/448516/6e8d2842-b249-11e2-91b6-9a2ffcd08bb0.png into `assets/images`
    1. `dashing install 5494590`

    FINALLY

    Copy the CircleCI image from https://f.cloud.github.com/assets/510845/448516/6e8d2842-b249-11e2-91b6-9a2ffcd08bb0.png into `assets/images`

    ![screen shot 2013-05-01 at 11 14 01](https://f.cloud.github.com/assets/510845/448488/2c0b0012-b248-11e2-9c8a-a9382e007785.png)
  14. Peter Hamilton revised this gist May 1, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,7 @@
    4. Copy the CircleCI image from https://f.cloud.github.com/assets/510845/448516/6e8d2842-b249-11e2-91b6-9a2ffcd08bb0.png into `assets/images`

    OR

    1. Get a Circle API Token from your [Account Dashboard](https://circleci.com/account/api) and set it in your environment as `CIRCLE_CI_AUTH_TOKEN`
    2. `dashing install 5494590`
    3. Copy the CircleCI image from https://f.cloud.github.com/assets/510845/448516/6e8d2842-b249-11e2-91b6-9a2ffcd08bb0.png into `assets/images`
  15. Peter Hamilton revised this gist May 1, 2013. 1 changed file with 10 additions and 6 deletions.
    16 changes: 10 additions & 6 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,17 @@
    # CircleCI Build Statuses
    ## Description

    [Dashing](http://shopify.github.io/dashing/) widget to show the status of builds from CircleCI

    ## Usage

    1. Copy the below coffee/scss/html files into a widget folder named `circle_ci_list`
    2. Copy the `circle_ci_list.rb` file into the `jobs` folder
    1. Get a Circle API Token from your [Account Dashboard](https://circleci.com/account/api) and set it in your environment as `CIRCLE_CI_AUTH_TOKEN`
    2. Copy the below coffee/scss/html files into a widget folder named `circle_ci_list`
    3. Copy the `circle_ci_list.rb` file into the `jobs` folder
    4. Copy the CircleCI image from https://f.cloud.github.com/assets/510845/448516/6e8d2842-b249-11e2-91b6-9a2ffcd08bb0.png into `assets/images`

    OR
    1. Get a Circle API Token from your [Account Dashboard](https://circleci.com/account/api) and set it in your environment as `CIRCLE_CI_AUTH_TOKEN`
    2. `dashing install 5494590`
    3. Copy the CircleCI image from https://f.cloud.github.com/assets/510845/448516/6e8d2842-b249-11e2-91b6-9a2ffcd08bb0.png into `assets/images`

    ```
    dashing install 5494590
    ```
    ![screen shot 2013-05-01 at 11 14 01](https://f.cloud.github.com/assets/510845/448488/2c0b0012-b248-11e2-9c8a-a9382e007785.png)
  16. Peter Hamilton renamed this gist May 1, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  17. Peter Hamilton revised this gist May 1, 2013. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,9 @@
    1. Copy the below coffee/scss/html files into a widget folder named `circle_ci_list`
    2. Copy the `circle_ci_list.rb` file into the `jobs` folder

    OR

    ```
    dashing install 5494590
    ```
    ![screen shot 2013-05-01 at 11 14 01](https://f.cloud.github.com/assets/510845/448488/2c0b0012-b248-11e2-9c8a-a9382e007785.png)
  18. Peter Hamilton revised this gist May 1, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    # CircleCI Build Statuses

    ![screen shot 2013-05-01 at 11 14 01](https://f.cloud.github.com/assets/510845/448488/2c0b0012-b248-11e2-9c8a-a9382e007785.png)

    ## Usage

    1. Copy the below coffee/scss/html files into a widget folder named `circle_ci_list`
    2. Copy the `circle_ci_list.rb` file into the `jobs` folder

    ![screen shot 2013-05-01 at 11 14 01](https://f.cloud.github.com/assets/510845/448488/2c0b0012-b248-11e2-9c8a-a9382e007785.png)
  19. Peter Hamilton revised this gist May 1, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -2,3 +2,7 @@

    ![screen shot 2013-05-01 at 11 14 01](https://f.cloud.github.com/assets/510845/448488/2c0b0012-b248-11e2-9c8a-a9382e007785.png)

    ## Usage

    1. Copy the below coffee/scss/html files into a widget folder named `circle_ci_list`
    2. Copy the `circle_ci_list.rb` file into the `jobs` folder
  20. Pete Hamilton revised this gist May 1, 2013. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion f
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    f
  21. Peter Hamilton created this gist May 1, 2013.
    4 changes: 4 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    # CircleCI Build Statuses

    ![screen shot 2013-05-01 at 11 14 01](https://f.cloud.github.com/assets/510845/448488/2c0b0012-b248-11e2-9c8a-a9382e007785.png)

    1 change: 1 addition & 0 deletions circle_ci_list.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    class Dashing.CircleCiList extends Dashing.Widget
    41 changes: 41 additions & 0 deletions circle_ci_list.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    require 'httparty'
    require 'digest/md5'

    PROJECTS = [
    { user: 'MY_GITHUB_USER_OR_ORG', repo: 'XXX', branch: 'master' },
    { user: 'MY_GITHUB_USER_OR_ORG', repo: 'YYY', branch: 'dev' },
    ]

    def translate_status_to_class(status)
    statuses = {
    'success' => 'passed',
    'fixed' => 'passed',
    'running' => 'pending',
    'failed' => 'failed'
    }
    statuses[status] || 'pending'
    end

    def update_builds(project, auth_token)
    api_url = 'https://circleci.com/api/v1/project/%s/%s/tree/%s?circle-token=%s'
    api_url = api_url % [project[:user], project[:repo], project[:branch], auth_token]
    api_response = HTTParty.get(api_url, :headers => { "Accept" => "application/json" } )
    api_json = JSON.parse(api_response.body)
    return {} if api_json.empty?

    latest_build = api_json.select{ |build| build['status'] != 'queued' }.first
    email_hash = Digest::MD5.hexdigest(latest_build['committer_email'])

    data = {
    repo: "#{project[:repo]}",
    branch: "#{latest_build['branch']}",
    widget_class: "#{translate_status_to_class(latest_build['status'])}",
    avatar_url: "http://www.gravatar.com/avatar/#{email_hash}"
    }
    return data
    end

    SCHEDULER.every '10s', :first_in => 0 do
    items = PROJECTS.map{ |p| update_builds(p, ENV['CIRCLE_CI_AUTH_TOKEN']) }
    send_event('circle-ci-list', { items: items })
    end
    1 change: 1 addition & 0 deletions f
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    f
    12 changes: 12 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    <h1 class="title" data-bind="title"></h1>

    <img class="background" src="/assets/circle-ci-logo.png">

    <ul class="items list-nostyle">
    <li class="item" data-foreach-item="items" data-bind-class="item.widget_class">
    <span class="label repo" data-bind="item.repo"></span>
    <span class="label branch" data-bind="item.branch"></span>
    <img class="avatar" data-bind-src="item.avatar_url" />
    <div class="clearfix" />
    </li>
    </ul>