ci: Improve CI performance (no-changelog) (#7637)

1. Split backend and frontend tests to avoid them running in parallel
2. Enable coverage only on `master`
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-11-07 14:19:39 +01:00 committed by GitHub
parent f748de9567
commit 2f665683fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 46 additions and 44 deletions

View file

@ -48,7 +48,8 @@ jobs:
with:
ref: ${{ inputs.branch }}
nodeVersion: ${{ matrix.node-version }}
cacheKey: ${{ github.sha }}-base:${{ matrix.node-version }}-test-lint
cacheKey: ${{ github.sha }}-base:${{ matrix.node-version }}-test-lint
collectCoverage: true
lint:
name: Lint changes

View file

@ -18,11 +18,17 @@ on:
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:
@ -51,10 +57,14 @@ jobs:
path: ./packages/**/dist
key: ${{ inputs.cacheKey }}
- name: Test
run: pnpm test
- name: Test Backend
run: pnpm test:backend
- 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/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

View file

@ -30,7 +30,7 @@ const config = {
return acc;
}, {}),
setupFilesAfterEnv: ['jest-expect-message'],
collectCoverage: true,
collectCoverage: process.env.COVERAGE_ENABLED === 'true',
coverageReporters: [process.env.COVERAGE_REPORT === 'true' ? 'text' : 'text-summary'],
collectCoverageFrom: ['src/**/*.ts'],
};

View file

@ -11,6 +11,8 @@
"scripts": {
"preinstall": "node scripts/block-npm-install.js",
"build": "turbo run build",
"build:backend": "pnpm --filter=!n8n-design-system --filter=!n8n-editor-ui build",
"build:frontend": "pnpm --filter=n8n-design-system --filter=n8n-editor-ui build",
"typecheck": "turbo run typecheck",
"dev": "turbo run dev --parallel",
"clean": "turbo run clean --parallel",
@ -23,6 +25,8 @@
"start:tunnel": "./packages/cli/bin/n8n start --tunnel",
"start:windows": "cd packages/cli/bin && n8n",
"test": "turbo run test",
"test:backend": "pnpm --filter=!n8n-design-system --filter=!n8n-editor-ui test",
"test:frontend": "pnpm --filter=n8n-design-system --filter=n8n-editor-ui test",
"watch": "turbo run watch",
"webhook": "./packages/cli/bin/n8n webhook",
"worker": "./packages/cli/bin/n8n worker",

View file

@ -17,7 +17,7 @@
"clean": "rimraf dist .turbo",
"build": "vite build",
"typecheck": "vue-tsc --declaration --emitDeclarationOnly",
"test": "vitest run --coverage",
"test": "vitest run",
"test:dev": "vitest",
"build:storybook": "storybook build",
"storybook": "storybook dev -p 6006",

View file

@ -1,9 +1,30 @@
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import { defineConfig, mergeConfig } from 'vite';
import { type UserConfig } from 'vitest';
import { defineConfig as defineVitestConfig } from 'vitest/config';
const { coverageReporters } = require('../../jest.config.js');
export const vitestConfig = defineVitestConfig({
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./src/__tests__/setup.ts'],
...(process.env.COVERAGE_ENABLED === 'true'
? {
coverage: {
provider: 'v8',
reporter: require('../../jest.config.js').coverageReporters,
all: true,
},
}
: {}),
css: {
modules: {
classNameStrategy: 'non-scoped',
},
},
},
}) as UserConfig;
export default mergeConfig(
defineConfig({
@ -35,21 +56,5 @@ export default mergeConfig(
},
},
}),
defineVitestConfig({
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./src/__tests__/setup.ts'],
coverage: {
provider: 'v8',
reporter: coverageReporters,
all: true,
},
css: {
modules: {
classNameStrategy: 'non-scoped',
},
},
},
}),
vitestConfig,
);

View file

@ -22,7 +22,7 @@
"lintfix": "eslint src --ext .js,.ts,.vue --fix",
"format": "prettier --write . --ignore-path ../../.prettierignore",
"serve": "cross-env VUE_APP_URL_BASE_API=http://localhost:5678/ vite --host 0.0.0.0 --port 8080 dev",
"test": "vitest run --coverage",
"test": "vitest run",
"test:dev": "vitest"
},
"dependencies": {

View file

@ -1,12 +1,10 @@
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import { defineConfig, mergeConfig } from 'vite';
import { defineConfig as defineVitestConfig } from 'vitest/config';
import { sentryVitePlugin } from '@sentry/vite-plugin';
import packageJSON from './package.json';
const { coverageReporters } = require('../../jest.config.js');
import { vitestConfig } from '../design-system/vite.config';
const vendorChunks = ['vue', 'vue-router'];
const n8nChunks = ['n8n-workflow', 'n8n-design-system'];
@ -115,21 +113,5 @@ export default mergeConfig(
},
},
}),
defineVitestConfig({
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./src/__tests__/setup.ts'],
coverage: {
provider: 'v8',
reporter: coverageReporters,
all: true,
},
css: {
modules: {
classNameStrategy: 'non-scoped',
},
},
},
}),
vitestConfig,
);