Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Run Canary
on:
push:
tags:
- '*'

jobs:
trigger_canary:
if: startsWith(github.ref, 'refs/tags/') # Only run when a new package is published (detects when a new tag is pushed)
runs-on: ubuntu-latest
steps:
- name: trigger canary
run: |
curl -L -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.CANARY_DISPATCH_PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/holepunchto/canary-tests/dispatches \
-d '{"event_type":"triggered-by-${{ github.event.repository.name }}-${{ github.ref_name }}"}'
16 changes: 16 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Lint

on:
push:
branches: [main, rocksdb]
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
name: Lint
steps:
- uses: holepunchto/actions/node-base@v1
with:
allow-git: true
- run: npm run lint
34 changes: 34 additions & 0 deletions .github/workflows/test-bare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test with Bare

on:
push:
branches: [main, rocksdb]
pull_request:

jobs:
test:
strategy:
matrix:
include:
- os: ubuntu-latest
platform: linux
arch: x64

- os: macos-latest
platform: darwin
arch: x64

- os: windows-latest
platform: win32
arch: x64

runs-on: ${{ matrix.os }}
name: ${{ matrix.platform }}-${{ matrix.arch }}
steps:
- uses: holepunchto/actions/node-base@v1
with:
allow-git: true
- uses: holepunchto/actions/setup-bare@v1

- name: Run tests
run: npm run test:bare
64 changes: 24 additions & 40 deletions .github/workflows/test-node.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,33 @@
name: Build Status
name: Test with Node

on:
push:
branches:
- main
- rocksdb
tags: # To trigger the canary
- '*'
branches: [main, rocksdb]
pull_request:
branches:
- main
- rocksdb

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 https://github.com/actions/checkout/releases/tag/v4.1.1
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2 https://github.com/actions/setup-node/releases/tag/v3.8.2
- run: npm install
- run: npm run lint
build:
if: ${{ !startsWith(github.ref, 'refs/tags/')}} # Already runs for the push of the commit, no need to run again for the tag
test:
strategy:
matrix:
node-version: [lts/*]
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
platform: linux
arch: x64

- os: macos-latest
platform: darwin
arch: x64

- os: windows-latest
platform: win32
arch: x64

runs-on: ${{ matrix.os }}
name: ${{ matrix.platform }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 https://github.com/actions/checkout/releases/tag/v4.1.1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2 https://github.com/actions/setup-node/releases/tag/v3.8.2
- uses: holepunchto/actions/node-base@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
- run: npm -g install bare
- run: npm run test:bare
trigger_canary:
if: startsWith(github.ref, 'refs/tags/') # Only run when a new package is published (detects when a new tag is pushed)
runs-on: ubuntu-latest
steps:
- name: trigger canary
run: |
curl -L -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.CANARY_DISPATCH_PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/holepunchto/canary-tests/dispatches \
-d '{"event_type":"triggered-by-${{ github.event.repository.name }}-${{ github.ref_name }}"}'
allow-git: true

- name: Run tests
run: npm run test:node
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"scripts": {
"format": "prettier --write .",
"lint": "prettier --check . && lunte",
"test": "brittle test/all.js",
"test:bare": "bare test/all.js",
"test:generate": "brittle -r test/all.js test/*.js"
"test": "npm run test:node && npm run test:bare",
"test:node": "brittle-node test/all.mjs",
"test:bare": "brittle-bare -j 4 test/all.mjs",
"test:generate": "brittle-make-test test/all.mjs test/*.js"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -67,7 +68,7 @@
"z32": "^1.0.0"
},
"devDependencies": {
"brittle": "^3.0.0",
"brittle": "github:holepunchto/brittle#v4",
"debugging-stream": "^3.1.0",
"hyperswarm": "^4.3.6",
"lunte": "^1.3.0",
Expand Down
43 changes: 0 additions & 43 deletions test/all.js

This file was deleted.

43 changes: 43 additions & 0 deletions test/all.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// This runner is auto-generated by Brittle

await runTests()

async function runTests() {
const test = (await import('brittle')).default

test.pause()

await test.load(import.meta.resolve('./atomic.js'))
await test.load(import.meta.resolve('./basic.js')) // todo: implement storageInfo API
await test.load(import.meta.resolve('./batch.js'))
await test.load(import.meta.resolve('./bit-interlude.js'))
await test.load(import.meta.resolve('./bitfield.js'))
await test.load(import.meta.resolve('./clear.js')) // todo: replace Info.bytesUsed API
// await test.load(import.meta.resolve('./compat.js')) // todo: how to test compat?
await test.load(import.meta.resolve('./conflicts.js'))
await test.load(import.meta.resolve('./core.js'))
await test.load(import.meta.resolve('./encodings.js'))
await test.load(import.meta.resolve('./encryption.js'))
await test.load(import.meta.resolve('./extension.js'))
await test.load(import.meta.resolve('./fully-remote-proof.js'))
await test.load(import.meta.resolve('./manifest.js'))
await test.load(import.meta.resolve('./mark-n-sweep.js'))
await test.load(import.meta.resolve('./merkle-tree.js'))
await test.load(import.meta.resolve('./merkle-tree-recovery.js'))
await test.load(import.meta.resolve('./move-to.js'))
await test.load(import.meta.resolve('./mutex.js'))
await test.load(import.meta.resolve('./preload.js'))
// await test.load(import.meta.resolve('./purge.js')) // todo: implement purge
await test.load(import.meta.resolve('./push.js'))
await test.load(import.meta.resolve('./remote-bitfield.js'))
await test.load(import.meta.resolve('./remote-length.js'))
await test.load(import.meta.resolve('./replicate.js'))
await test.load(import.meta.resolve('./sessions.js'))
await test.load(import.meta.resolve('./snapshots.js'))
await test.load(import.meta.resolve('./streams.js'))
await test.load(import.meta.resolve('./timeouts.js'))
await test.load(import.meta.resolve('./user-data.js'))
await test.load(import.meta.resolve('./wants.js'))

test.resume()
}
4 changes: 2 additions & 2 deletions test/mark-n-sweep.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { create, createStorage } = require('./helpers')

const Hypercore = require('../')

test('startMarking - basic', async (t) => {
test('startMarking - basic', { timeout: 60_000 }, async (t) => {
const core = await create(t)

const num = 50_000
Expand Down Expand Up @@ -90,7 +90,7 @@ test('startMarking then immediate sweep', async (t) => {
t.absent(await core.has(0, core.length), 'cleared all blocks')
})

test('startMarking - on session', async (t) => {
test('startMarking - on session', { timeout: 60_000 }, async (t) => {
const core = await create(t)

const num = 50_000
Expand Down