js-waku/.github/workflows/ci.yml

264 lines
6.9 KiB
YAML

name: CI
on:
push:
branches:
- "master"
- "staging"
- "trying"
pull_request:
workflow_dispatch:
inputs:
nim_wakunode_image:
description: "Docker hub image name taken from https://hub.docker.com/r/statusteam/nim-waku/tags. Format: statusteam/nim-waku:v0.19.0"
required: false
type: string
workflow_call:
inputs:
nim_wakunode_image:
required: false
type: string
caller:
required: false
type: string
env:
NODE_JS: "18"
RETRY_ATTEMPTS: 3
jobs:
check:
runs-on: ubuntu-latest
if: ${{ inputs.caller == null || inputs.caller != 'nwaku' }}
steps:
- uses: actions/checkout@v3
with:
repository: waku-org/js-waku
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_JS }}
- uses: ./.github/actions/npm
- run: npm run build
- run: npm run check
- run: npm run doc
proto:
runs-on: ubuntu-latest
if: ${{ inputs.caller == null || inputs.caller != 'nwaku' }}
steps:
- uses: actions/checkout@v3
with:
repository: waku-org/js-waku
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_JS }}
- uses: ./.github/actions/npm
- name: Generate protobuf code
run: |
npm run proto
npm run fix
- name: Check all protobuf code was committed
shell: bash
run: |
res=$(git status --short --ignore-submodules)
echo -n "'$res'" # For debug purposes
[ $(echo -n "$res"|wc -l) -eq 0 ]
browser:
runs-on: ubuntu-latest
if: ${{ inputs.caller == null || inputs.caller != 'nwaku' }}
steps:
- uses: actions/checkout@v3
with:
repository: waku-org/js-waku
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_JS }}
- uses: ./.github/actions/npm
- run: npm run build:esm
- run: npm run test:browser
node:
runs-on: ubuntu-latest
env:
WAKUNODE_IMAGE: ${{ inputs.nim_wakunode_image || 'statusteam/nim-waku:v0.19.0' }}
steps:
- uses: actions/checkout@v3
with:
repository: waku-org/js-waku
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_JS }}
- uses: ./.github/actions/npm
- run: npm run build:esm
- uses: Wandalen/wretry.action@master
with:
attempt_limit: ${{ env.RETRY_ATTEMPTS }}
command: npm run test:node
with: |
DEBUG: ""
- name: Upload debug logs on failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: debug.log
path: debug.log
- name: Upload nwaku logs on failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: nwaku-logs
path: packages/tests/log/
node_optional:
runs-on: ubuntu-latest
env:
WAKUNODE_IMAGE: ${{ inputs.nim_wakunode_image || 'statusteam/nim-waku:v0.19.0' }}
steps:
- uses: actions/checkout@v3
with:
repository: waku-org/js-waku
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_JS }}
- uses: ./.github/actions/npm
- run: npm run build:esm
- uses: Wandalen/wretry.action@master
with:
attempt_limit: ${{ env.RETRY_ATTEMPTS }}
command: npm run test:optional --workspace=@waku/tests
with: |
DEBUG: ""
node_with_go_waku_master:
runs-on: ubuntu-latest
if: ${{ inputs.caller == null || inputs.caller != 'nwaku' }}
env:
WAKUNODE_IMAGE: "statusteam/go-waku:latest"
WAKU_SERVICE_NODE_PARAMS: "--min-relay-peers-to-publish=0" # Can be removed once https://github.com/status-im/nwaku/issues/1004 is done
DEBUG: "waku*"
steps:
- uses: actions/checkout@v3
with:
repository: waku-org/js-waku
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_JS }}
- uses: ./.github/actions/npm
- run: npm run build:esm
- uses: Wandalen/wretry.action@master
with:
attempt_limit: ${{ env.RETRY_ATTEMPTS }}
command: npm run test:node
with: |
DEBUG: "waku:nwaku*,waku:test*"
- name: Upload debug logs on failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: go-waku-debug.log
path: debug.log
- name: Upload logs on failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: go-waku-logs
path: packages/tests/log/
node_with_nwaku_master:
runs-on: ubuntu-latest
if: ${{ inputs.caller == null || inputs.caller != 'nwaku' }}
env:
DEBUG: "waku*"
WAKUNODE_IMAGE: "statusteam/nim-waku:deploy-wakuv2-test"
steps:
- uses: actions/checkout@v3
with:
repository: waku-org/js-waku
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_JS }}
- uses: ./.github/actions/npm
- run: npm run build:esm
- uses: Wandalen/wretry.action@master
with:
attempt_limit: ${{ env.RETRY_ATTEMPTS }}
command: npm run test:node
with: |
DEBUG: "waku:nwaku*,waku:test*"
- name: Upload debug logs on failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: nwaku-master-debug.log
path: debug.log
- name: Upload logs on failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: nwaku-master-logs
path: packages/tests/log/
maybe-release:
name: release
runs-on: ubuntu-latest
if: >
github.event_name == 'push' &&
github.ref == 'refs/heads/master' &&
(github.event.inputs.caller == null || github.event.inputs.caller != 'nwaku')
needs: [check, proto, browser, node]
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
command: manifest
monorepo-tags: true
token: ${{ secrets.CI_TOKEN }}
- uses: actions/checkout@v3
with:
repository: waku-org/js-waku
if: ${{ steps.release.outputs.releases_created }}
- uses: actions/setup-node@v3
if: ${{ steps.release.outputs.releases_created }}
with:
node-version: ${{ env.NODE_JS }}
registry-url: "https://registry.npmjs.org"
- run: npm install
if: ${{ steps.release.outputs.releases_created }}
- run: npm run build
if: ${{ steps.release.outputs.releases_created }}
- run: npm run publish
if: ${{ steps.release.outputs.releases_created }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_JS_WAKU_PUBLISH }}