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

Commit

Permalink
Merge pull request #22 from little-bear-labs/feature/add_ci_and_linting
Browse files Browse the repository at this point in the history
Add CI templates
  • Loading branch information
ddimaria authored Sep 13, 2022
2 parents c54b121 + e156adf commit 94d4701
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 6 deletions.
8 changes: 8 additions & 0 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
build: {
config: {
platform: 'node'
},
bundlesizeMax: '31KB'
}
}
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
11 changes: 11 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.

name: Automerge
on: [ pull_request ]

jobs:
automerge:
uses: protocol/.github/.github/workflows/automerge.yml@master
with:
job: 'automerge'
116 changes: 116 additions & 0 deletions .github/workflows/js-test-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.

name: test & maybe release
on:
push:
branches:
- master # with #262 - ${{{ github.default_branch }}}
pull_request:
branches:
- master # with #262 - ${{{ github.default_branch }}}
- develop

jobs:

check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present lint
- run: npm run --if-present dep-check

test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:chrome
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: chrome

test-chrome-webworker:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:chrome-webworker
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: chrome-webworker

test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:firefox
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: firefox

test-firefox-webworker:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:firefox-webworker
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: firefox-webworker

test-electron-main:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npx xvfb-maybe npm run --if-present test:electron-main
- uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
with:
flags: electron-main

release:
needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master' # with #262 - 'refs/heads/${{{ github.default_branch }}}'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- uses: ipfs/aegir/actions/docker-login@master
with:
docker-token: ${{ secrets.DOCKER_TOKEN }}
docker-username: ${{ secrets.DOCKER_USERNAME }}
- run: npm run --if-present release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
53 changes: 52 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@
- [API](#api)
- [Transport](#transport)
- [Connection](#connection)
- [Hacking](#hacking)
- [Contribute](#contribute)
- [Contribute](#contribute-1)
- [Development](#development)
- [Build](#build)
- [Lint](#lint)
- [Clean](#clean)
- [Check Dependencies](#check-dependencies)
- [Build a Release](#build-a-release)
- [License](#license)
- [Contribution](#contribution)

Expand Down Expand Up @@ -70,6 +76,51 @@ Please be aware that all interactions related to libp2p are subject to the IPFS

Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.

## Development

This module leans heavily on (Aegir)[https://github.com/ipfs/aegir] for most of the `package.json` scripts.

### Build
The build script is a wrapper to `aegir build`. To build this package:

```shell
npm run build
```

The build will be located in the `/dist` folder.

### Lint
Aegir is also used to lint the code, which follows the [Standard](https://github.com/standard/standard) JS linter.
The VS Code plugin for this standard is located at https://marketplace.visualstudio.com/items?itemName=standard.vscode-standard.
To lint this repo:

```shell
npm run lint
```

You can also auto-fix when applicable:

```shell
npm run lint:fix
```

### Clean

```shell
npm run clean
```

### Check Dependencies

```shell
npm run deps-check
```

### Build a Release

```shell
npm run release
```
## License

Licensed under either of
Expand Down
22 changes: 21 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,32 @@
"author": "",
"license": "Apache-2.0 or MIT",
"type": "module",
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
"sourceType": "module"
}
},
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"files": [
"src",
"dist/src",
"!dist/test",
"!**/*.tsbuildinfo"
],
"scripts": {
"autogen": "npx protoc --ts_out proto_ts --proto_path src src/*.proto",
"othergen": "./node_modules/.bin/proto-loader-gen-types --longs=String --enums=String --defaults --oneofs --grpcLib=@grpc/grpc-js --outDir=proto_ts/ src/*.proto",
"build": "aegir build",
"test": "aegir test --target browser",
"format": "prettier --write src/*.ts"
"lint": "aegir lint",
"lint:fix": "aegir lint --fix",
"clean": "aegir clean",
"dep-check": "aegir dep-check",
"release": "aegir release"
},
"devDependencies": {
"@libp2p/interface-mocks": "^4.0.1",
Expand Down
5 changes: 1 addition & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
"extends": "aegir/src/config/tsconfig.aegir.json",
"compilerOptions": {
"outDir": "dist",
"emitDeclarationOnly": false,
"module": "ES2020",
"importsNotUsedAsValues": "preserve",
"moduleResolution": "node"
"importsNotUsedAsValues": "preserve"
},
"include": [
"src",
Expand Down

0 comments on commit 94d4701

Please sign in to comment.