Skip to content

Commit

Permalink
Merge pull request #18 from macbre/tests
Browse files Browse the repository at this point in the history
Add CI for running tests
  • Loading branch information
macbre authored Oct 22, 2021
2 parents 8d9b614 + 13ed975 commit ef15bcd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ devel ]
pull_request:

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 17.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- run: npm ci
- run: npm test
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function ColorsRanker(stats, from, to) {
this.articles = stats.articles;

this.edits_per_article = Math.ceil(this.edits / this.articles) * 2;
this.from = new Color(from || '#000000');
this.from = from || '#000000';
this.to = new Color(to || '#ffffff');
}

Expand All @@ -70,8 +70,10 @@ function ColorsRanker(stats, from, to) {
* @returns {string} RGB color (without a hash)
*/
ColorsRanker.prototype.getColorForEdit = function(idx) {
const from = Color(this.from || '#000000');

var mix = Math.min(1, (idx + 1) / this.edits_per_article);
return this.from.clone().mix(this.to, mix).hexString().substring(1);
return from.mix(this.to, mix).hex().substring(1);
};

// public API
Expand Down

0 comments on commit ef15bcd

Please sign in to comment.