n8n/.github/workflows/units-tests-reusable.yml
कारतोफ्फेलस्क्रिप्ट™ b910ed6847
ci: Use turbo for build cache (no-changelog) (#9696)
2024-07-05 17:43:52 +02:00

80 lines
1.9 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: 20.x
cacheKey:
description: Cache key for modules and build artifacts.
required: false
default: ''
type: string
collectCoverage:
required: false
default: false
type: boolean
secrets:
CODECOV_TOKEN:
description: 'Codecov upload token.'
required: false
jobs:
unit-test:
name: Unit tests
runs-on: ubuntu-latest
env:
COVERAGE_ENABLED: ${{ inputs.collectCoverage }}
steps:
- uses: actions/checkout@v4.1.1
with:
repository: n8n-io/n8n
ref: ${{ inputs.ref }}
- run: corepack enable
- name: Use Node.js ${{ inputs.nodeVersion }}
uses: actions/setup-node@v4.0.2
with:
node-version: ${{ inputs.nodeVersion }}
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Setup build cache
uses: rharkor/caching-for-turbo@v1.5
- name: Build
if: ${{ inputs.cacheKey == '' }}
run: pnpm build
- name: Restore cached build artifacts
if: ${{ inputs.cacheKey != '' }}
uses: actions/cache/restore@v4.0.0
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
uses: codecov/codecov-action@v4.5.0
with:
token: ${{ secrets.CODECOV_TOKEN }}