Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
chore: ci cleanup
Browse files Browse the repository at this point in the history
move to gh actions
add npm linting
fix tests for new tap
  • Loading branch information
wraithgar committed Sep 1, 2021
1 parent 25f0a40 commit 6d22da9
Show file tree
Hide file tree
Showing 18 changed files with 9,435 additions and 4,374 deletions.
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { readdirSync: readdir } = require('fs')

const localConfigs = readdir(__dirname)
.filter((file) => file.startsWith('.eslintrc.local.'))
.map((file) => `./${file}`)

module.exports = {
extends: [
'@npmcli',
...localConfigs,
],
}
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI

on:
pull_request:
push:
branches:
- main
- latest

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
cache: npm
- run: npm i --prefer-online -g npm@latest
- run: npm ci
- run: npm run lint

test:
strategy:
fail-fast: false
matrix:
node-version: [10.0.x, 10.x, 12.0.x, 12.x, 14.0.x, 14.x, 15.x, 16.x]
platform:
- os: ubuntu-latest
shell: bash
- os: macos-latest
shell: bash
- os: windows-latest
shell: bash
- os: windows-latest
shell: cmd
- os: windows-latest
shell: powershell
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm i --prefer-online -g npm@latest
- run: npm ci
- run: npm test --ignore-scripts
- run: npm ls -a
21 changes: 16 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
*~
.#*
node_modules
coverage
.nyc_output
# ignore everything in the root
/*

# keep these
!/.eslintrc*
!/.github
!**/.gitignore
!/package.json
!/package-lock.json
!/bin
!/lib
!/map.js
!/tap-snapshots
!/test
!/README*
!/LICENSE*
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

5 changes: 0 additions & 5 deletions LICENSE

This file was deleted.

18 changes: 18 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ISC License

Copyright npm, Inc.

Permission to use, copy, modify, and/or distribute this
software for any purpose with or without fee is hereby
granted, provided that the above copyright notice and this
permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
EVENT SHALL NPM BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
USE OR PERFORMANCE OF THIS SOFTWARE.
File renamed without changes.
File renamed without changes.
19 changes: 14 additions & 5 deletions tracker-group.js → lib/tracker-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ util.inherits(TrackerGroup, TrackerBase)
function bubbleChange (trackerGroup) {
return function (name, completed, tracker) {
trackerGroup.completion[tracker.id] = completed
if (trackerGroup.finished) return
if (trackerGroup.finished) {
return
}
trackerGroup.emit('change', name || trackerGroup.name, trackerGroup.completed(), trackerGroup)
}
}
Expand Down Expand Up @@ -53,17 +55,22 @@ TrackerGroup.prototype.addUnit = function (unit, weight) {
this.trackers.push(unit)
this.completion[unit.id] = unit.completed()
unit.on('change', this.bubbleChange)
if (!this.finished) this.emit('change', unit.name, this.completion[unit.id], unit)
if (!this.finished) {
this.emit('change', unit.name, this.completion[unit.id], unit)
}
return unit
}

TrackerGroup.prototype.completed = function () {
if (this.trackers.length === 0) return 0
if (this.trackers.length === 0) {
return 0
}
var valPerWeight = 1 / this.totalWeight
var completed = 0
for (var ii = 0; ii < this.trackers.length; ii++) {
var trackerId = this.trackers[ii].id
completed += valPerWeight * this.weight[trackerId] * this.completion[trackerId]
completed +=
valPerWeight * this.weight[trackerId] * this.completion[trackerId]
}
return completed
}
Expand All @@ -82,7 +89,9 @@ TrackerGroup.prototype.newStream = function (name, todo, weight) {

TrackerGroup.prototype.finish = function () {
this.finished = true
if (!this.trackers.length) this.addUnit(new Tracker(), 1, true)
if (!this.trackers.length) {
this.addUnit(new Tracker(), 1, true)
}
for (var ii = 0; ii < this.trackers.length; ii++) {
var tracker = this.trackers[ii]
tracker.finish()
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion tracker.js → lib/tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ Tracker.prototype.addWork = function (work) {

Tracker.prototype.completeWork = function (work) {
this.workDone += work
if (this.workDone > this.workTodo) this.workDone = this.workTodo
if (this.workDone > this.workTodo) {
this.workDone = this.workTodo
}
this.emit('change', this.name, this.completed(), this)
}

Expand Down
Loading

0 comments on commit 6d22da9

Please sign in to comment.