Browse Source

live-fns: simplify circleci badge - success/failed (#269)

docker-size
Andrew Leedham 6 years ago
committed by Amio
parent
commit
7413e84d4e
  1. 19
      libs/live-fns/circleci.js

19
libs/live-fns/circleci.js

@ -4,7 +4,7 @@ const got = require('../got.js')
// https://circleci.com/docs/api/v1-reference/
module.exports = async (vcsType, user, project, branch) => {
branch = branch ? `/tree/${qs.escape(branch)}` : ''
const endpoint = `https://circleci.com/api/v1.1/project/${vcsType}/${user}/${project}${branch}`
const endpoint = `https://circleci.com/api/v1.1/project/${vcsType}/${user}/${project}${branch}?filter=completed&limit=1`
const [latest] = await got(endpoint).then(res => res.body)
return {
@ -16,26 +16,9 @@ module.exports = async (vcsType, user, project, branch) => {
const getStatusColor = status => {
switch (status) {
case 'infrastructure_fail':
case 'timedout':
case 'failed':
case 'no_tests':
return 'red'
case 'canceled':
case 'not_run':
case 'not_running':
return 'grey'
case 'queued':
case 'scheduled':
return 'yellow'
case 'retried':
case 'running':
return 'orange'
case 'fixed':
case 'success':
return 'green'

Loading…
Cancel
Save