n8n/.github/workflows/units-tests-reusable.yml
कारतोफ्फेलस्क्रिप्ट™ d1ca368c7d
ci: Fix codecov reporting, and include all packages (no-changelog) (#8276)
2024-01-09 16:18:20 +01:00

74 lines
2.2 KiB
YAML

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
default: '18.x'
cacheKey:
description: 'Cache key for modules and build artifacts.'
required: false
default: ''
type: string
collectCoverage:
required: false
default: 'false'
type: string
jobs:
unit-test:
name: Unit tests
runs-on: ubuntu-latest
env:
COVERAGE_ENABLED: ${{ inputs.collectCoverage }}
steps:
- uses: actions/checkout@v3.5.3
with:
repository: n8n-io/n8n
ref: ${{ inputs.ref }}
- uses: pnpm/action-setup@v2.4.0
- name: Use Node.js ${{ inputs.nodeVersion }}
uses: actions/setup-node@v3.7.0
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 != '' }}
uses: actions/cache/restore@v3.3.1
with:
path: ./packages/**/dist
key: ${{ inputs.cacheKey }}
- name: Test Backend
run: pnpm test:backend
- name: Test Nodes
run: pnpm test:nodes
- name: Test Frontend
run: pnpm test:frontend
- name: Upload coverage to Codecov
if: ${{ inputs.collectCoverage == 'true' }}
uses: codecov/codecov-action@v3
with:
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/editor-ui/coverage/cobertura-coverage.xml,packages/nodes-base/coverage/cobertura-coverage.xml,packages/workflow/coverage/cobertura-coverage.xml