js-waku/.github/workflows/test-node.yml

86 lines
2.5 KiB
YAML

# WARNING: This workflow is used by upstream workflows (jswaku, nwaku, gowaku) via workflow_call.
# DO NOT modify the name, inputs, or other parts of this workflow that might break upstream CI.
name: Run Test
on:
workflow_call:
# IMPORTANT: Do not change the name or properties of these inputs.
# If you add new required inputs make sure that they have default value or you make the change upstream as well
inputs:
nim_wakunode_image:
required: true
type: string
test_type:
required: true
type: string
debug:
required: false
type: string
default: ''
env:
NODE_JS: "20"
# Ensure test type conditions remain consistent.
WAKU_SERVICE_NODE_PARAMS: ${{ (inputs.test_type == 'go-waku-master') && '--min-relay-peers-to-publish=0' || '' }}
DEBUG: ${{ inputs.debug }}
jobs:
node:
runs-on: ubuntu-latest
env:
WAKUNODE_IMAGE: ${{ inputs.nim_wakunode_image }}
permissions:
contents: read
actions: read
checks: write
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: ${{ (inputs.test_type == 'node-optional') && 'npm run test:optional --workspace=@waku/tests' || 'npm run test:node' }}
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Test Report - ${{ inputs.test_type }}
path: 'packages/tests/reports/mocha-*.json'
reporter: mocha-json
fail-on-error: true
- name: Upload debug logs on failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ inputs.test_type }}-debug.log
path: debug.log
- name: Sanitize log filenames
if: failure()
run: |
find packages/tests/log/ -type f | while read fname; do
dir=$(dirname "$fname")
base=$(basename "$fname")
sanitized_base=$(echo $base | tr -d '\"*:<>?|' | sed 's/[\\/\r\n]/_/g' | sed 's/_$//')
if [ "$base" != "$sanitized_base" ]; then
mv "$fname" "$dir/$sanitized_base"
fi
done
- name: Upload logs on failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ inputs.test_type }}-logs
path: packages/tests/log/