fix: await multip #723
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a basic workflow to help you get started with Actions | |
name: Server CI/CD v1 | |
# Controls when the action will run. Triggers the workflow on push or pull request | |
# events but only for the master branch | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
outputs: | |
test-chunks: ${{ steps['set-test-chunks'].outputs['test-chunks'] }} | |
test-chunk-ids: ${{ steps['set-test-chunk-ids'].outputs['test-chunk-ids'] }} | |
wallet-chunk-id: ${{ steps['set-test-chunk-ids'].outputs['wallet-chunk-id'] }} | |
steps: | |
- uses: actions/checkout@v3 | |
- id: set-test-chunks | |
name: Set Chunks | |
run: echo "test-chunks=$(find ./src -path \*/__tests__/*.js | sort | jq -R -s -c 'split("\n")[:-1] | map(select(contains("__util") == false))' | jq -cM '[_nwise(length / 5 | floor)]')" >> $GITHUB_OUTPUT | |
- id: set-test-chunk-ids | |
name: Set Chunk IDs | |
run: | | |
echo "test-chunk-ids=$(echo $CHUNKS | jq -cM 'to_entries | map(.key)')" >> $GITHUB_OUTPUT | |
echo "wallet-chunk-id=$(echo $CHUNKS | jq -cM 'to_entries | map(select(.value | .[] | index("blockchain"))) | map(.key) | unique')" >> $GITHUB_OUTPUT | |
env: | |
CHUNKS: ${{ steps['set-test-chunks'].outputs['test-chunks'] }} | |
test: | |
name: Unit Tests | |
needs: | |
- setup | |
strategy: | |
matrix: | |
chunk: ${{ fromJson(needs.setup.outputs['test-chunk-ids']) }} | |
if: "github.event_name != 'workflow_dispatch' && !contains(github.event.head_commit.message,'skip ci') && !contains(github.event.head_commit.message,'skip build')" | |
env: | |
ADMIN_PASS: test | |
JWT_PASS: test | |
TRAVIS: true | |
NETWORK: dapptest | |
# MNEMONIC: 'myth like bonus scare over problem client lizard pioneer submit female collect' | |
ADMIN_MNEMONIC: 'test test test test test test test test test test test junk' | |
ALCHEMY_API: ${{ secrets.ALCHEMY_API }} | |
AWS_SES_ACCESS_KEY: ${{ secrets.AWS_SES_ACCESS_KEY }} | |
AWS_SES_SECRET_ACCESS_KEY: ${{ secrets.AWS_SES_SECRET_ACCESS_KEY }} | |
CF_WORKER_VERIFY_JWT_SECRET: ${{ secrets.CF_WORKER_VERIFY_JWT_SECRET }} | |
MAUTIC_TOKEN: ${{ secrets.MAUTIC_TOKEN }} | |
MAUTIC_BASIC_TOKEN: ${{ secrets.MAUTIC_BASIC_TOKEN }} | |
CI: false | |
LOG_LEVEL: error | |
CHUNKS: ${{ needs.setup.outputs['test-chunks'] }} | |
BLOCKCHAIN_CHUNKS: ${{ needs.setup.outputs['wallet-chunk-id'] }} | |
runs-on: ubuntu-latest | |
steps: | |
- run: corepack enable | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
- run: npm i -g patch-package | |
- name: Install npm dependencies | |
uses: bahmutov/npm-install@v1 | |
- name: prepare blockchain for blockchain related tests | |
if: contains(fromJson(env.BLOCKCHAIN_CHUNKS),matrix.chunk) | |
env: | |
MNEMONIC: ${{ env.ADMIN_MNEMONIC }} | |
run: npm run test:setup | |
- name: prepare blockchain for generic tests | |
if: '!contains(fromJson(env.BLOCKCHAIN_CHUNKS) ,matrix.chunk)' | |
run: | | |
npx ganache-cli -p 8545 & | |
sleep 30 | |
- name: run tests and code coverage | |
env: | |
MNEMONIC: ${{ env.ADMIN_MNEMONIC }} | |
run: | | |
echo "using mnemonic for admin: ${MNEMONIC}" | |
echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | @text' | xargs npm run coverage | |
# npm run test -- src/server/send/__tests__/sendAPI.js | |
# npm run coverage -- --silent | |
# npm run coveralls | |
npm run build | |
pkill -f ganache || true | |
- name: Coveralls | |
uses: coverallsapp/github-action@master | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
parallel: true | |
flag-name: run-${{ matrix.chunk }} | |
coverage: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Coveralls Finished | |
uses: coverallsapp/github-action@master | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
parallel-finished: true |