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

feat: add auto-publish #134

Merged
merged 2 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions .github/workflows/bundlesize.yml

This file was deleted.

187 changes: 170 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci
name: test & maybe release
on:
push:
branches:
Expand All @@ -8,17 +8,34 @@ on:
- master

jobs:

check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: npm run build
- run: npm run lint
- run: npm run dep-check
node-version: lts/*
- uses: actions/cache@v2
id: cache
env:
CACHE_NAME: cache-node-modules
with:
path: |
~/.npm
./dist
./node_modules
./packages/*/dist
./packages/*/node_modules
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.sha }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install
npm run --if-present build
- run: npm run --if-present lint
- run: npm run --if-present dep-check

test-node:
needs: check
runs-on: ${{ matrix.os }}
Expand All @@ -32,29 +49,165 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm run build
- run: npm run test:node -- -- --bail
- uses: actions/cache@v2
id: cache
env:
CACHE_NAME: cache-node-modules
with:
path: |
~/.npm
./dist
./node_modules
./packages/*/dist
./packages/*/node_modules
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.sha }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install
npm run --if-present build
- run: npm run --if-present test:node -- --bail --cov
- uses: codecov/codecov-action@v1

test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: npm run build
- run: npm run test:browser -- -- --bail
node-version: lts/*
- uses: actions/cache@v2
id: cache
env:
CACHE_NAME: cache-node-modules
with:
path: |
~/.npm
./dist
./node_modules
./packages/*/dist
./packages/*/node_modules
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.sha }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install
npm run --if-present build
- run: npm run --if-present test:browser -- -t browser -t webworker --bail

test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm install
- run: npm run build
- run: npm run test:browser -- -- --bail --browser firefox
node-version: lts/*
- uses: actions/cache@v2
id: cache
env:
CACHE_NAME: cache-node-modules
with:
path: |
~/.npm
./dist
./node_modules
./packages/*/dist
./packages/*/node_modules
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.sha }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install
npm run --if-present build
- run: npm run --if-present test:browser -- -t browser -t webworker --bail -- --browser firefox

test-electron-main:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: actions/cache@v2
id: cache
env:
CACHE_NAME: cache-node-modules
with:
path: |
~/.npm
./dist
./node_modules
./packages/*/dist
./packages/*/node_modules
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.sha }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install
npm run --if-present build
- run: npx xvfb-maybe npm run --if-present test:electron-main --bail

test-electron-renderer:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: actions/cache@v2
id: cache
env:
CACHE_NAME: cache-node-modules
with:
path: |
~/.npm
./dist
./node_modules
./packages/*/dist
./packages/*/node_modules
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.sha }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install
npm run --if-present build
- run: npx xvfb-maybe npm run --if-present test:electron-renderer --bail

release:
needs: [test-node, test-chrome, test-firefox, test-electron-main]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: actions/cache@v2
id: cache
env:
CACHE_NAME: cache-node-modules
with:
path: |
~/.npm
./dist
./node_modules
./packages/*/dist
./packages/*/node_modules
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ github.sha }}
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install
npm run --if-present build
- run: npm run --if-present release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
"private": true,
"scripts": {
"reset": "lerna run clean && rimraf ./node_modules ./package-lock.json packages/*/node_modules packages/*/package-lock.json packages/*/dist",
"test": "lerna run test",
"test:node": "lerna run test:node",
"test:browser": "lerna run test:browser",
"test": "lerna run test -- --",
"test:node": "lerna run test:node -- --",
"test:browser": "lerna run test:browser -- --",
"test:electron-main": "lerna run test:electron-main -- --",
"build": "lerna run build",
"lint": "lerna run lint",
"dep-check": "lerna run dep-check",
"release": "lerna run build && lerna publish"
"release": "lerna run build && lerna publish --force-publish --yes"
},
"bugs": "https://github.com/libp2p/js-libp2p-interfaces/issues",
"homepage": "https://github.com/libp2p/js-libp2p-interfaces#readme",
Expand All @@ -32,7 +33,7 @@
"rimraf": "^3.0.2"
},
"engines": {
"node": ">=14.0.0",
"node": ">=15.0.0",
"npm": ">=7.0.0"
}
}
9 changes: 6 additions & 3 deletions packages/libp2p-connection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
"dep-check": "aegir dep-check dist/src/**/*.js",
"pretest": "npm run build",
"build": "tsc",
"test": "aegir test -f ./dist/test/*.js"
"test": "aegir test -f ./dist/test/**/*.js",
"test:browser": "aegir test -t browser -f ./dist/test/**/*.js",
"test:node": "aegir test -t node -f ./dist/test/**/*.js",
"test:electron-main": "aegir test -t electron-main -f ./dist/test/**/*.js"
},
"repository": {
"type": "git",
Expand All @@ -44,8 +47,8 @@
"homepage": "https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-connection#readme",
"dependencies": {
"@libp2p/interfaces": "^0.1.0",
"err-code": "^3.0.1",
"multiaddr": "^10.0.1"
"@multiformats/multiaddr": "^10.1.1",
"err-code": "^3.0.1"
},
"devDependencies": {
"@libp2p/peer-id-factory": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p-connection/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Multiaddr } from 'multiaddr'
import type { Multiaddr } from '@multiformats/multiaddr'
import errCode from 'err-code'
import { OPEN, CLOSING, CLOSED } from '@libp2p/interfaces/connection/status'
import type { MuxedStream } from '@libp2p/interfaces/stream-muxer'
Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p-connection/test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Connection } from '../src/index.js'
import * as PeerIdFactory from '@libp2p/peer-id-factory'
// @ts-expect-error no types
import pair from 'it-pair'
import { Multiaddr } from 'multiaddr'
import { Multiaddr } from '@multiformats/multiaddr'
import type { MuxedStream } from '@libp2p/interfaces/stream-muxer'

