Skip to content

Commit e6f15bf

Browse files
committed
format tests, update project ci settings
1 parent 2ec0b52 commit e6f15bf

8 files changed

Lines changed: 87 additions & 70 deletions

File tree

.github/workflows/benchmark.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
build:
77
strategy:
88
matrix:
9-
node-version: [20.x, 22.x]
9+
node-version: [22.x, 24.x, 25.x]
1010
platform:
1111
- os: ubuntu-latest
1212
shell: bash
@@ -23,16 +23,13 @@ jobs:
2323

2424
steps:
2525
- name: Checkout Repository
26-
uses: actions/checkout@v4
26+
uses: actions/checkout@v6
2727

2828
- name: Use Nodejs ${{ matrix.node-version }}
29-
uses: actions/setup-node@v4
29+
uses: actions/setup-node@v6
3030
with:
3131
node-version: ${{ matrix.node-version }}
3232

33-
- name: Use latest npm
34-
run: npm i -g npm@latest
35-
3633
- name: Install dependencies
3734
run: npm install
3835

.github/workflows/ci.yml

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request_target:
7+
paths:
8+
- 'src/**'
9+
- 'test/**'
10+
- '*.json'
11+
- '*.js'
12+
- '*.ts'
13+
- 'lib/**'
14+
- 'scripts/**'
15+
- '.github/workflows/ci.yml'
16+
- 'package.json'
17+
workflow_dispatch:
18+
19+
permissions:
20+
contents: read
421

522
jobs:
623
build:
724
strategy:
825
matrix:
9-
node-version: [20.x, 22.x, 24.x]
26+
node-version: [22.x, 24.x, 25.x]
1027
platform:
11-
- os: ubuntu-latest
12-
shell: bash
13-
- os: macos-latest
14-
shell: bash
15-
- os: windows-latest
16-
shell: bash
17-
- os: windows-latest
18-
shell: powershell
28+
- os: ubuntu-latest
29+
shell: bash
30+
- os: macos-latest
31+
shell: bash
32+
- os: windows-latest
33+
shell: bash
34+
- os: windows-latest
35+
shell: powershell
1936
fail-fast: false
2037

2138
runs-on: ${{ matrix.platform.os }}
@@ -25,16 +42,13 @@ jobs:
2542

2643
steps:
2744
- name: Checkout Repository
28-
uses: actions/checkout@v4
45+
uses: actions/checkout@v6
2946

3047
- name: Use Nodejs ${{ matrix.node-version }}
31-
uses: actions/setup-node@v4
48+
uses: actions/setup-node@v6
3249
with:
3350
node-version: ${{ matrix.node-version }}
3451

35-
- name: debugging
36-
run: echo NODEVERSION=[${{ matrix.node-version }}] OS=[${{ matrix.platform.os }}]
37-
3852
- name: Install dependencies
3953
run: npm install
4054

.github/workflows/typedoc.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,41 @@
1-
# Simple workflow for deploying static content to GitHub Pages
2-
name: Deploy static content to Pages
1+
name: typedoc
32

43
on:
5-
# Runs on pushes targeting the default branch
64
push:
75
branches: ["main"]
8-
9-
# Allows you to run this workflow manually from the Actions tab
106
workflow_dispatch:
117

12-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
138
permissions:
149
contents: read
1510
pages: write
1611
id-token: write
1712

18-
# Allow one concurrent deployment
1913
concurrency:
2014
group: "pages"
2115
cancel-in-progress: true
2216

2317
jobs:
24-
# Single deploy job since we're just deploying
2518
deploy:
2619
environment:
2720
name: github-pages
2821
url: ${{ steps.deployment.outputs.page_url }}
2922
runs-on: ubuntu-latest
3023
steps:
3124
- name: Checkout
32-
uses: actions/checkout@v4
25+
uses: actions/checkout@v6
3326
- name: Use Nodejs ${{ matrix.node-version }}
34-
uses: actions/setup-node@v4
27+
uses: actions/setup-node@v6
3528
with:
36-
node-version: 22.x
29+
node-version: 20.x
3730
- name: Install dependencies
3831
run: npm install
3932
- name: Generate typedocs
4033
run: npm run typedoc
41-
- name: Generate Benchmarks
42-
run: npm run benchmark
43-
- name: Copy Benchmarks to Docs
44-
run: npm run benchmark-results-typedoc
34+
4535
- name: Setup Pages
4636
uses: actions/configure-pages@v5
4737
- name: Upload artifact
48-
uses: actions/upload-pages-artifact@v3
38+
uses: actions/upload-pages-artifact@v4
4939
with:
5040
path: './docs'
5141
- name: Deploy to GitHub Pages

