Skip to content

Commit

Permalink
chore: switch to github actions
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
  • Loading branch information
lidel committed Sep 28, 2022
1 parent e08276a commit 4fabe56
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 209 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
TEST: true

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir lint
- run: npx aegir build
- run: npx aegir dep-check
- uses: ipfs/aegir/actions/bundle-size@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
test-node:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node: ['lts/*', '*']
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npx aegir test -t node --bail --cov
- uses: codecov/codecov-action@v1
test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- run: npm install
- run: npx aegir test -t browser --bail --cov
- run: npx aegir test -t webworker --bail
- uses: codecov/codecov-action@v1
test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- run: npm install
- run: npx aegir test -t browser -t webworker --bail -- --browser firefox
test-webkit:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: microsoft/playwright-github-action@v1
- run: npm install
- run: npx aegir test -t browser -t webworker --bail -- --browser webkit
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
53 changes: 0 additions & 53 deletions .travis.yml

This file was deleted.

24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,53 +54,53 @@ When using prebuilt bundle from CDN, `ipfs-geoip` will be exposed under `window.

## Usage

### With a public gateway (default)
### With public gateways (default)

If `ipfs` is `undefined` or a string with gateway URL, it will be used for
fetching data as [`application/vnd.ipld.raw`](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw)
and parsing it as DAG-CBOR locally:
If `ipfs` is a string or array of strings with public gateway URLs, it will be used for
fetching IPFS blocks as [`application/vnd.ipld.raw`](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw)
and parsing them as DAG-CBOR locally:

```js
const geoip = require('ipfs-geoip')
const exampleIp = '66.6.44.4'

const ipfsGateway = 'https://ipfs.io'
const ipfsGw = ['https://ipfs.io', 'https://dweb.link']

try {
const result = await geoip.lookup(ipfsGateway, exampleIp)
const result = await geoip.lookup(ipfsGw, exampleIp)
console.log('Result: ', result)
} catch (err) {
console.log('Error: ' + err)
}

try {
const result = await geoip.lookupPretty(ipfs, '/ip4/' + exampleIp)
const result = await geoip.lookupPretty(ipfsGw, '/ip4/' + exampleIp)
console.log('Pretty result: %s', result.formatted)
} catch (err) {
console.log('Error: ' + err)
}
```

### With JS-IPFS or Kubo RPC
### With custom block getter function

It is also possible to use it with local or remote IPFS node that exposes
It is also possible to use it with local or remote IPFS node by passing block getter function, e.g., one that exposes
[`ipfs.block.get` Core JS API](https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/BLOCK.md#ipfsblockgetcid-options):

```js
const geoip = require('ipfs-geoip')
const exampleIp = '66.6.44.4'

const ipfsApi = require('ipfs-http-client')()
const ipfs = require('ipfs-http-client')()

try {
const result = await geoip.lookup(ipfsApi, exampleIp)
const getBlock = (cid) => ipfs.block.get(cid)
const result = await geoip.lookup(getBlock, exampleIp)
console.log('Result: ', result)
} catch (err) {
console.log('Error: ' + err)
}
```


## API

### `lookup(ipfs, ip)`
Expand Down
12 changes: 0 additions & 12 deletions circle.yml

This file was deleted.

Loading

0 comments on commit 4fabe56

Please sign in to comment.