Skip to content

fix: make tests more stable #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Sep 2, 2021
Merged
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
52 changes: 15 additions & 37 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,16 @@ jobs:
- packages/interface-store
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 16.x
- name: Install dependencies
run: npm install
- name: Build types
- name: Build project
run: npm run build
- name: Typecheck ${{ matrix.project }}
uses: gozala/[email protected]
with:
project: ${{ matrix.project }}
- run: npx aegir build
- run: npx aegir dep-check
- name: Check deps
run: npm run dep-check
- uses: ipfs/aegir/actions/bundle-size@master
name: size
with:
Expand All @@ -42,54 +38,36 @@ jobs:
test-node:
strategy:
matrix:
node-version: [14.x, 16.x]
os: [windows-latest, ubuntu-latest, macos-latest]
project:
- packages/interface-blockstore
- packages/interface-blockstore-tests
- packages/interface-datastore
- packages/interface-datastore-tests
- packages/interface-store
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: ${{ matrix.node-version }}
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
node-version: 16.x
- run: npm install
- run: npx aegir test -t node --cov --bail
- run: npm run test -- -- -- -t node --cov --bail
- uses: codecov/codecov-action@v1
test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16.x
- run: npm install
- run: npx aegir test -t browser -t webworker --bail
- run: npm run test -- -- -- -t browser -t webworker --bail
test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16.x
- run: npm install
- run: npx aegir test -t browser -t webworker --bail -- --browser firefox
test-electron-main:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx xvfb-maybe aegir test -t electron-main --bail
test-electron-renderer:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx xvfb-maybe aegir test -t electron-renderer --bail
- run: npm run test -- -- -- -t browser -t webworker --bail -- --browser firefox
1 change: 1 addition & 0 deletions .nyc_output/coverage-final.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"test": "lerna run test",
"build": "lerna run build",
"lint": "lerna run lint",
"release": "lerna run build && lerna publish"
"release": "lerna run build && lerna publish",
"dep-check": "lerna run dep-check"
},
"homepage": "https://github.com/ipfs/js-ipfs-interfaces/tree/master#readme",
"bugs": "https://github.com/ipfs/js-ipfs-interfaces/issues",
Expand Down
5 changes: 3 additions & 2 deletions packages/interface-blockstore-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"scripts": {
"build": "aegir build",
"lint": "aegir ts -p check && aegir lint",
"test": "echo \"No tests configured\""
"test": "echo \"No tests configured\"",
"dep-check": "aegir dep-check"
},
"repository": {
"type": "git",
Expand All @@ -31,7 +32,7 @@
"homepage": "https://github.com/ipfs/js-ipfs-interfaces/tree/master/packages/interface-blockstore-tests#readme",
"dependencies": {
"aegir": "^35.0.0",
"interface-blockstore": "^0.2.1",
"interface-blockstore": "^1.0.1",
"it-all": "^1.0.2",
"it-drain": "^1.0.1",
"it-length": "^1.0.2",
Expand Down
20 changes: 17 additions & 3 deletions packages/interface-blockstore-tests/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const drain = require('it-drain')
const { fromString: uint8ArrayFromString } = require('uint8arrays/from-string')
const { CID } = require('multiformats/cid')
const { sha256 } = require('multiformats/hashes/sha2')
const { base32 } = require('multiformats/bases/base32')
const raw = require('multiformats/codecs/raw')
const length = require('it-length')

Expand Down Expand Up @@ -286,9 +287,9 @@ module.exports = (test) => {
})

it('many (1200)', async function () {
this.timeout(20 * 1000)
this.timeout(60 * 1000)
const b = store.batch()
const count = 10
const count = 1200

/** @type {Record<string, number>} */
const prefixes = {}
Expand All @@ -300,7 +301,20 @@ module.exports = (test) => {

b.put(key, value)

const prefix = key.toString().substr(0, 13)
// find the shortest stringified key that aligns with a byte boundary
const keyStr = key.toString()
let prefix = ''

for (let j = keyStr.length - 1; j > 20; j--) {
try {
base32.decode(keyStr.substring(0, j))
prefix = keyStr.substring(0, j)
} catch (err) {
if (err.message !== 'Unexpected end of data') {
throw err
}
}
}

prefixes[prefix] = (prefixes[prefix] || 0) + 1
}
Expand Down
5 changes: 3 additions & 2 deletions packages/interface-blockstore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"scripts": {
"build": "aegir build",
"test": "echo \"No tests configured\"",
"lint": "aegir ts -p check && aegir lint"
"lint": "aegir ts -p check && aegir lint",
"dep-check": "aegir dep-check"
},
"license": "(Apache-2.0 OR MIT)",
"homepage": "https://github.com/ipfs/js-ipfs-interfaces/tree/master/packages/interface-blockstore#readme",
Expand All @@ -18,7 +19,7 @@
},
"dependencies": {
"err-code": "^3.0.1",
"interface-store": "^0.1.1",
"interface-store": "^1.0.1",
"it-all": "^1.0.5",
"it-drain": "^1.0.4",
"it-filter": "^1.0.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Pair as StorePair,
Batch as StoreBatch,
QueryFilter as StoreQueryFilter,
Expand All @@ -10,7 +10,7 @@ import {
Options as StoreOptions,
Store
} from 'interface-store'
import {
import type {
CID
} from 'multiformats'

Expand Down
3 changes: 2 additions & 1 deletion packages/interface-datastore-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"scripts": {
"build": "aegir build",
"lint": "aegir ts -p check && aegir lint",
"test": "echo \"No tests configured\""
"test": "echo \"No tests configured\"",
"dep-check": "aegir dep-check"
},
"repository": {
"type": "git",
Expand Down
7 changes: 7 additions & 0 deletions packages/interface-datastore/.nyc_output/coverage-final.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions packages/interface-datastore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"build": "aegir build",
"lint": "aegir ts -p check && aegir lint",
"test": "aegir test",
"coverage": "aegir test --cov"
"coverage": "aegir test --cov",
"dep-check": "aegir dep-check -i interface-datastore-tests"
},
"repository": {
"type": "git",
Expand All @@ -37,7 +38,7 @@
},
"dependencies": {
"err-code": "^3.0.1",
"interface-store": "^0.1.1",
"interface-store": "^1.0.1",
"ipfs-utils": "^8.1.2",
"it-all": "^1.0.2",
"it-drain": "^1.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
Pair as StorePair,
Batch as StoreBatch,
QueryFilter as StoreQueryFilter,
Expand Down
3 changes: 2 additions & 1 deletion packages/interface-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"scripts": {
"build": "aegir build",
"test": "echo \"No tests configured\"",
"lint": "aegir ts -p check && aegir lint"
"lint": "aegir ts -p check && aegir lint",
"dep-check": "aegir dep-check"
},
"homepage": "https://github.com/ipfs/js-ipfs-interfaces/tree/master/packages/interface-store#readme",
"bugs": "https://github.com/ipfs/js-ipfs-interfaces/issues",
Expand Down