.taprc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# vim: set filetype=yaml :
2+
node-arg:
3+
- "--expose-gc"
4+
plugin:
5+
- "@tapjs/clock"

package.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,6 @@
6666
"engines": {
6767
"node": "20 || >=22"
6868
},
69-
"tap": {
70-
"node-arg": [
71-
"--expose-gc"
72-
],
73-
"plugin": [
74-
"@tapjs/clock"
75-
]
76-
},
7769
"exports": {
7870
"./raw": {
7971
"import": {

test/basic.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ t.test('verify require works as expected', async t => {
1313
const { LRUCache } = await t.mockImport('../dist/esm/index.js')
1414
const { LRUCache: LRUCacheRaw } = await t.mockImport('lru-cache/raw')
1515
t.equal(LRUCache.toString().split(/\r?\n/)[0].trim(), 'class LRUCache {')
16-
t.equal(LRUCache.toString(), LRUCacheRaw.toString(), './raw endpoint is unminified')
16+
t.equal(
17+
LRUCache.toString(),
18+
LRUCacheRaw.toString(),
19+
'./raw endpoint is unminified',
20+
)
1721
const { LRUCache: LRUCacheMain } = await t.mockImport('lru-cache')
18-
const { LRUCache: LRUCacheMin } = await t.mockImport('../dist/esm/index.min.js')
22+
const { LRUCache: LRUCacheMin } = await t.mockImport(
23+
'../dist/esm/index.min.js',
24+
)
1925
t.equal(LRUCacheMin.toString(), LRUCacheMain.toString())
2026
})
2127

test/ttl.ts

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,11 @@ const runTests = (LRU: typeof LRUCache, t: Test) => {
498498

499499
// advance past the original TTL (80 + 30 = 110 from set, but only 30 from get)
500500
clock.advance(30)
501-
t.equal(c.size, 1, 'entry survives past original TTL because get refreshed it')
501+
t.equal(
502+
c.size,
503+
1,
504+
'entry survives past original TTL because get refreshed it',
505+
)
502506
t.equal(c.get('a'), 1, 'entry is still retrievable')
503507

504508
// now let the refreshed TTL expire without any more gets
@@ -511,28 +515,35 @@ const runTests = (LRU: typeof LRUCache, t: Test) => {
511515
t.end()
512516
})
513517

514-
t.test('updateAgeOnGet + ttlAutopurge: entry eventually purged if not re-accessed', t => {
515-
const c = new LRU({
516-
ttl: 50,
517-
ttlAutopurge: true,
518-
updateAgeOnGet: true,
519-
ttlResolution: 0,
520-
})
521-
c.set('b', 2)
522-
t.equal(c.size, 1)
523-
524-
// access once before TTL expires, refreshing the timer
525-
clock.advance(30)
526-
t.equal(c.get('b'), 2, 'alive before TTL')
527-
528-
// do NOT access again — let the refreshed TTL expire
529-
// the refreshed TTL starts at t=30, expires at t=30+50+1=81
530-
clock.advance(52)
531-
t.equal(c.size, 0, 'entry autopurged after refreshed TTL with no further access')
532-
t.equal(c.get('b'), undefined, 'entry is gone')
533-
534-
t.end()
535-
})
518+
t.test(
519+
'updateAgeOnGet + ttlAutopurge: entry eventually purged if not re-accessed',
520+
t => {
521+
const c = new LRU({
522+
ttl: 50,
523+
ttlAutopurge: true,
524+
updateAgeOnGet: true,
525+
ttlResolution: 0,
526+
})
527+
c.set('b', 2)
528+
t.equal(c.size, 1)
529+
530+
// access once before TTL expires, refreshing the timer
531+
clock.advance(30)
532+
t.equal(c.get('b'), 2, 'alive before TTL')
533+
534+
// do NOT access again — let the refreshed TTL expire
535+
// the refreshed TTL starts at t=30, expires at t=30+50+1=81
536+
clock.advance(52)
537+
t.equal(
538+
c.size,
539+
0,
540+
'entry autopurged after refreshed TTL with no further access',
541+
)
542+
t.equal(c.get('b'), undefined, 'entry is gone')
543+
544+
t.end()
545+
},
546+
)
536547

537548
t.end()
538549
}

typedoc.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
"tsconfig": "./.tshy/esm.json",
3+
"entryPoints": ["./src/**/*.+(ts|tsx|mts|cts)"],
24
"navigationLinks": {
35
"GitHub": "https://github.com/isaacs/node-lru-cache",
46
"isaacs projects": "https://isaacs.github.io/",

0 commit comments

Comments
 (0)