2023-09-13 06:24:02 -07:00
|
|
|
name: Reusable units test workflow
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
ref:
|
|
|
|
description: 'GitHub ref to test.'
|
|
|
|
required: false
|
|
|
|
type: string
|
|
|
|
default: 'master'
|
|
|
|
nodeVersion:
|
|
|
|
description: 'Version of node to use.'
|
|
|
|
required: false
|
|
|
|
type: string
|
2024-05-24 03:32:50 -07:00
|
|
|
default: 20.x
|
2023-09-13 06:24:02 -07:00
|
|
|
cacheKey:
|
|
|
|
description: 'Cache key for modules and build artifacts.'
|
|
|
|
required: false
|
|
|
|
default: ''
|
|
|
|
type: string
|
2023-11-07 05:19:39 -08:00
|
|
|
collectCoverage:
|
|
|
|
required: false
|
|
|
|
default: 'false'
|
|
|
|
type: string
|
2023-09-13 06:24:02 -07:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
unit-test:
|
|
|
|
name: Unit tests
|
|
|
|
runs-on: ubuntu-latest
|
2023-11-07 05:19:39 -08:00
|
|
|
env:
|
|
|
|
COVERAGE_ENABLED: ${{ inputs.collectCoverage }}
|
2023-09-13 06:24:02 -07:00
|
|
|
steps:
|
2024-01-26 02:26:30 -08:00
|
|
|
- uses: actions/checkout@v4.1.1
|
2023-09-13 06:24:02 -07:00
|
|
|
with:
|
|
|
|
repository: n8n-io/n8n
|
|
|
|
ref: ${{ inputs.ref }}
|
|
|
|
|
2024-02-02 00:47:58 -08:00
|
|
|
- run: corepack enable
|
2023-09-13 06:24:02 -07:00
|
|
|
- name: Use Node.js ${{ inputs.nodeVersion }}
|
2024-05-24 03:32:50 -07:00
|
|
|
uses: actions/setup-node@v4.0.2
|
2023-09-13 06:24:02 -07:00
|
|
|
with:
|
|
|
|
node-version: ${{ inputs.nodeVersion }}
|
|
|
|
cache: pnpm
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
if: ${{ inputs.cacheKey == '' }}
|
|
|
|
run: pnpm build
|
|
|
|
|
|
|
|
- name: Restore cached build artifacts
|
|
|
|
if: ${{ inputs.cacheKey != '' }}
|
2024-01-26 02:26:30 -08:00
|
|
|
uses: actions/cache/restore@v4.0.0
|
2023-09-13 06:24:02 -07:00
|
|
|
with:
|
|
|
|
path: ./packages/**/dist
|
|
|
|
key: ${{ inputs.cacheKey }}
|
|
|
|
|
2023-11-07 05:19:39 -08:00
|
|
|
- name: Test Backend
|
|
|
|
run: pnpm test:backend
|
|
|
|
|
2023-11-10 06:04:26 -08:00
|
|
|
- name: Test Nodes
|
|
|
|
run: pnpm test:nodes
|
|
|
|
|
2023-11-07 05:19:39 -08:00
|
|
|
- name: Test Frontend
|
|
|
|
run: pnpm test:frontend
|
2023-09-13 06:24:02 -07:00
|
|
|
|
|
|
|
- name: Upload coverage to Codecov
|
2023-11-07 05:19:39 -08:00
|
|
|
if: ${{ inputs.collectCoverage == 'true' }}
|
2023-09-13 06:24:02 -07:00
|
|
|
uses: codecov/codecov-action@v3
|
|
|
|
with:
|
2024-05-10 09:49:22 -07:00
|
|
|
files: packages/@n8n/chat/coverage/cobertura-coverage.xml,packages/@n8n/nodes-langchain/coverage/cobertura-coverage.xml,packages/@n8n/permissions/coverage/cobertura-coverage.xml,packages/@n8n/client-oauth2/coverage/cobertura-coverage.xml,packages/cli/coverage/cobertura-coverage.xml,packages/core/coverage/cobertura-coverage.xml,packages/design-system/coverage/cobertura-coverage.xml,packages/@n8n/codemirror-lang/coverage/cobertura-coverage.xml,packages/editor-ui/coverage/cobertura-coverage.xml,packages/nodes-base/coverage/cobertura-coverage.xml,packages/workflow/coverage/cobertura-coverage.xml
|