Skip to content

Runs unit tests for a given ref #24

Runs unit tests for a given ref

Runs unit tests for a given ref #24

name: Runs unit tests for a given ref
on:
workflow_dispatch:
inputs:
ref:
description: 'GitHub ref to test.'
required: false
default: 'master'
type: string
prNumber:
description: 'PR number to run tests for.'
required: false
type: number
jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.compute-branch.outputs.branch }}
steps:
- name: Compute branch
id: compute-branch
run: |
BRANCH_NAME=""
if [[ "${{ inputs.prNumber }}" != "" && "${{ inputs.prNumber }}" != "null" ]]; then
BRANCH_NAME="refs/pull/${{ inputs.prNumber }}/merge"
else
BRANCH_NAME="${{ inputs.ref }}"
fi
echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT
build:
name: Build
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
repository: n8n-io/n8n
ref: ${{ needs.prepare.outputs.branch }}
- run: corepack enable
- name: Use Node.js 18
uses: actions/[email protected]
with:
node-version: 18.x
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build
- name: Cache build artifacts
uses: actions/cache/[email protected]
with:
path: ./packages/**/dist
key: ${{ needs.prepare.outputs.branch }}-base:18-test-lint
unit-test:
name: Unit tests
needs: [prepare, build]
uses: ./.github/workflows/units-tests-reusable.yml
with:
ref: ${{ needs.prepare.outputs.branch }}
cacheKey: ${{ needs.prepare.outputs.branch }}-base:18-test-lint
collectCoverage: true # TODO: remove this before merging