Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit 9d36595

Browse files
authoredNov 17, 2021
Merge pull request #397 from ipfs/feat/custom-runtime-script
feat: scripts/custom-runtime.sh
2 parents b361f74 + f62da35 commit 9d36595

File tree

4 files changed

+94
-5
lines changed

4 files changed

+94
-5
lines changed
 

‎.github/workflows/test.yml

+22-4
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,40 @@ on:
44
branches:
55
- master
66

7+
# To run CI against unrelased go-ipfs or js-ipfs-* code (eg. wip PR),
8+
# uncomment env below and define git revisions in ./scripts/custom-runtime.sh
9+
10+
#env:
11+
#IPFS_GO_EXEC: /tmp/go-ipfs/cmd/ipfs/ipfs
12+
#IPFS_JS_EXEC: /tmp/js-ipfs/packages/ipfs/src/cli.js
13+
#IPFS_JS_MODULE: /tmp/js-ipfs/packages/ipfs/dist/cjs/src/index.js
14+
#IPFS_JS_HTTP_MODULE: /tmp/js-ipfs/packages/ipfs-http-client/dist/cjs/src/index.js
15+
716
jobs:
817
build:
918
name: Build
1019
runs-on: ubuntu-latest
1120
steps:
1221
- uses: actions/checkout@v2
13-
- uses: actions/setup-node@v1
22+
- uses: actions/setup-go@v2
23+
with:
24+
go-version: '1.16'
25+
- uses: actions/setup-node@v2
1426
with:
1527
node-version: 16
1628
- uses: actions/cache@v2
1729
env:
1830
CACHE_NAME: cache-node-modules
1931
with:
2032
path: |
33+
/tmp/*-ipfs/**
2134
~/.npm
2235
./node_modules
2336
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
2437
- name: Install Dependencies
2538
run: |
2639
npm install
40+
./scripts/custom-runtime.sh
2741
npm run build
2842
2943
check:
@@ -41,6 +55,7 @@ jobs:
4155
CACHE_NAME: cache-node-modules
4256
with:
4357
path: |
58+
/tmp/*-ipfs/**
4459
~/.npm
4560
./node_modules
4661
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
@@ -59,7 +74,7 @@ jobs:
5974
name: test node ${{ matrix.node }}
6075
steps:
6176
- uses: actions/checkout@v2
62-
- uses: actions/setup-node@v1
77+
- uses: actions/setup-node@v2
6378
with:
6479
node-version: 16
6580
- uses: actions/cache@v2
@@ -68,6 +83,7 @@ jobs:
6883
CACHE_NAME: cache-node-modules
6984
with:
7085
path: |
86+
/tmp/*-ipfs/**
7187
~/.npm
7288
./node_modules
7389
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
@@ -92,7 +108,7 @@ jobs:
92108
- webworker
93109
steps:
94110
- uses: actions/checkout@v2
95-
- uses: actions/setup-node@v1
111+
- uses: actions/setup-node@v2
96112
with:
97113
node-version: 16
98114
- uses: actions/cache@v2
@@ -101,6 +117,7 @@ jobs:
101117
CACHE_NAME: cache-node-modules
102118
with:
103119
path: |
120+
/tmp/*-ipfs/**
104121
~/.npm
105122
./node_modules
106123
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
@@ -122,7 +139,7 @@ jobs:
122139
- electron-renderer
123140
steps:
124141
- uses: actions/checkout@v2
125-
- uses: actions/setup-node@v1
142+
- uses: actions/setup-node@v2
126143
with:
127144
node-version: 16
128145
- uses: actions/cache@v2
@@ -131,6 +148,7 @@ jobs:
131148
CACHE_NAME: cache-node-modules
132149
with:
133150
path: |
151+
/tmp/*-ipfs/**
134152
~/.npm
135153
./node_modules
136154
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}

‎README.md

+21
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,27 @@ $ npm install -g ipfs-interop
7373
$ IPFS_GO_EXEC=/path IPFS_JS_EXEC=/path IPFS_JS_MODULE=/path IPFS_JS_HTTP_MODULE=/path ipfs-interop
7474
```
7575

76+
### As a custom runtime
77+
78+
If you want to run interop on CI against specific repo and git revision of
79+
go-ipfs or js-ipfs* then set everything up in `./scripts/custom-runtime.sh`
80+
and enable it by uncommenting `env:` `IPFS_(..)` definitions in `.github/workflows/test.yml`
81+
82+
If you want to test against unrelased things locally, make sure the same env
83+
variables are set on your machine.
84+
85+
For example, to run pubsub tests against go-ipfs and js-ipfs revision defined
86+
in `./scripts/custom-runtime.sh`, one can:
87+
88+
```
89+
export IPFS_GO_EXEC=/tmp/go-ipfs/cmd/ipfs/ipfs
90+
export IPFS_JS_EXEC=/tmp/js-ipfs/packages/ipfs/src/cli.js
91+
export IPFS_JS_MODULE=/tmp/js-ipfs/packages/ipfs/dist/cjs/src/index.js
92+
export IPFS_JS_HTTP_MODULE=/tmp/js-ipfs/packages/ipfs-http-client/dist/cjs/src/index.js
93+
./scripts/custom-runtime.sh
94+
node bin/ipfs-interop.js -- -t node --grep "pubsub"
95+
```
96+
7697
## Releasing a new version
7798

7899
This repo does not use aegir for releases.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"ipfs-interop": "bin/ipfs-interop.js"
2020
},
2121
"engines": {
22-
"node": ">=12.0.0",
22+
"node": ">=16.0.0",
2323
"npm": ">6.0.0"
2424
},
2525
"scripts": {

‎scripts/custom-runtime.sh

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
# This script sets up the Rube Goldberg machine for testing against custom
4+
# revision of go-ipfs and js-ipfs (the latter being tricky due to lerna monorepo)
5+
#
6+
# It assumes IPFS_GO_EXEC or IPFS_JS_EXEC to be in env.
7+
# One can trigger this locally by exporting the same path as we do on CI.
8+
# For example, to run pubsub tests against go-ipfs and js-ipfs revision defined
9+
# in ./scripts/custom-runtime.sh one can:
10+
#
11+
# export IPFS_GO_EXEC=/tmp/go-ipfs/cmd/ipfs/ipfs
12+
# export IPFS_JS_EXEC=/tmp/js-ipfs/packages/ipfs/src/cli.js
13+
# export IPFS_JS_MODULE=/tmp/js-ipfs/packages/ipfs/dist/cjs/src/index.js
14+
# export IPFS_JS_HTTP_MODULE=/tmp/js-ipfs/packages/ipfs-http-client/dist/cjs/src/index.js
15+
# ./scripts/custom-runtime.sh
16+
# node bin/ipfs-interop.js -- -t node --grep "pubsub"
17+
18+
set -eo pipefail
19+
20+
WORKDIR=$(pwd)
21+
22+
if [ "$IPFS_GO_EXEC" == /tmp/go-ipfs/cmd/ipfs/ipfs ]; then
23+
if [ ! -d /tmp/go-ipfs ]; then
24+
cd /tmp
25+
git clone https://github.com/ipfs/go-ipfs.git
26+
cd go-ipfs
27+
# set implementation to specific commit
28+
git checkout CHANGEME_GO
29+
make build
30+
fi
31+
fi
32+
33+
if [ "$IPFS_JS_EXEC" == /tmp/js-ipfs/packages/ipfs/src/cli.js ]; then
34+
if [ ! -d /tmp/js-ipfs ]; then
35+
cd /tmp
36+
git clone https://github.com/ipfs/js-ipfs.git
37+
cd js-ipfs
38+
# set implementation to specific commit
39+
git checkout CHANGEME_JS
40+
npm install
41+
npm run build
42+
npm run link
43+
fi
44+
fi
45+
46+
cd $WORKDIR
47+
48+
49+
# print overrides
50+
env | grep IPFS_ || true

0 commit comments

Comments
 (0)
This repository has been archived.