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

Commit

Permalink
refactor: custom-runtime.sh
Browse files Browse the repository at this point in the history
Making this into a feature useful for testing specific go+js setups.
  • Loading branch information
lidel committed Nov 17, 2021
1 parent 00d8105 commit fd51402
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 48 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ on:
branches:
- master

# TODO: remove below + use of setup-go
env:
IPFS_GO_EXEC: '/tmp/go-ipfs/cmd/ipfs/ipfs'
IPFS_JS_EXEC: '/tmp/js-ipfs/packages/ipfs/src/cli.js'
IPFS_JS_MODULE: '/tmp/js-ipfs/packages/ipfs/dist/cjs/src/index.js'
IPFS_JS_HTTP_MODULE: '/tmp/js-ipfs/packages/ipfs-http-client/dist/cjs/src/index.js'
# To run CI against unrelased go-ipfs or js-ipfs-* code (eg. wip PR),
# uncomment below and define git revisions in ./scripts/custom-runtime.sh
IPFS_GO_EXEC: /tmp/go-ipfs/cmd/ipfs/ipfs
IPFS_JS_EXEC: /tmp/js-ipfs/packages/ipfs/src/cli.js
IPFS_JS_MODULE: /tmp/js-ipfs/packages/ipfs/dist/cjs/src/index.js
IPFS_JS_HTTP_MODULE: /tmp/js-ipfs/packages/ipfs-http-client/dist/cjs/src/index.js

jobs:
build:
Expand All @@ -34,6 +35,7 @@ jobs:
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.event.pull_request.head.sha }}
- name: Install Dependencies
run: |
./scripts/custom-runtime.sh
npm install
npm run build
Expand Down Expand Up @@ -95,7 +97,9 @@ jobs:
run: |
npm install
npm run build
- run: npm run test -- -t node
- run: |
./scripts/custom-runtime.sh
npm run test -- -t node
test-browser:
needs: build
Expand Down Expand Up @@ -132,7 +136,9 @@ jobs:
run: |
npm install
npm run build
- run: npm run test -- -t ${{ matrix.type }} -- --browser ${{ matrix.browser }}
- run: |
./scripts/custom-runtime.sh
npm run test -- -t ${{ matrix.type }} -- --browser ${{ matrix.browser }}
test-electron:
needs: check
Expand Down Expand Up @@ -168,4 +174,6 @@ jobs:
npm run build
- uses: GabrielBB/xvfb-action@v1
with:
run: npm run test -- -t ${{ matrix.type }} --bail -f dist/cjs/node-test/*js
run: |
./scripts/custom-runtime.sh
npm run test -- -t ${{ matrix.type }} --bail -f dist/cjs/node-test/*js
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ test/test-data/go-ipfs-repo/LOCK
test/test-data/go-ipfs-repo/LOG
test/test-data/go-ipfs-repo/LOG.old
types
tmp
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ $ npm install -g ipfs-interop
$ IPFS_GO_EXEC=/path IPFS_JS_EXEC=/path IPFS_JS_MODULE=/path IPFS_JS_HTTP_MODULE=/path ipfs-interop
```

### As a custom runtime

If you want to run interop on CI against specific repo and git revision of
go-ipfs or js-ipfs* then set everything up in `./scripts/custom-runtime.sh`
and enable it by uncommenting `env:` `IPFS_(..)` definitions in `.github/workflows/test.yml`

If you want to test against unrelased things locally, make sure the same env
variables are set on your machine.

For example, to run pubsub tests against go-ipfs and js-ipfs revision defined
in `./scripts/custom-runtime.sh`, one can:

```
export IPFS_GO_EXEC=/tmp/go-ipfs/cmd/ipfs/ipfs
export IPFS_JS_EXEC=/tmp/js-ipfs/packages/ipfs/src/cli.js
export IPFS_JS_MODULE=/tmp/js-ipfs/packages/ipfs/dist/cjs/src/index.js
export IPFS_JS_HTTP_MODULE=/tmp/js-ipfs/packages/ipfs-http-client/dist/cjs/src/index.js
./scripts/custom-runtime.sh
node bin/ipfs-interop.js -- -t node --grep "pubsub"
```

## Releasing a new version

This repo does not use aegir for releases.
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"npm": ">6.0.0"
},
"scripts": {
"postinstall": "bash ./setup-http-rpc-runtime.sh",
"lint": "aegir lint",
"build": "aegir build",
"pretest": "aegir build --esm-tests",
Expand Down
50 changes: 50 additions & 0 deletions scripts/custom-runtime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash

# This script sets up the Rube Goldberg machine for testing against custom
# revision of go-ipfs and js-ipfs (the latter being tricky due to lerna monorepo)
#
# It assumes IPFS_GO_EXEC or IPFS_JS_EXEC to be in env.
# One can trigger this locally by exporting the same path as we do on CI.
# For example, to run pubsub tests against go-ipfs and js-ipfs revision defined
# in ./scripts/custom-runtime.sh one can:
#
# export IPFS_GO_EXEC=/tmp/go-ipfs/cmd/ipfs/ipfs
# export IPFS_JS_EXEC=/tmp/js-ipfs/packages/ipfs/src/cli.js
# export IPFS_JS_MODULE=/tmp/js-ipfs/packages/ipfs/dist/cjs/src/index.js
# export IPFS_JS_HTTP_MODULE=/tmp/js-ipfs/packages/ipfs-http-client/dist/cjs/src/index.js
# ./scripts/custom-runtime.sh
# node bin/ipfs-interop.js -- -t node --grep "pubsub"

set -eo pipefail

WORKDIR=$(pwd)

if [ "$IPFS_GO_EXEC" == /tmp/go-ipfs/cmd/ipfs/ipfs ]; then
if [ ! -d /tmp/go-ipfs ]; then
cd /tmp
git clone https://github.com/coryschwartz/go-ipfs.git
cd go-ipfs
# implementation from https://github.com/ipfs/go-ipfs/pull/8183
git checkout 153697d524f449ee9bec97245b0fcd7ebc2e8170
make build
fi
fi

if [ "$IPFS_JS_EXEC" == /tmp/js-ipfs/packages/ipfs/src/cli.js ]; then
if [ ! -d /tmp/js-ipfs ]; then
cd /tmp
git clone https://github.com/ipfs/js-ipfs.git
cd js-ipfs
# implementation from https://github.com/ipfs/js-ipfs/pull/3922
git checkout 1dcac76f56972fc3519526e93567e39d685033dd
npm install
npm run build
npm run link
fi
fi

cd $WORKDIR


# print overrides
env | grep IPFS_
38 changes: 0 additions & 38 deletions setup-http-rpc-runtime.sh

This file was deleted.

0 comments on commit fd51402

Please sign in to comment.