Skip to content

Commit

Permalink
Separate node and browser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
julienmalard committed Jan 20, 2024
1 parent 4dc6542 commit b7ee275
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 610 deletions.
34 changes: 1 addition & 33 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
import path, { dirname } from "path";
import { fileURLToPath } from "url";
import { createRequire } from "module";

const require = createRequire(import.meta.url);

const __dirname = dirname(fileURLToPath(import.meta.url));

// https://github.com/node-webrtc/node-webrtc/issues/636#issuecomment-774171409
process.on("beforeExit", (code) => process.exit(code));

// https://github.com/ipfs/aegir/blob/master/md/migration-to-v31.md
const esbuild = {
// this will inject all the named exports from 'node-globals.js' as globals
inject: [path.join(__dirname, "./scripts/node-globals.js")],
external: ["fs", "path", "os", "chokidar", "url", "zlib", "rimraf"],
plugins: [
{
name: "node built ins", // this will make the bundler resolve node builtins to the respective browser polyfill
setup(build) {
build.onResolve({ filter: /^stream$/ }, () => {
return { path: require.resolve("stream-browserify") };
});
build.onResolve({ filter: /^os$/ }, () => {
return { path: require.resolve("os-browserify") };
});
build.onResolve({ filter: /^crypto$/ }, () => {
return { path: require.resolve("crypto-browserify") };
});
build.onResolve({ filter: /^fs/ }, () => {
return { path: require.resolve("browserify-fs") };
});
},
},
],
external: ["rimraf"],
};

/** @type {import('aegir').PartialOptions} */
Expand Down
29 changes: 27 additions & 2 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches:
- main
jobs:
tests-and-coverage:
test-node:
name: Node.js test
runs-on: ubuntu-latest
steps:
Expand All @@ -28,7 +28,32 @@ jobs:
run: pnpm install --lockfile=false

- name: Vérifier les tests
run: pnpm test
run: pnpm test:node

- name: Envoyer couverture à Codecov
uses: codecov/codecov-action@v3
test-browser:
name: Browser test
runs-on: ubuntu-latest
steps:
- name: Préparation de Node.js
uses: actions/setup-node@v4
with:
node-version: 16

- name: Installer pnpm
uses: pnpm/action-setup@v2.4.0
with:
version: latest

- name: Ouvrir la branche
uses: actions/checkout@v4

- name: Nétoyer les dépendances d'installation
run: pnpm install --lockfile=false

- name: Vérifier les tests
run: pnpm test:browser

- name: Envoyer couverture à Codecov
uses: codecov/codecov-action@v3
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Set database type for orbit-db.

## Installation
```
$ pnpm add @orbitdb/orbit-db-set
$ pnpm add @orbitdb/set
```
## Introduction
As `Set` database is like a [`Feed`](https://github.com/reseau-constellation/set), but each value can only be present once. Works for primitive types as well as more complex objects.
Expand Down
13 changes: 4 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"scripts": {
"clean": "rimraf dist",
"compile": "pnpm updateVersion && pnpm format && pnpm clean && pnpm tspc -p tsconfig.build.json",
"test": "pnpm compile && pnpm aegir test -t node --cov -- --exit",
"test:node": "pnpm compile && pnpm aegir test -t node --cov -- --exit",
"test:browser": "pnpm compile && pnpm aegir test -t browser --cov -- --exit",
"format": "pnpm prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\" && pnpm eslint --ext .js,.ts src",
"release": "pnpm test && (git commit -a -m 'version' || true) && pnpm publish",
"updateVersion": "pnpm genversion --es6 --semi src/version.ts"
Expand All @@ -36,30 +37,24 @@
"@libp2p/identify": "^1.0.11",
"@libp2p/webrtc": "^4.0.16",
"@libp2p/websockets": "^8.0.12",
"@types/fs-extra": "^11.0.4",
"@types/mocha": "^10.0.6",
"@types/uuid": "^9.0.7",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"aegir": "^42.2.2",
"blockstore-core": "^4.3.10",
"blockstore-level": "^1.1.7",
"browserify-fs": "^1.0.0",
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"fs-extra": "^11.2.0",
"genversion": "^3.2.0",
"libp2p": "^1.2.0",
"mocha": "^10.2.0",
"os-browserify": "^0.3.0",
"prettier": "^3.2.4",
"process": "^0.11.10",
"rimraf": "^5.0.5",
"ts-patch": "^3.1.2",
"typescript": "^5.3.3",
"typescript-transform-paths": "^3.4.6"
"typescript-transform-paths": "^3.4.6",
"wherearewe": "^2.0.1"
},
"jest": {
"transform": {
Expand Down
Loading

0 comments on commit b7ee275

Please sign in to comment.