Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 9a353b8

Browse files
fix: test each example individually (#39)
* fix: test each example individually The current CI setup hoists all deps to the root which makes it hard to spot when individual examples are missing dependencies. This change switches up CI to run the tests for each example in isolation so we should know when a dep is missing. * chore: use working-directory option * chore: fix gh actions * chore: fix gh actions * chore: add missing dep * chore: revert yarn.lock changes * chore: more missing deps * chore: rename step running tests to make it more obvious * chore: test monorepo * fix: add missing example Co-authored-by: Olivério Sousa <47525443+oliveriosousa@users.noreply.github.com>
1 parent ba02297 commit 9a353b8

File tree

5 files changed

+67
-11
lines changed

5 files changed

+67
-11
lines changed

.github/workflows/ci.yml

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,71 @@ on:
77
branches: [master]
88

99
jobs:
10-
build:
10+
examples:
1111
runs-on: ubuntu-latest
12+
name: Test ${{ matrix.project }}
13+
strategy:
14+
matrix:
15+
project:
16+
- browser-add-readable-stream
17+
- browser-angular
18+
- browser-browserify
19+
- browser-create-react-app
20+
- browser-exchange-files
21+
- browser-ipns-publish
22+
- browser-lit
23+
- browser-mfs
24+
- browser-nextjs
25+
- browser-parceljs
26+
- browser-readablestream
27+
- browser-script-tag
28+
- browser-service-worker
29+
- browser-sharing-node-across-tabs
30+
- browser-video-streaming
31+
- browser-vue
32+
- browser-webpack
33+
- circuit-relaying
34+
- custom-ipfs-repo
35+
- custom-ipld-formats
36+
- custom-libp2p
37+
- http-client-browser-pubsub
38+
- http-client-bundle-webpack
39+
- http-client-name-api
40+
- http-client-upload-file
41+
- ipfs-101
42+
- ipfs-client-add-files
43+
- run-in-electron
44+
- running-multiple-nodes
45+
- traverse-ipld-graphs
46+
- types-use-ipfs-from-ts
47+
- types-use-ipfs-from-typed-js
48+
defaults:
49+
run:
50+
working-directory: examples/${{ matrix.project }}
51+
steps:
52+
- uses: actions/checkout@v2
53+
- uses: actions/setup-node@v2
54+
with:
55+
node-version: 16
56+
- run: npm install
57+
- uses: GabrielBB/xvfb-action@v1
58+
name: Run tests
59+
with:
60+
run: npm test
61+
working-directory: examples/${{ matrix.project }}
1262

63+
monorepo:
64+
runs-on: ubuntu-latest
65+
name: Test monorepo
1366
steps:
1467
- uses: actions/checkout@v2
1568
- uses: actions/setup-node@v2
1669
with:
17-
node-version: "16"
18-
cache: "yarn"
70+
node-version: 16
71+
cache: yarn
1972
- name: Install dependencies
2073
run: yarn install
21-
- name: Install dependencies for browsers
22-
run: npx playwright install-deps
23-
- name: Run test:examples
24-
run: npx xvfb-maybe yarn run test:examples
74+
- uses: GabrielBB/xvfb-action@v1
75+
name: Run test:examples
76+
with:
77+
run: yarn run test:examples

examples/browser-exchange-files/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@babel/core": "^7.14.8",
2222
"@playwright/test": "^1.12.3",
2323
"ipfs-http-client": "^52.0.1",
24+
"libp2p-webrtc-star": "^0.23.0",
2425
"parcel": "latest",
2526
"playwright": "^1.12.3",
2627
"rimraf": "^3.0.2",

examples/browser-ipns-publish/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"ipfs-utils": "^8.1.4",
2929
"ipns": "^0.13.3",
3030
"it-last": "^1.0.4",
31-
"multihashes": "^4.0.2",
31+
"libp2p-websockets": "^0.16.1",
32+
"multiformats": "^9.4.7",
3233
"p-retry": "^4.2.0",
3334
"uint8arrays": "^3.0.0"
3435
},

examples/browser-ipns-publish/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ const cryptoKeys = require("human-crypto-keys"); // { getKeyPairFromSeed }
99
const { toString: uint8ArrayToString } = require('uint8arrays/to-string')
1010
const { fromString: uint8ArrayFromString } = require('uint8arrays/from-string')
1111
const { sha256 } = require('multiformats/hashes/sha2')
12+
const { base58btc } = require('multiformats/bases/base58')
1213
const WS = require('libp2p-websockets')
1314
const transportKey = WS.prototype[Symbol.toStringTag]
1415
const filters = require('libp2p-websockets/src/filters')
15-
const mh = require('multihashes')
1616

1717
const { sleep, Logger, onEnterPress, catchAndLog } = require("./util");
1818

@@ -205,7 +205,7 @@ async function main() {
205205
last(ipfsAPI.name.resolve(keys.id, { stream: false })); // save the pubsub topic to the server to make them listen
206206

207207
// set up the topic from ipns key
208-
let b58 = await mh.fromB58String(keys.id);
208+
let b58 = base58btc.decode(`z${keys.id}`)
209209
const ipnsKeys = ipns.getIdKeys(b58);
210210
const topic = `${namespace}${uint8ArrayToString(ipnsKeys.routingKey._buf, 'base64url')}`;
211211

examples/browser-vue/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"eslint-plugin-vue": "^7.2.0",
4949
"playwright": "^1.12.3",
5050
"rimraf": "^3.0.2",
51-
"test-util-ipfs-example": "^1.0.2"
51+
"test-util-ipfs-example": "^1.0.2",
52+
"util": "^0.12.4"
5253
}
5354
}

0 commit comments

Comments
 (0)