forked from n8n-io/n8n
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Parallelize unit tests on the CI (no-changelog)
- Loading branch information
Showing
12 changed files
with
206 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: 'Build n8n' | ||
description: 'Build n8n and cache the dist folder' | ||
inputs: | ||
ref: | ||
description: 'GitHub ref to build' | ||
required: true | ||
type: string | ||
cacheKey: | ||
description: 'Cache key for modules and build artifacts' | ||
required: true | ||
type: string | ||
nodeVersion: | ||
description: 'Version of node to use.' | ||
required: false | ||
type: string | ||
default: '18.x' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- run: corepack enable | ||
shell: bash | ||
|
||
- uses: actions/[email protected] | ||
with: | ||
node-version: ${{ inputs.nodeVersion }} | ||
cache: pnpm | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
shell: bash | ||
|
||
- name: Build | ||
run: pnpm build | ||
shell: bash | ||
|
||
- name: Cache build artifacts | ||
uses: actions/cache/[email protected] | ||
with: | ||
path: ./packages/**/dist | ||
key: ${{ inputs.cacheKey }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,83 +6,38 @@ on: | |
- master | ||
|
||
jobs: | ||
install-and-build: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
timeout-minutes: 30 | ||
|
||
strategy: | ||
matrix: | ||
node-version: [18.x, 20.x] | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- run: corepack enable | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/[email protected] | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: pnpm | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Build | ||
run: pnpm build | ||
ref: ${{ github.sha }} | ||
|
||
- name: Cache build artifacts | ||
uses: actions/cache/[email protected] | ||
- uses: ./.github/actions/build-n8n | ||
with: | ||
path: ./packages/**/dist | ||
key: ${{ github.sha }}-base:${{ matrix.node-version }}-test-lint | ||
ref: ${{ github.sha }} | ||
cacheKey: ${{ github.sha }}:build | ||
|
||
unit-test: | ||
name: Unit tests | ||
uses: ./.github/workflows/units-tests-reusable.yml | ||
needs: install-and-build | ||
uses: ./.github/workflows/reusable-units-tests.yml | ||
needs: build | ||
strategy: | ||
matrix: | ||
node-version: [18.x, 20.x] | ||
with: | ||
ref: ${{ inputs.branch }} | ||
nodeVersion: ${{ matrix.node-version }} | ||
cacheKey: ${{ github.sha }}-base:${{ matrix.node-version }}-test-lint | ||
cacheKey: ${{ github.sha }}:build | ||
collectCoverage: true | ||
|
||
lint: | ||
name: Lint changes | ||
runs-on: ubuntu-latest | ||
needs: install-and-build | ||
strategy: | ||
matrix: | ||
node-version: [18.x, 20.x] | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
repository: n8n-io/n8n | ||
ref: ${{ inputs.branch }} | ||
|
||
- run: corepack enable | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/[email protected] | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: pnpm | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Restore cached build artifacts | ||
uses: actions/cache/[email protected] | ||
with: | ||
path: ./packages/**/dist | ||
key: ${{ github.sha }}-base:${{ matrix.node-version }}-test-lint | ||
|
||
- name: Lint | ||
env: | ||
CI_LINT_MASTER: true | ||
run: pnpm lint | ||
uses: ./.github/workflows/reusable-linting.yml | ||
needs: build | ||
with: | ||
ref: ${{ inputs.branch }} | ||
cacheKey: ${{ github.sha }}:build | ||
|
||
notify-on-failure: | ||
name: Notify Slack on failure | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ jobs: | |
uses: actions/cache/[email protected] | ||
with: | ||
path: ./packages/**/dist | ||
key: ${{ github.sha }}:db-tests | ||
key: ${{ github.sha }}:build:backend | ||
|
||
mysql: | ||
name: MySQL | ||
|
@@ -54,7 +54,7 @@ jobs: | |
uses: actions/cache/[email protected] | ||
with: | ||
path: ./packages/**/dist | ||
key: ${{ github.sha }}:db-tests | ||
key: ${{ github.sha }}:build:backend | ||
|
||
- name: Start MySQL | ||
uses: isbang/[email protected] | ||
|
@@ -87,7 +87,7 @@ jobs: | |
uses: actions/cache/[email protected] | ||
with: | ||
path: ./packages/**/dist | ||
key: ${{ github.sha }}:db-tests | ||
key: ${{ github.sha }}:build:backend | ||
|
||
- name: Start Postgres | ||
uses: isbang/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,61 +9,25 @@ jobs: | |
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
repository: n8n-io/n8n | ||
ref: refs/pull/${{ github.event.pull_request.number }}/merge | ||
|
||
- 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 | ||
ref: ${{ github.sha }} | ||
|
||
- name: Cache build artifacts | ||
uses: actions/cache/[email protected] | ||
- uses: ./.github/actions/build-n8n | ||
with: | ||
path: ./packages/**/dist | ||
key: ${{ github.sha }}-base:18-test-lint | ||
ref: refs/pull/${{ github.event.pull_request.number }}/merge | ||
cacheKey: ${{ github.sha }}:build | ||
|
||
unit-test: | ||
name: Unit tests | ||
uses: ./.github/workflows/units-tests-reusable.yml | ||
uses: ./.github/workflows/reusable-units-tests.yml | ||
needs: install | ||
with: | ||
ref: refs/pull/${{ github.event.pull_request.number }}/merge | ||
cacheKey: ${{ github.sha }}-base:18-test-lint | ||
cacheKey: ${{ github.sha }}:build | ||
|
||
lint: | ||
name: Lint changes | ||
runs-on: ubuntu-latest | ||
name: Lint | ||
uses: ./.github/workflows/reusable-linting.yml | ||
needs: install | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
repository: n8n-io/n8n | ||
ref: refs/pull/${{ github.event.pull_request.number }}/merge | ||
|
||
- 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: Restore cached build artifacts | ||
uses: actions/cache/[email protected] | ||
with: | ||
path: ./packages/**/dist | ||
key: ${{ github.sha }}-base:18-test-lint | ||
|
||
- name: Lint | ||
run: pnpm lint | ||
with: | ||
ref: refs/pull/${{ github.event.pull_request.number }}/merge | ||
cacheKey: ${{ github.sha }}:build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Reusable linting workflow | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
description: 'GitHub ref to lint.' | ||
required: false | ||
type: string | ||
default: 'master' | ||
cacheKey: | ||
description: 'Cache key for modules and build artifacts.' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
group: [backend, frontend, nodes] | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
repository: n8n-io/n8n | ||
ref: ${{ inputs.ref }} | ||
|
||
- 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: Restore cached build artifacts | ||
uses: actions/cache/[email protected] | ||
with: | ||
path: ./packages/**/dist | ||
key: ${{ inputs.cacheKey }} | ||
|
||
- name: Lint | ||
run: pnpm lint:${{ matrix.group }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Reusable units test workflow | ||
name: Reusable unit-test workflow | ||
|
||
on: | ||
workflow_call: | ||
|
@@ -15,8 +15,7 @@ on: | |
default: '18.x' | ||
cacheKey: | ||
description: 'Cache key for modules and build artifacts.' | ||
required: false | ||
default: '' | ||
required: true | ||
type: string | ||
collectCoverage: | ||
required: false | ||
|
@@ -25,10 +24,12 @@ on: | |
|
||
jobs: | ||
unit-test: | ||
name: Unit tests | ||
runs-on: ubuntu-latest | ||
env: | ||
COVERAGE_ENABLED: ${{ inputs.collectCoverage }} | ||
strategy: | ||
matrix: | ||
group: [backend, frontend, nodes] | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
|
@@ -45,28 +46,43 @@ jobs: | |
- 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/[email protected] | ||
with: | ||
path: ./packages/**/dist | ||
key: ${{ inputs.cacheKey }} | ||
|
||
- name: Test Backend | ||
run: pnpm test:backend | ||
|
||
- name: Test Nodes | ||
run: pnpm test:nodes | ||
- name: Test | ||
run: pnpm test:${{ matrix.group }} | ||
|
||
- name: Test Frontend | ||
run: pnpm test:frontend | ||
- name: Cache Coverage | ||
if: ${{ inputs.collectCoverage == 'true' }} | ||
uses: actions/cache/[email protected] | ||
with: | ||
path: ./packages/**/coverage | ||
key: ${{ inputs.cacheKey }}:${{ matrix.group }}:coverage | ||
|
||
upload-coverage: | ||
name: Upload Coverage | ||
if: ${{ inputs.collectCoverage == 'true' }} | ||
runs-on: ubuntu-latest | ||
needs: unit-test | ||
steps: | ||
- uses: actions/cache/[email protected] | ||
with: | ||
path: ./packages/**/coverage | ||
key: ${{ inputs.cacheKey }}:backend:coverage | ||
- uses: actions/cache/[email protected] | ||
with: | ||
path: ./packages/**/coverage | ||
key: ${{ inputs.cacheKey }}:frontend:coverage | ||
- uses: actions/cache/[email protected] | ||
with: | ||
path: ./packages/**/coverage | ||
key: ${{ inputs.cacheKey }}:nodes:coverage | ||
- run: ls -R packages | ||
- name: Upload coverage to Codecov | ||
if: ${{ inputs.collectCoverage == 'true' }} | ||
uses: codecov/codecov-action@v3 | ||
uses: codecov/[email protected] | ||
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 | ||
files: packages/**/coverage/cobertura-coverage.xml | ||
token: ${{ secrets.CODECOV_TOKEN }} |
Oops, something went wrong.