Skip to content

Commit

Permalink
pkg: add ci.
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Jul 6, 2023
1 parent c2c093e commit 5abec59
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
},
"rules": {
"max-len": "off",
"prefer-arrow-callback": "off"
"prefer-arrow-callback": "off",
"no-return-assign": "off"
}
}
],
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build

on: [push, pull_request]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup
uses: actions/setup-node@v3
with:
node-version: 20.x

- name: Install tools
run: npm install --location=global bslint

- name: Install dependencies
run: npm install

- name: Lint
run: npm run lint

test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node: [16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install dependencies
run: npm install

- name: Test
run: npm test

4 changes: 3 additions & 1 deletion lib/blru.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = require('./lru');
const LRU = require('./lru');

module.exports = LRU;
43 changes: 43 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"author": "Christopher Jeffrey <[email protected]>",
"main": "./lib/blru.js",
"scripts": {
"lint": "eslint lib/ test/ || exit 0",
"lint": "eslint lib/ test/",
"test": "bmocha --reporter spec test/*-test.js"
},
"dependencies": {
"bsert": "~0.0.10"
"bsert": "~0.0.12"
},
"devDependencies": {
"bmocha": "^2.1.0"
"bmocha": "^2.1.8"
},
"engines": {
"node": ">=8.0.0"
Expand Down
23 changes: 23 additions & 0 deletions test/lru-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

const assert = require('bsert');
const LRU = require('../lib/lru');

describe('LRU', function() {
it('should test lru', () => {
const cap = 10;
const all = 100;
const lru = new LRU(cap);

for (let i = 0; i < all; i++)
lru.set(i, i);

for (let i = 0; i < all - cap; i++)
assert(!lru.has(i));

for (let i = all - cap; i < all; i++) {
assert(lru.has(i));
assert.strictEqual(lru.get(i), i);
}
});
});

0 comments on commit 5abec59

Please sign in to comment.