const peers = [{
Expand Down
9 changes: 6 additions & 3 deletions packages/libp2p-interface-compliance-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
"dep-check": "aegir dep-check dist/src/**/*.js",
"build": "tsc",
"pretest": "npm run build",
"test": "aegir test -f ./dist/test/**/*.js"
"test": "aegir test -f ./dist/test/**/*.js",
"test:browser": "aegir test -t browser -f ./dist/test/**/*.js",
"test:node": "aegir test -t node -f ./dist/test/**/*.js",
"test:electron-main": "aegir test -t electron-main -f ./dist/test/**/*.js"
},
"repository": {
"type": "git",
Expand All @@ -42,11 +45,13 @@
"homepage": "https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-interfaces-compliance-tests#readme",
"dependencies": {
"@libp2p/connection": "^0.1.0",
"@libp2p/crypto": "^0.22.2",
"@libp2p/interfaces": "^0.1.0",
"@libp2p/peer-id": "^0.1.0",
"@libp2p/peer-id-factory": "^0.1.0",
"@libp2p/pubsub": "^0.1.0",
"@libp2p/topology": "^0.1.0",
"@multiformats/multiaddr": "^10.1.1",
"abort-controller": "^3.0.0",
"abortable-iterator": "^3.0.0",
"aegir": "^36.0.0",
Expand All @@ -56,8 +61,6 @@
"it-goodbye": "^3.0.0",
"it-pair": "^1.0.0",
"it-pipe": "^1.1.0",
"libp2p-crypto": "^0.21.0",
"multiaddr": "^10.0.0",
"multiformats": "^9.4.10",
"p-defer": "^3.0.0",
"p-limit": "^3.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'aegir/utils/chai.js'
import { Multiaddr } from 'multiaddr'
import { Multiaddr } from '@multiformats/multiaddr'
import delay from 'delay'
import pDefer from 'p-defer'
import type { TestSetup } from '../index.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import sinon from 'sinon'
import type { TestSetup } from '../index.js'
import type { Transport, Listener } from '@libp2p/interfaces/transport'
import type { TransportTestFixtures, SetupArgs, Connector } from './index.js'
import type { Multiaddr } from 'multiaddr'
import type { Multiaddr } from '@multiformats/multiaddr'

export default (common: TestSetup<TransportTestFixtures, SetupArgs>) => {
describe('dial', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { mockUpgrader } from './utils/index.js'
import type { TestSetup } from '../index.js'
import type { Transport } from '@libp2p/interfaces/transport'
import type { TransportTestFixtures, SetupArgs } from './index.js'
import type { Multiaddr } from 'multiaddr'
import type { Multiaddr } from '@multiformats/multiaddr'

export default (common: TestSetup<TransportTestFixtures, SetupArgs>) => {
describe('filter', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import listen from './listen-test.js'
import filter from './filter-test.js'
import type { TestSetup } from '../index.js'
import type { Transport, Upgrader } from '@libp2p/interfaces/transport'
import type { Multiaddr } from 'multiaddr'
import type { Multiaddr } from '@multiformats/multiaddr'

export interface Connector {
delay: (ms: number) => void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import defer from 'p-defer'
import type { TestSetup } from '../index.js'
import type { Transport } from '@libp2p/interfaces/transport'
import type { TransportTestFixtures, SetupArgs } from './index.js'
import type { Multiaddr } from 'multiaddr'
import type { Multiaddr } from '@multiformats/multiaddr'
import type { Connection } from '@libp2p/interfaces/connection'

export default (common: TestSetup<TransportTestFixtures, SetupArgs>) => {
Expand Down
Loading