Amio
6 years ago
6 changed files with 52 additions and 20 deletions
@ -0,0 +1,18 @@ |
|||
const axios = require('../axios.js') |
|||
const covColor = require('../utils/cov-color.js') |
|||
|
|||
module.exports = async function (topic, platform, user, repo, branch) { |
|||
// only support topic="c" fow now
|
|||
|
|||
const query = branch ? `?branch=${branch}` : '' |
|||
const endpoint = `https://coveralls.io/${platform}/${user}/${repo}.json${query}` |
|||
|
|||
/* eslint-disable camelcase */ |
|||
const { covered_percent } = await axios.get(endpoint).then(res => res.data) |
|||
|
|||
return { |
|||
subject: 'coverage', |
|||
status: Number(covered_percent).toFixed(2) + '%', |
|||
color: covColor(covered_percent) |
|||
} |
|||
} |
@ -0,0 +1,24 @@ |
|||
/** |
|||
* Generate color from coverage number |
|||
* |
|||
* @param {Number} value |
|||
* @param {Number} orange |
|||
* @param {Number} yellow |
|||
* @param {Number} green |
|||
*/ |
|||
|
|||
module.exports = function cc (value, orange = 70, yellow = 85, green = 100) { |
|||
if (value <= 0) { |
|||
return 'red' |
|||
} |
|||
if (value < orange) { |
|||
return 'ef6c00' |
|||
} |
|||
if (value < yellow) { |
|||
return 'c0ca33' |
|||
} |
|||
if (value < green) { |
|||
return 'a4a61d' |
|||
} |
|||
return 'green' |
|||
} |
Loading…
Reference in new issue