mirror of
https://github.com/n8n-io/n8n
synced 2026-04-21 15:47:20 +00:00
207 lines
7.4 KiB
YAML
207 lines
7.4 KiB
YAML
name: 'Test: Unit'
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
ref:
|
|
description: GitHub ref to test.
|
|
required: false
|
|
type: string
|
|
default: ''
|
|
nodeVersion:
|
|
description: Version of node to use.
|
|
required: false
|
|
type: string
|
|
default: 24.14.1
|
|
collectCoverage:
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
env:
|
|
NODE_OPTIONS: --max-old-space-size=7168
|
|
|
|
jobs:
|
|
unit-test-backend:
|
|
name: Backend Unit Tests
|
|
runs-on: ${{ vars.RUNNER_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-4vcpu-ubuntu-2204' }}
|
|
env:
|
|
COVERAGE_ENABLED: ${{ inputs.collectCoverage }} # Coverage collected when true
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
ref: ${{ inputs.ref }}
|
|
|
|
- name: Build
|
|
uses: ./.github/actions/setup-nodejs
|
|
with:
|
|
node-version: ${{ inputs.nodeVersion }}
|
|
|
|
- name: Test Unit
|
|
run: pnpm test:ci:backend:unit --summarize
|
|
|
|
- name: Send Test Stats
|
|
if: ${{ !cancelled() }}
|
|
run: node .github/scripts/send-build-stats.mjs || true
|
|
env:
|
|
QA_METRICS_WEBHOOK_URL: ${{ secrets.QA_METRICS_WEBHOOK_URL }}
|
|
QA_METRICS_WEBHOOK_USER: ${{ secrets.QA_METRICS_WEBHOOK_USER }}
|
|
QA_METRICS_WEBHOOK_PASSWORD: ${{ secrets.QA_METRICS_WEBHOOK_PASSWORD }}
|
|
|
|
- name: Upload test results to Codecov
|
|
if: ${{ !cancelled() }}
|
|
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
report-type: test_results
|
|
name: backend-unit
|
|
|
|
- name: Upload coverage to Codecov
|
|
if: env.COVERAGE_ENABLED == 'true'
|
|
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
flags: backend-unit
|
|
name: backend-unit
|
|
files: ./packages/**/coverage/cobertura-coverage.xml,./coverage/cobertura-coverage.xml
|
|
|
|
integration-test-backend:
|
|
name: Backend Integration Tests
|
|
runs-on: ${{ vars.RUNNER_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-4vcpu-ubuntu-2204' }}
|
|
env:
|
|
COVERAGE_ENABLED: ${{ inputs.collectCoverage }} # Coverage collected when true
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
ref: ${{ inputs.ref }}
|
|
|
|
- name: Build
|
|
uses: ./.github/actions/setup-nodejs
|
|
with:
|
|
node-version: ${{ inputs.nodeVersion }}
|
|
|
|
- name: Test Integration
|
|
run: pnpm test:ci:backend:integration --summarize
|
|
|
|
- name: Send Test Stats
|
|
if: ${{ !cancelled() }}
|
|
run: node .github/scripts/send-build-stats.mjs || true
|
|
env:
|
|
QA_METRICS_WEBHOOK_URL: ${{ secrets.QA_METRICS_WEBHOOK_URL }}
|
|
QA_METRICS_WEBHOOK_USER: ${{ secrets.QA_METRICS_WEBHOOK_USER }}
|
|
QA_METRICS_WEBHOOK_PASSWORD: ${{ secrets.QA_METRICS_WEBHOOK_PASSWORD }}
|
|
|
|
- name: Upload test results to Codecov
|
|
if: ${{ !cancelled() }}
|
|
uses: codecov/test-results-action@0fa95f0e1eeaafde2c782583b36b28ad0d8c77d3 # v1.2.1
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
name: backend-integration
|
|
|
|
- name: Upload coverage to Codecov
|
|
if: env.COVERAGE_ENABLED == 'true'
|
|
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
flags: backend-integration
|
|
name: backend-integration
|
|
files: ./packages/**/coverage/cobertura-coverage.xml,./coverage/cobertura-coverage.xml
|
|
|
|
unit-test-nodes:
|
|
name: Nodes Unit Tests
|
|
runs-on: ${{ vars.RUNNER_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-4vcpu-ubuntu-2204' }}
|
|
env:
|
|
COVERAGE_ENABLED: ${{ inputs.collectCoverage }} # Coverage collected when true
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
ref: ${{ inputs.ref }}
|
|
|
|
- name: Build
|
|
uses: ./.github/actions/setup-nodejs
|
|
with:
|
|
node-version: ${{ inputs.nodeVersion }}
|
|
|
|
- name: Test Nodes
|
|
run: pnpm turbo test --filter=n8n-nodes-base --summarize
|
|
|
|
- name: Send Test Stats
|
|
if: ${{ !cancelled() }}
|
|
run: node .github/scripts/send-build-stats.mjs || true
|
|
env:
|
|
QA_METRICS_WEBHOOK_URL: ${{ secrets.QA_METRICS_WEBHOOK_URL }}
|
|
QA_METRICS_WEBHOOK_USER: ${{ secrets.QA_METRICS_WEBHOOK_USER }}
|
|
QA_METRICS_WEBHOOK_PASSWORD: ${{ secrets.QA_METRICS_WEBHOOK_PASSWORD }}
|
|
|
|
- name: Upload test results to Codecov
|
|
if: ${{ !cancelled() }}
|
|
uses: codecov/test-results-action@0fa95f0e1eeaafde2c782583b36b28ad0d8c77d3 # v1.2.1
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
name: nodes-unit
|
|
|
|
- name: Upload coverage to Codecov
|
|
if: env.COVERAGE_ENABLED == 'true'
|
|
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
flags: nodes-unit
|
|
name: nodes-unit
|
|
files: ./packages/**/coverage/cobertura-coverage.xml,./coverage/cobertura-coverage.xml
|
|
|
|
unit-test-frontend:
|
|
name: Frontend (${{ matrix.shard }}/2)
|
|
runs-on: ${{ vars.RUNNER_PROVIDER == 'github' && 'ubuntu-latest' || 'blacksmith-4vcpu-ubuntu-2204' }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
shard: [1, 2]
|
|
env:
|
|
COVERAGE_ENABLED: ${{ inputs.collectCoverage }}
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
ref: ${{ inputs.ref }}
|
|
|
|
- name: Build
|
|
uses: ./.github/actions/setup-nodejs
|
|
with:
|
|
node-version: ${{ inputs.nodeVersion }}
|
|
|
|
- name: Test
|
|
run: pnpm test:ci:frontend --summarize -- --shard=${{ matrix.shard }}/2
|
|
env:
|
|
VITEST_SHARD: ${{ matrix.shard }}/2
|
|
|
|
- name: Send Test Stats
|
|
if: ${{ !cancelled() }}
|
|
run: node .github/scripts/send-build-stats.mjs || true
|
|
env:
|
|
QA_METRICS_WEBHOOK_URL: ${{ secrets.QA_METRICS_WEBHOOK_URL }}
|
|
QA_METRICS_WEBHOOK_USER: ${{ secrets.QA_METRICS_WEBHOOK_USER }}
|
|
QA_METRICS_WEBHOOK_PASSWORD: ${{ secrets.QA_METRICS_WEBHOOK_PASSWORD }}
|
|
|
|
- name: Upload test results to Codecov
|
|
if: ${{ !cancelled() }}
|
|
uses: codecov/test-results-action@0fa95f0e1eeaafde2c782583b36b28ad0d8c77d3 # v1.2.1
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
name: frontend-shard-${{ matrix.shard }}
|
|
|
|
- name: Upload coverage to Codecov
|
|
if: env.COVERAGE_ENABLED == 'true'
|
|
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
flags: frontend
|
|
name: frontend-shard-${{ matrix.shard }}
|
|
files: ./packages/**/coverage/cobertura-coverage.xml,./coverage/cobertura-coverage.xml
|
|
|
|
unit-test:
|
|
name: Unit tests
|
|
runs-on: ubuntu-latest
|
|
needs: [unit-test-backend, integration-test-backend, unit-test-nodes, unit-test-frontend]
|
|
if: always()
|
|
steps:
|
|
- name: Fail if tests failed
|
|
if: needs.unit-test-backend.result == 'failure' || needs.integration-test-backend.result == 'failure' || needs.unit-test-nodes.result == 'failure' || needs.unit-test-frontend.result == 'failure'
|
|
run: exit 1
|